From 3507838024a44652a80fe17568db335745dc4091 Mon Sep 17 00:00:00 2001 From: jaydee Date: Tue, 24 Oct 2023 10:19:06 +0200 Subject: [PATCH] upt playbook --- playbooks/00_check_for_reboot.yml | 25 ++++++++ playbooks/00_install_zabbix_agent.yml | 53 ++++++++++++++++ playbooks/00_install_zabbix_agent2.yml | 35 +++++++++++ playbooks/00_setup_display.yml | 59 ++++++++++++++++++ playbooks/99_complete_install.yml | 1 - .../zabbix-release_6.4-1+ubuntu22.04_all.deb | Bin 0 -> 3744 bytes 6 files changed, 172 insertions(+), 1 deletion(-) create mode 100644 playbooks/00_check_for_reboot.yml create mode 100644 playbooks/00_install_zabbix_agent.yml create mode 100644 playbooks/00_install_zabbix_agent2.yml create mode 100644 playbooks/00_setup_display.yml create mode 100644 playbooks/files/packages/zabbix-release_6.4-1+ubuntu22.04_all.deb diff --git a/playbooks/00_check_for_reboot.yml b/playbooks/00_check_for_reboot.yml new file mode 100644 index 0000000..be98e81 --- /dev/null +++ b/playbooks/00_check_for_reboot.yml @@ -0,0 +1,25 @@ +- hosts: odroid_cluster + name: Check for reboot + become: true + tasks: + - name: Check if file exists using stat module + stat: + path: /var/run/reboot-required + register: file_status + + - name: Print file status + debug: + var: file_status.stat.exists + - name: Reboot the server + tags: reboot + become: yes + become_user: root + shell: "sleep 5 && reboot" + async: 1 + poll: 0 + when: file_status.stat.exists == true + + - name: (reboot) Wait for server to restart + ansible.builtin.wait_for_connection: + delay: 10 + timeout: 300 \ No newline at end of file diff --git a/playbooks/00_install_zabbix_agent.yml b/playbooks/00_install_zabbix_agent.yml new file mode 100644 index 0000000..f9b53db --- /dev/null +++ b/playbooks/00_install_zabbix_agent.yml @@ -0,0 +1,53 @@ +- hosts: odroid_cluster + name: Install zabbix agent + become: true + tasks: + - name: Upload zabbix package + ansible.builtin.copy: + src: packages/zabbix-release_6.4-1+ubuntu22.04_all.deb + dest: /tmp/ + # - name: Install a .deb package from the internet + # ansible.builtin.apt: + # deb: https://repo.zabbix.com/zabbix/6.4/ubuntu-arm64/pool/main/z/zabbix-release/zabbix-release_6.4-1+ubuntu22.04_all.deb + - name: Install a .deb package localy + ansible.builtin.apt: + deb: /tmp/zabbix-release_6.4-1+ubuntu22.04_all.deb + - name: Install zabbix packages + ansible.builtin.apt: + name: + - zabbix-agent2 + - zabbix-agent2-plugin-* + update_cache: yes + - name: Reconfigure zabbix agent Server + ansible.builtin.lineinfile: + path: /etc/zabbix/zabbix_agent2.conf + regexp: "^Server=.*" + insertafter: '^# Server=' + line: "Server=192.168.77.106" + + - name: Reconfigure zabbix agent ServerActive + ansible.builtin.lineinfile: + path: /etc/zabbix/zabbix_agent2.conf + regexp: "^ServerActive=.*" + line: "ServerActive=192.168.77.106" + - name: Reconfigure zabbix agent ListenPort + ansible.builtin.lineinfile: + path: /etc/zabbix/zabbix_agent2.conf + regexp: "^ListenPort=.*" + line: "ListenPort=10050" + # - name: Reconfigure zabbix agent ListenIP + # ansible.builtin.lineinfile: + # path: /etc/zabbix/zabbix_agent2.conf + # regexp: "^ListenIP=.*" + # line: "ListenIP=0.0.0.0" + - name: Reconfigure zabbix-agent2 hostname + ansible.builtin.lineinfile: + path: /etc/zabbix/zabbix_agent2.conf + regexp: "^Hostname=.*" + line: "Hostname={{ansible_hostname}}" + + - name: Restart zabbix-agent2 service + ansible.builtin.service: + name: zabbix-agent2.service + state: restarted + enabled: true \ No newline at end of file diff --git a/playbooks/00_install_zabbix_agent2.yml b/playbooks/00_install_zabbix_agent2.yml new file mode 100644 index 0000000..72dd680 --- /dev/null +++ b/playbooks/00_install_zabbix_agent2.yml @@ -0,0 +1,35 @@ +- hosts: odroid_cluster + name: Install zabbix agent + become: true + tasks: + - name: Reconfigure zabbix agent Server + ansible.builtin.lineinfile: + path: /etc/zabbix/zabbix_agent2.conf + regexp: "^Server=.*" + insertafter: '^# Server=' + line: "Server=192.168.77.106" + + - name: Reconfigure zabbix agent ServerActive + ansible.builtin.lineinfile: + path: /etc/zabbix/zabbix_agent2.conf + regexp: "^ServerActive=.*" + insertafter: '^# ServerActive=' + line: "ServerActive=192.168.77.106" + - name: Reconfigure zabbix agent ListenPort + ansible.builtin.lineinfile: + path: /etc/zabbix/zabbix_agent2.conf + regexp: "^ListenPort=.*" + insertafter: '^# ListenPort=' + line: "ListenPort=10050" + - name: Reconfigure zabbix agent ListenIP + ansible.builtin.lineinfile: + path: /etc/zabbix/zabbix_agent2.conf + regexp: "^ListenIP=.*" + insertafter: '^# ListenIP=' + line: "ListenIP=0.0.0.0" + - name: Reconfigure zabbix-agent2 hostname + ansible.builtin.lineinfile: + path: /etc/zabbix/zabbix_agent2.conf + regexp: "^Hostname=.*" + insertafter: '^# Hostname=' + line: "Hostname={{ansible_hostname}}" \ No newline at end of file diff --git a/playbooks/00_setup_display.yml b/playbooks/00_setup_display.yml new file mode 100644 index 0000000..a087d7a --- /dev/null +++ b/playbooks/00_setup_display.yml @@ -0,0 +1,59 @@ +- hosts: odroid_master + name: Setup info display + become: true + tasks: + - name: Install deps... + ansible.builtin.apt: + name: + - python3-pip + - python3-dev + - name: Remove file (delete file) + ansible.builtin.file: + path: /usr/lib/python3.11/EXTERNALLY-MANAGED + state: absent + + - name: Install bottle python package + ansible.builtin.pip: + name: + - RPLCD + - psutil + - smbus2 + - uptime + - name: Upload led control scripts + ansible.builtin.copy: + src: scripts/lcd_control.py + dest: /usr/bin/lcd_control.py + - name: Upload led control service + ansible.builtin.copy: + src: services/lcd_control.service + dest: /etc/systemd/system/ + - name: Upload led control scripts + ansible.builtin.copy: + src: scripts/lcd_control_restart.py + dest: /usr/bin/lcd_control_restart.py + - name: Upload led control service + ansible.builtin.copy: + src: services/lcd_control_restart.service + dest: /etc/systemd/system/ + - name: Upload led control scripts + ansible.builtin.copy: + src: scripts/lcd_control_start.py + dest: /usr/bin/lcd_control_start.py + - name: Upload led control service + ansible.builtin.copy: + src: services/lcd_control_start.service + dest: /etc/systemd/system/ + - name: reload systemctl + ansible.builtin.command: systemctl daemon-reload + - name: Enable service startup lcd_control + ansible.builtin.command: systemctl enable lcd_control.service + - name: Starting service lcd_control + ansible.builtin.command: systemctl start lcd_control.service + - name: Enable service startup lcd_control_restart.service + ansible.builtin.command: systemctl enable lcd_control_restart.service + - name: Enable service startup lcd_control_start.service + ansible.builtin.command: systemctl enable lcd_control_start.service + # - name: Start service lcd_control_restart.service + # ansible.builtin.command: systemctl start lcd_control_restart.service + # - name: start lcd script + # shell: cd /root; nohup python3 lcd_control.py >/dev/null 2>&1 & \ No newline at end of file diff --git a/playbooks/99_complete_install.yml b/playbooks/99_complete_install.yml index da5ac5d..500776f 100644 --- a/playbooks/99_complete_install.yml +++ b/playbooks/99_complete_install.yml @@ -21,7 +21,6 @@ import_playbook: 70_install_k3s.yml - name: Install worker import_playbook: 72_install_k3s_worker.yml - - name: Install zabbix agent import_playbook: 00_install_zabbix_agent.yml - name: Reboot All diff --git a/playbooks/files/packages/zabbix-release_6.4-1+ubuntu22.04_all.deb b/playbooks/files/packages/zabbix-release_6.4-1+ubuntu22.04_all.deb new file mode 100644 index 0000000000000000000000000000000000000000..0765f2d5b629665f4114f6a2e4fbed7b1c4c3229 GIT binary patch literal 3744 zcmbu>WmFT6y9e-5(lsR~GC~9-#~2_;BO@h*F+$1FH9|@lB{D!zQW!`$327-AEl77G zB1k(xq)WK|&+p#8>>X^KZ9GJ6ojq*OfnYFL z5+)-nDJuz+kN|`K&fomAB_$+aP$(Gucm6xpG!QWf8aq!9U$m#2n6C|5EFkDV-@_pP z^TC?tk4%u6IRHSuHdXV0yseTPW57eg3iv0?gaVbtJ6EKFRsc5Irkl@5Qroz+6$4p1 z1_TNov$X+z5}!%Y%M&vib8dqMH8$>WC8B;_s!HjZzUOHM{QgMo?z~>^%Dn6%K99FK z8ktF0NnVgi5}H|*k~}#8_`M$X!2$Va18&v_q!tb8dl)~pjN%fDSJl9Rly~H20ZO_CLGjUsjdL#0)*&{o&t(gpk_YG?x_+CU2a+NlquWfo6iy0s zq~Ki|qF@!;8V^XgrD^8k#*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