From 7966f5725cf5b320adae0899d77ffdd4671fcda8 Mon Sep 17 00:00:00 2001 From: Anoop C S Date: Wed, 14 Feb 2024 19:53:00 +0530 Subject: [PATCH 1/2] setup: Install jmespath python module using pip Very recently on CentOS Stream 8 ansible version got updated to v2.16.3 built with Python 3.12. Due to unavailability of python 3.12 module for jmespath playbook execution is expected to fail. Therefore switch the python module installation from RPMs to pip where it can be versioned. Signed-off-by: Anoop C S --- playbooks/roles/setup.prep/tasks/centos.yml | 10 ---------- playbooks/roles/setup.prep/tasks/centos8.yml | 13 +++++++++++++ playbooks/roles/setup.prep/tasks/centos9.yml | 12 ++++++++++++ playbooks/roles/sit.cephfs/tasks/setup/centos8.yml | 7 +++---- playbooks/roles/sit.cephfs/tasks/setup/centos9.yml | 6 ++---- .../roles/sit.glusterfs/tasks/setup/centos8.yml | 7 +++---- .../roles/sit.glusterfs/tasks/setup/centos9.yml | 6 ++---- 7 files changed, 35 insertions(+), 26 deletions(-) create mode 100644 playbooks/roles/setup.prep/tasks/centos8.yml create mode 100644 playbooks/roles/setup.prep/tasks/centos9.yml diff --git a/playbooks/roles/setup.prep/tasks/centos.yml b/playbooks/roles/setup.prep/tasks/centos.yml index 3266457c..befc43b4 100644 --- a/playbooks/roles/setup.prep/tasks/centos.yml +++ b/playbooks/roles/setup.prep/tasks/centos.yml @@ -9,16 +9,6 @@ name: epel-release state: latest -- name: Install Python3 pip - yum: - name: python3-pip - state: installed - -- name: Install pip jinja2 library - pip: - name: jinja2 - state: latest - # RHEL 8 image doesn't include make - name: Install additional packages yum: diff --git a/playbooks/roles/setup.prep/tasks/centos8.yml b/playbooks/roles/setup.prep/tasks/centos8.yml new file mode 100644 index 00000000..695b4042 --- /dev/null +++ b/playbooks/roles/setup.prep/tasks/centos8.yml @@ -0,0 +1,13 @@ +--- +- name: Process common OS tasks + include_tasks: centos.yml + +- name: Install Python3.12 pip + yum: + name: python3.12-pip + state: installed + +- name: Install pip jinja2 library + pip: + executable: pip3.12 + name: jinja2 diff --git a/playbooks/roles/setup.prep/tasks/centos9.yml b/playbooks/roles/setup.prep/tasks/centos9.yml new file mode 100644 index 00000000..4d24625c --- /dev/null +++ b/playbooks/roles/setup.prep/tasks/centos9.yml @@ -0,0 +1,12 @@ +--- +- name: Process common OS tasks + include_tasks: centos.yml + +- name: Install Python3 pip + yum: + name: python3-pip + state: installed + +- name: Install pip jinja2 library + pip: + name: jinja2 diff --git a/playbooks/roles/sit.cephfs/tasks/setup/centos8.yml b/playbooks/roles/sit.cephfs/tasks/setup/centos8.yml index 4432d3f3..43ab9049 100644 --- a/playbooks/roles/sit.cephfs/tasks/setup/centos8.yml +++ b/playbooks/roles/sit.cephfs/tasks/setup/centos8.yml @@ -1,6 +1,5 @@ --- - name: Install Python jmespath module - yum: - name: - - python3.11-jmespath - state: latest + pip: + executable: pip3.12 + name: jmespath diff --git a/playbooks/roles/sit.cephfs/tasks/setup/centos9.yml b/playbooks/roles/sit.cephfs/tasks/setup/centos9.yml index ee9e53c7..cf4d632c 100644 --- a/playbooks/roles/sit.cephfs/tasks/setup/centos9.yml +++ b/playbooks/roles/sit.cephfs/tasks/setup/centos9.yml @@ -1,6 +1,4 @@ --- - name: Install Python jmespath module - yum: - name: - - python3-jmespath - state: latest + pip: + name: jmespath diff --git a/playbooks/roles/sit.glusterfs/tasks/setup/centos8.yml b/playbooks/roles/sit.glusterfs/tasks/setup/centos8.yml index f0883279..16af4526 100644 --- a/playbooks/roles/sit.glusterfs/tasks/setup/centos8.yml +++ b/playbooks/roles/sit.glusterfs/tasks/setup/centos8.yml @@ -3,7 +3,6 @@ include_tasks: centos.yml - name: Install Python jmespath module - yum: - name: - - python3.11-jmespath - state: latest + pip: + executable: pip3.12 + name: jmespath diff --git a/playbooks/roles/sit.glusterfs/tasks/setup/centos9.yml b/playbooks/roles/sit.glusterfs/tasks/setup/centos9.yml index b1f4eee7..58e88478 100644 --- a/playbooks/roles/sit.glusterfs/tasks/setup/centos9.yml +++ b/playbooks/roles/sit.glusterfs/tasks/setup/centos9.yml @@ -3,7 +3,5 @@ include_tasks: centos.yml - name: Install Python jmespath module - yum: - name: - - python3-jmespath - state: latest + pip: + name: jmespath From 5150ec935f9e47c387773a8d891cfeaa0b33c385 Mon Sep 17 00:00:00 2001 From: Anoop C S Date: Fri, 16 Feb 2024 12:42:13 +0530 Subject: [PATCH 2/2] tasks: Workaround first_found regression with absolute path Recent update to ansible v2.16.3 broke[1] the promised action of first_found plugin to find files with relative paths when tasks are included from a different subdirectory other than where its main.yml is located. Thus we temporarily switch to use absolute paths wherever required until fix is available with an updated package. [1] https://github.com/ansible/ansible/issues/82695 Signed-off-by: Anoop C S --- playbooks/ansible/roles/ctdb.setup/tasks/glusterfs/main.yml | 4 +++- playbooks/ansible/roles/samba.setup/tasks/cephfs/main.yml | 4 +++- playbooks/ansible/roles/samba.setup/tasks/glusterfs/main.yml | 4 +++- playbooks/ansible/roles/sit.cephfs/tasks/server/main.yml | 4 +++- playbooks/roles/sit.cephfs/tasks/setup/main.yml | 4 +++- playbooks/roles/sit.glusterfs/tasks/setup/main.yml | 4 +++- 6 files changed, 18 insertions(+), 6 deletions(-) diff --git a/playbooks/ansible/roles/ctdb.setup/tasks/glusterfs/main.yml b/playbooks/ansible/roles/ctdb.setup/tasks/glusterfs/main.yml index 84dee73e..a84b7bfa 100644 --- a/playbooks/ansible/roles/ctdb.setup/tasks/glusterfs/main.yml +++ b/playbooks/ansible/roles/ctdb.setup/tasks/glusterfs/main.yml @@ -10,8 +10,10 @@ - name: Process OS specific tasks include_tasks: "{{ include_file }}" + vars: + prefix: "{{ role_path }}/tasks/glusterfs/" with_first_found: - - files: "{{ config.os[config.nodes[inventory_hostname].os].includes }}" + - files: "{{ [prefix] | product(config.os[config.nodes[inventory_hostname].os].includes) | map('join') | list }}" loop_control: loop_var: include_file diff --git a/playbooks/ansible/roles/samba.setup/tasks/cephfs/main.yml b/playbooks/ansible/roles/samba.setup/tasks/cephfs/main.yml index 34c8c953..c635bfd8 100644 --- a/playbooks/ansible/roles/samba.setup/tasks/cephfs/main.yml +++ b/playbooks/ansible/roles/samba.setup/tasks/cephfs/main.yml @@ -4,8 +4,10 @@ block: - name: Process OS specific tasks include_tasks: "{{ include_file }}" + vars: + prefix: "{{ role_path }}/tasks/cephfs/" with_first_found: - - files: "{{ config.os[config.nodes[inventory_hostname].os].includes }}" + - files: "{{ [prefix] | product(config.os[config.nodes[inventory_hostname].os].includes) | map('join') | list }}" loop_control: loop_var: include_file diff --git a/playbooks/ansible/roles/samba.setup/tasks/glusterfs/main.yml b/playbooks/ansible/roles/samba.setup/tasks/glusterfs/main.yml index 2c07caf8..b3ac3f5b 100644 --- a/playbooks/ansible/roles/samba.setup/tasks/glusterfs/main.yml +++ b/playbooks/ansible/roles/samba.setup/tasks/glusterfs/main.yml @@ -1,8 +1,10 @@ --- - name: Process OS specific tasks include_tasks: "{{ include_file }}" + vars: + prefix: "{{ role_path }}/tasks/glusterfs/" with_first_found: - - files: "{{ config.os[config.nodes[inventory_hostname].os].includes }}" + - files: "{{ [prefix] | product(config.os[config.nodes[inventory_hostname].os].includes) | map('join') | list }}" loop_control: loop_var: include_file diff --git a/playbooks/ansible/roles/sit.cephfs/tasks/server/main.yml b/playbooks/ansible/roles/sit.cephfs/tasks/server/main.yml index affe545b..c3d87de8 100644 --- a/playbooks/ansible/roles/sit.cephfs/tasks/server/main.yml +++ b/playbooks/ansible/roles/sit.cephfs/tasks/server/main.yml @@ -1,8 +1,10 @@ --- - name: Process OS specific tasks include_tasks: "{{ include_file }}" + vars: + prefix: "{{ role_path }}/tasks/server/" with_first_found: - - files: "{{ config.os[config.nodes[inventory_hostname].os].includes }}" + - files: "{{ [prefix] | product(config.os[config.nodes[inventory_hostname].os].includes) | map('join') | list }}" loop_control: loop_var: include_file diff --git a/playbooks/roles/sit.cephfs/tasks/setup/main.yml b/playbooks/roles/sit.cephfs/tasks/setup/main.yml index b897f881..f0fcba47 100644 --- a/playbooks/roles/sit.cephfs/tasks/setup/main.yml +++ b/playbooks/roles/sit.cephfs/tasks/setup/main.yml @@ -9,7 +9,9 @@ - name: Process OS specific tasks include_tasks: "{{ include_file }}" + vars: + prefix: "{{ role_path }}/tasks/setup/" with_first_found: - - files: "{{ config.os[config.nodes[inventory_hostname].os].includes }}" + - files: "{{ [prefix] | product(config.os[config.nodes[inventory_hostname].os].includes) | map('join') | list }}" loop_control: loop_var: include_file diff --git a/playbooks/roles/sit.glusterfs/tasks/setup/main.yml b/playbooks/roles/sit.glusterfs/tasks/setup/main.yml index c3220641..b941d932 100644 --- a/playbooks/roles/sit.glusterfs/tasks/setup/main.yml +++ b/playbooks/roles/sit.glusterfs/tasks/setup/main.yml @@ -6,7 +6,9 @@ - name: Process OS specific tasks include_tasks: "{{ include_file }}" + vars: + prefix: "{{ role_path }}/tasks/setup/" with_first_found: - - files: "{{ config.os[config.nodes[inventory_hostname].os].includes }}" + - files: "{{ [prefix] | product(config.os[config.nodes[inventory_hostname].os].includes) | map('join') | list }}" loop_control: loop_var: include_file