Skip to content

Commit

Permalink
[FIX] ansible module uri setup password ให้กับ kibana ผ่าน role elk_ssl
Browse files Browse the repository at this point in the history
  • Loading branch information
wdrdres3qew5ts21 committed Jun 7, 2020
1 parent 2185628 commit 9a96f48
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 27 deletions.
37 changes: 17 additions & 20 deletions Ansible-ELK-Stack/roles/elk_ssl/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,26 +34,23 @@
state: present
remove_orphans: true

- name: "Change password for Kibana"
become: no
shell:
cmd: >
bash -c "
while true
do
curl --fail -u elastic:PleaseChangeMe \
'https://localhost:9200/_cluster/health?wait_for_status=yellow' \
&& break
sleep 5
done
curl -X POST -v -k --cacert /usr/share/elasticsearch/config/certificates/ca/ca.crt \
'https://localhost:9200/_security/user/kibana/_password?pretty' \
-u elastic:PleaseChangeMe -H 'Content-Type: application/json' \
-d ' { \"password\" : \"PleaseChangeMe\" } ' && echo 'success change password success'
"

- name: Pause play until a URL is reachable from this host
uri:
url: "https://localhost:9200/_security/user/kibana/_password?pretty"
follow_redirects: none
method: POST
user: elastic
password: PleaseChangeMe
validate_certs: no
force_basic_auth: yes
body_format: json
body: >
{ "password" : "PleaseChangeMe" }
register: _result
until: _result.status == 200
retries: 20
delay: 5



2 changes: 1 addition & 1 deletion Ansible-ELK-Stack/setup-ssl-stack.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
become_method: sudo
roles: # ทำให้ ansible รันเฉพาะ tag ได้ถ้าไม่ระบุแท๊กก็จะรันทั้งมด ansible-playbook setup.yml -t docker
- {role: docker, tags: "docker"}
- {role: elk, tags: "elk_ssl"}
- {role: elk_ssl, tags: "elk_ssl"}
17 changes: 11 additions & 6 deletions Ansible-ELK-Stack/setupKibanaPassword.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
#!/bin/bash
# while true
# do
# curl --fail -k -u elastic:PleaseChangeMe \
# "https://localhost:9200/_cluster/health?wait_for_status=yellow" && break
# sleep 5
# done

while true
do
curl --fail -u elastic:PleaseChangeMe \
"http://localhost:9200/_cluster/health?wait_for_status=yellow" \
&& break
curl --fail -k -u elastic:PleaseChangeMe \
curl -X POST -v -k "https://localhost:9200/_security/user/kibana/_password?pretty" -u elastic:PleaseChangeMe -H 'Content-Type: application/json' -d ' { "password" : "PleaseChangeMe" } ' && break
sleep 5
done

curl -X POST -v -k "http://localhost:9200/_security/user/kibana/_password?pretty" -u elastic:PleaseChangeMe -H 'Content-Type: application/json' -d ' { "password" : "PleaseChangeMe" } ' && echo "success change password success"


echo "fuckkkkkkkkkkkkkkkkkkk"
curl -X POST -v -k "https://localhost:9200/_security/user/kibana/_password?pretty" -u elastic:PleaseChangeMe -H 'Content-Type: application/json' -d ' { "password" : "PleaseChangeMe" } '

0 comments on commit 9a96f48

Please sign in to comment.