From d7a2181ab902f217cb0eb1976ae6ba0dda9a6f1f Mon Sep 17 00:00:00 2001 From: Gasper Spagnolo Date: Sun, 25 Sep 2022 22:41:47 +0200 Subject: [PATCH] Fixing script --- inventory.yml | 2 ++ playbook.yml | 39 ++++++++++++++++++++++++++++++--------- run.sh | 1 + 3 files changed, 33 insertions(+), 9 deletions(-) create mode 100755 run.sh diff --git a/inventory.yml b/inventory.yml index a696006..c11c524 100644 --- a/inventory.yml +++ b/inventory.yml @@ -1,2 +1,4 @@ [okeanos_server] faust.ad +# root: r00tP@ssWd +# user: KrknPGiD0E diff --git a/playbook.yml b/playbook.yml index d2d77a3..ecc16f5 100644 --- a/playbook.yml +++ b/playbook.yml @@ -1,24 +1,45 @@ --- - name: Setup faustAD platform hosts: okeanos_server + gather_facts: yes + become: yes tasks: - - name: Update and upgrade system + - name: System details + debug: msg='{{ item }}' + with_items: + - '{{ ansible_distribution }}' + - '{{ ansible_distribution_release }}' + - '{{ ansible_distribution_version }}' + - '{{ ansible_distribution_major_version }}' + + - name: Update system apt: - name: '*' - state: latest update_cache: yes force_apt_get: yes - register: apt_update_status + cache_valid_time: 3600 - - name: Remove packages not needed anymore + - name: Upgrade system apt: + upgrade: yes + force_apt_get: yes autoremove: yes - - name: Reboot when packages were updated + - name: Check if reboot is needed + register: reboot_required_file + stat: + path: /var/run/reboot-required + get_md5: no + + - name: Reboot the server if kernel was updated reboot: - post_reboot_delay: 60 - when: apt_update_status.changed + msg: "Reboot initiated by Ansible for kernel updates" + connect_timeout: 5 + reboot_timeout: 300 + pre_reboot_delay: 0 + post_reboot_delay: 30 + test_command: uptime + when: reboot_required_file.stat.exists - name: Install required packages for Docker apt: @@ -40,7 +61,7 @@ - name: Add Docker Repository apt_repository: - repo: deb https://download.docker.com/linux/ubuntu focal stable + repo: 'deb https://download.docker.com/linux/ubuntu {{ ansible_distribution_release }} stable' state: present - name: Update apt and install docker-ce diff --git a/run.sh b/run.sh new file mode 100755 index 0000000..12cbf1c --- /dev/null +++ b/run.sh @@ -0,0 +1 @@ +ansible-playbook -i inventory.yml playbook.yml