From 6b33f6c34a8b861b3f2d006ea24459c2e7c8d7ba Mon Sep 17 00:00:00 2001 From: Talha Bin Rizwan Date: Fri, 22 Mar 2024 16:00:13 +0500 Subject: [PATCH 1/5] PMM-12998 Log message on ansible self update. --- update/ansible/playbook/tasks/update.yml | 53 ++++++++++++++---------- 1 file changed, 32 insertions(+), 21 deletions(-) diff --git a/update/ansible/playbook/tasks/update.yml b/update/ansible/playbook/tasks/update.yml index ff6632a6ad..04b756f859 100644 --- a/update/ansible/playbook/tasks/update.yml +++ b/update/ansible/playbook/tasks/update.yml @@ -22,6 +22,38 @@ - vmproxy - grafana-db-migrator pre_tasks: + - name: Check if ansible-core RPM was updated + shell: "grep -A 1 'Install ansible-core RPM | EL9' /srv/logs/pmm-update-perform.log | grep -qE 'changed' && echo 'Updated' || echo 'Not Updated'" + register: ansible_core_log + changed_when: False + ignore_errors: True + + - name: Log message if ansible-core RPM was updated + debug: + msg: "The ansible-core package was updated. The playbook is currently being re-run to apply the changes." + when: ansible_core_log.stdout == "Updated" + + - name: Remove ansible RPM if installed | EL9 + when: + - ansible_distribution == 'OracleLinux' or ansible_distribution == 'AlmaLinux' + - ansible_distribution_major_version == '9' + yum: + name: ansible + state: absent + ignore_errors: yes + + - name: Install ansible-core RPM | EL9 + when: + - ansible_distribution == 'OracleLinux' or ansible_distribution == 'AlmaLinux' + - ansible_distribution_major_version == '9' + yum: + name: + - ansible-core + - ansible-collection-community-general + - ansible-collection-community-postgresql + - ansible-collection-ansible-posix + state: latest + - name: detect /srv/pmm-distribution stat: path: /srv/pmm-distribution @@ -271,27 +303,6 @@ - sshpass - vi - - name: Remove ansible RPM if installed | EL9 - when: - - ansible_distribution == 'OracleLinux' or ansible_distribution == 'AlmaLinux' - - ansible_distribution_major_version == '9' - yum: - name: ansible - state: absent - ignore_errors: yes - - - name: Install ansible-core RPM | EL9 - when: - - ansible_distribution == 'OracleLinux' or ansible_distribution == 'AlmaLinux' - - ansible_distribution_major_version == '9' - yum: - name: - - ansible-core - - ansible-collection-community-general - - ansible-collection-community-postgresql - - ansible-collection-ansible-posix - state: present - - name: Update system packages EL9 when: - ansible_distribution == 'OracleLinux' or ansible_distribution == 'AlmaLinux' From 4d99a503f31de4905eb9971397d0d9013ff67acd Mon Sep 17 00:00:00 2001 From: Talha Bin Rizwan Date: Tue, 26 Mar 2024 14:29:59 +0500 Subject: [PATCH 2/5] Update update/ansible/playbook/tasks/update.yml Co-authored-by: Alex Demidoff --- update/ansible/playbook/tasks/update.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/update/ansible/playbook/tasks/update.yml b/update/ansible/playbook/tasks/update.yml index 04b756f859..8b4bfb45a8 100644 --- a/update/ansible/playbook/tasks/update.yml +++ b/update/ansible/playbook/tasks/update.yml @@ -23,7 +23,7 @@ - grafana-db-migrator pre_tasks: - name: Check if ansible-core RPM was updated - shell: "grep -A 1 'Install ansible-core RPM | EL9' /srv/logs/pmm-update-perform.log | grep -qE 'changed' && echo 'Updated' || echo 'Not Updated'" + shell: "grep -A 1 'Install ansible-core RPM | EL9' /srv/logs/pmm-update-perform.log | grep -q 'changed' && echo 'Updated' || echo 'Not Updated'" register: ansible_core_log changed_when: False ignore_errors: True From a144aa07db67ae70726040952342a45647d18749 Mon Sep 17 00:00:00 2001 From: Talha Bin Rizwan Date: Thu, 4 Apr 2024 16:26:08 +0500 Subject: [PATCH 3/5] PMM-12998 Log message on ansible self update. --- update/ansible/playbook/tasks/update.yml | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/update/ansible/playbook/tasks/update.yml b/update/ansible/playbook/tasks/update.yml index 8b4bfb45a8..38bf3705f6 100644 --- a/update/ansible/playbook/tasks/update.yml +++ b/update/ansible/playbook/tasks/update.yml @@ -22,16 +22,14 @@ - vmproxy - grafana-db-migrator pre_tasks: - - name: Check if ansible-core RPM was updated - shell: "grep -A 1 'Install ansible-core RPM | EL9' /srv/logs/pmm-update-perform.log | grep -q 'changed' && echo 'Updated' || echo 'Not Updated'" - register: ansible_core_log - changed_when: False - ignore_errors: True + - name: Check for updates of ansible-core package + shell: yum list updates ansible-core | grep -q 'ansible-core' && echo 'Available' || echo 'Not Available' + register: ansible_core_update - - name: Log message if ansible-core RPM was updated + - name: Log message if ansible-core package needs update debug: - msg: "The ansible-core package was updated. The playbook is currently being re-run to apply the changes." - when: ansible_core_log.stdout == "Updated" + msg: "The ansible-core package needs update. Playbook will re-run to apply the changes." + when: ansible_core_update.stdout == "Available" - name: Remove ansible RPM if installed | EL9 when: From 0765e30eb38135fa258b06e5e076fed4120cfdd1 Mon Sep 17 00:00:00 2001 From: Talha Bin Rizwan Date: Thu, 4 Apr 2024 16:48:10 +0500 Subject: [PATCH 4/5] PMM-12998 Log message on ansible self update. --- update/ansible/playbook/tasks/update.yml | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/update/ansible/playbook/tasks/update.yml b/update/ansible/playbook/tasks/update.yml index 38bf3705f6..2758c5c89a 100644 --- a/update/ansible/playbook/tasks/update.yml +++ b/update/ansible/playbook/tasks/update.yml @@ -22,14 +22,20 @@ - vmproxy - grafana-db-migrator pre_tasks: - - name: Check for updates of ansible-core package + - name: Check for updates of ansible-core package | EL9 shell: yum list updates ansible-core | grep -q 'ansible-core' && echo 'Available' || echo 'Not Available' register: ansible_core_update + when: + - ansible_distribution == 'OracleLinux' or ansible_distribution == 'AlmaLinux' + - ansible_distribution_major_version == '9' - - name: Log message if ansible-core package needs update + - name: Log message if ansible-core package needs update | EL9 debug: msg: "The ansible-core package needs update. Playbook will re-run to apply the changes." - when: ansible_core_update.stdout == "Available" + when: + - ansible_distribution == 'OracleLinux' or ansible_distribution == 'AlmaLinux' + - ansible_distribution_major_version == '9' + - ansible_core_update.stdout == "Available" - name: Remove ansible RPM if installed | EL9 when: From a61e65381e86fb0909c756e3e7fc65f863bc8487 Mon Sep 17 00:00:00 2001 From: Talha Bin Rizwan Date: Thu, 4 Apr 2024 16:58:43 +0500 Subject: [PATCH 5/5] PMM-12998 Log message on ansible self update. --- update/ansible/playbook/tasks/update.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/update/ansible/playbook/tasks/update.yml b/update/ansible/playbook/tasks/update.yml index 2758c5c89a..be8f18e4bb 100644 --- a/update/ansible/playbook/tasks/update.yml +++ b/update/ansible/playbook/tasks/update.yml @@ -50,6 +50,7 @@ when: - ansible_distribution == 'OracleLinux' or ansible_distribution == 'AlmaLinux' - ansible_distribution_major_version == '9' + - not ansible_check_mode yum: name: - ansible-core