Skip to content

Commit

Permalink
[ADD] Ansible role ติดตั้ง Elastic + Kibana พร้อมตั้ง Password Automa…
Browse files Browse the repository at this point in the history
…tion
  • Loading branch information
wdrdres3qew5ts21 committed Jun 7, 2020
1 parent 4a96c04 commit e1662d9
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .env
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#ถ้า set ตัวนี้จะทำการ ovver default name ทันที
#COMPOSE_PROJECT_NAME=es
CERTS_DIR=/usr/share/elasticsearch/config/certificates
ELASTIC_PASSWORD=PleaseChangeMe
ELASTIC_PASSWORD=
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ nbdist/
# gitignore template for Nuxt.js projects
#
# Recommended template: Node.gitignore

.env
# Nuxt build
.nuxt

Expand Down
6 changes: 6 additions & 0 deletions Ansible-ELK-Stack/foo.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
$ANSIBLE_VAULT;1.2;AES256;test
30356435383966623237363336376132373461396466633436363965653464616232356664323131
3936316364626139626162646362643339373830393265640a656264383463326566656165313933
61303933393934363433303564343530636135626633373535653931363865393531396634376533
3535316337316466330a373030376261646539393839373134653733323432336361653266663732
6134
1 change: 0 additions & 1 deletion Ansible-ELK-Stack/hello.txt

This file was deleted.

6 changes: 6 additions & 0 deletions Ansible-ELK-Stack/roles/elk/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,10 @@
state: present
remove_orphans: true

- name: "Change password for Kibana"
script: ../setupKibanaPassword.sh





2 changes: 1 addition & 1 deletion changePassword.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash
curl -X POST -v -k --cacert /usr/share/elasticsearch/config/certificates/ca/ca.crt "https://elasticsearch1:9200/_security/user/kibana/_password?pretty" -u elastic:PleaseChangeMe -H 'Content-Type: application/json' -d' { "password" : "PleaseChangeMe" } '
curl -X POST -v -k --cacert /usr/share/elasticsearch/config/certificates/ca/ca.crt "https://elasticsearch1:9200/_security/user/kibana/_password?pretty" -u elastic: -H 'Content-Type: application/json' -d' { "password" : "" } '

if [[ $? == 51 ]]
then
Expand Down
2 changes: 2 additions & 0 deletions docker-compose-elastic-single-ssl.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
version: '3.3'
services:
env_file: Ansible-ELK-Stack/elk.config
elasticsearch1:
image: docker.elastic.co/elasticsearch/elasticsearch:7.7.0
container_name: elasticsearch1
Expand Down Expand Up @@ -47,6 +48,7 @@ services:
ports:
- 9200:9200


kibana:
image: docker.elastic.co/kibana/kibana:7.7.0
container_name: kibana
Expand Down
14 changes: 14 additions & 0 deletions setupKibanaPassword.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash
while true
do
curl --fail -u "elastic:" \
"http://localhost:9200/_cluster/health?wait_for_status=yellow" \
&& break
sleep 5
done

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

0 comments on commit e1662d9

Please sign in to comment.