From 9a284f0378bdd1977cf1ced5662fa46b4121dd88 Mon Sep 17 00:00:00 2001 From: qiaofeng1227 <76487013@qq.com> Date: Tue, 17 May 2022 17:09:10 +0800 Subject: [PATCH] elk --- apps/roles/elk/Notes.md | 0 apps/roles/elk/defaults/main.yml | 1 + apps/roles/elk/files/template.service | 0 apps/roles/elk/handlers/main.yml | 0 apps/roles/elk/meta/main.yml | 19 +++++++++++++++++++ apps/roles/elk/tasks/Debian.yml | 0 apps/roles/elk/tasks/RedHat.yml | 0 apps/roles/elk/tasks/main.yml | 21 +++++++++++++++++++++ apps/roles/elk/tasks/pre.yml | 20 ++++++++++++++++++++ apps/roles/elk/templates/template.conf | 0 apps/roles/elk/vars/main.yml | 17 +++++++++++++++++ 11 files changed, 78 insertions(+) create mode 100644 apps/roles/elk/Notes.md create mode 100644 apps/roles/elk/defaults/main.yml create mode 100644 apps/roles/elk/files/template.service create mode 100644 apps/roles/elk/handlers/main.yml create mode 100644 apps/roles/elk/meta/main.yml create mode 100644 apps/roles/elk/tasks/Debian.yml create mode 100644 apps/roles/elk/tasks/RedHat.yml create mode 100644 apps/roles/elk/tasks/main.yml create mode 100644 apps/roles/elk/tasks/pre.yml create mode 100644 apps/roles/elk/templates/template.conf create mode 100644 apps/roles/elk/vars/main.yml diff --git a/apps/roles/elk/Notes.md b/apps/roles/elk/Notes.md new file mode 100644 index 00000000..e69de29b diff --git a/apps/roles/elk/defaults/main.yml b/apps/roles/elk/defaults/main.yml new file mode 100644 index 00000000..8b137891 --- /dev/null +++ b/apps/roles/elk/defaults/main.yml @@ -0,0 +1 @@ + diff --git a/apps/roles/elk/files/template.service b/apps/roles/elk/files/template.service new file mode 100644 index 00000000..e69de29b diff --git a/apps/roles/elk/handlers/main.yml b/apps/roles/elk/handlers/main.yml new file mode 100644 index 00000000..e69de29b diff --git a/apps/roles/elk/meta/main.yml b/apps/roles/elk/meta/main.yml new file mode 100644 index 00000000..cbb0858d --- /dev/null +++ b/apps/roles/elk/meta/main.yml @@ -0,0 +1,19 @@ +--- +dependencies: [] + +galaxy_info: + author: + description: + company: + license: + min_ansible_version: + platforms: + - name: EL + versions: + - 7 + - name: Ubuntu + versions: + - 18.04 + + galaxy_tags: + diff --git a/apps/roles/elk/tasks/Debian.yml b/apps/roles/elk/tasks/Debian.yml new file mode 100644 index 00000000..e69de29b diff --git a/apps/roles/elk/tasks/RedHat.yml b/apps/roles/elk/tasks/RedHat.yml new file mode 100644 index 00000000..e69de29b diff --git a/apps/roles/elk/tasks/main.yml b/apps/roles/elk/tasks/main.yml new file mode 100644 index 00000000..bb87efe0 --- /dev/null +++ b/apps/roles/elk/tasks/main.yml @@ -0,0 +1,21 @@ +- name: wait for {{appname}} start + wait_for: + port: "{{nginx_reverse_proxy_port}}" + delay: 10 + timeout: 300 + +- name: Check {{appname}} Version + shell: | + sudo echo -e "elk_version: `docker exec -it elk-elasticsearch bin/elasticsearch --version | awk -F ' ' '{print $2}'`" |sudo tee -a /data/logs/install_version.txt + +- block: + - pause: + prompt: "Please login to Kibana UI and check it, then input Enter to continue" + echo: no + - name: Delete contains and images resources + shell: | + docker-compose down -v + docker system prune --all --force + args: + chdir: /data/wwwroot/elk + when: elk_delete_image == 'y' diff --git a/apps/roles/elk/tasks/pre.yml b/apps/roles/elk/tasks/pre.yml new file mode 100644 index 00000000..dc05e224 --- /dev/null +++ b/apps/roles/elk/tasks/pre.yml @@ -0,0 +1,20 @@ +- pause: + prompt: | + Do you want to delete containers and images (y/n): + 'y': Delete image + 'n': Do not delete image + private: no + Default: 'y' + register: delete_image + +- set_fact: + elk_delete_image: "{{delete_image.user_input}}" + +- debug: + msg: "elk_delete_image is {{elk_delete_image}}" + +- name: Config .env for start containers + shell: | + public_ip=`wget -O - https://download.websoft9.com/ansible/get_ip.sh | bash` + sed -i 's/APP_VERSION=.*/APP_VERSION=v{{erpnext_version}}/g' {{installpath}}/{{appname}}/.env + sed -i "s/erp.example.com/$public_ip/g" {{installpath}}/{{appname}}/.env diff --git a/apps/roles/elk/templates/template.conf b/apps/roles/elk/templates/template.conf new file mode 100644 index 00000000..e69de29b diff --git a/apps/roles/elk/vars/main.yml b/apps/roles/elk/vars/main.yml new file mode 100644 index 00000000..8ceb4e82 --- /dev/null +++ b/apps/roles/elk/vars/main.yml @@ -0,0 +1,17 @@ +# global +region: "0" + +common_install_docker: True +docker_install: False + +nginx_vhost_mode: "reverse" +nginx_reverse_proxy_port: "9001" +nginx_appname: "ELK" + +init_application: + elk: + username: elastic + password: "elastic123" + commands: + - sudo sed -i "s/elastic123/$new_password/g" `grep 'elastic123' /data/apps/elk/.env -rnl` + - sudo sed -i "s/elastic123/$new_password/g" `grep 'elastic123' /data/apps/elk/src/logstash/pipeline/logstash.conf -rnl`