From cd180bb835cdf4b0c817ad56fd7ee87606533b0b Mon Sep 17 00:00:00 2001 From: Nguyen Thai <39090621+tk-nguyen@users.noreply.github.com> Date: Tue, 13 Aug 2024 04:12:46 +0700 Subject: [PATCH] Added default `ansible_python_interpreter`; Compatibility with Ansible 10 (#730) --- add_balancer.yml | 6 ------ add_pgnode.yml | 6 ------ balancers.yml | 6 ------ config_pgcluster.yml | 6 ------ consul.yml | 6 ------ deploy_pgcluster.yml | 6 ------ etcd_cluster.yml | 6 ------ group_vars/all | 7 +++++++ inventory | 2 +- pg_upgrade.yml | 5 ----- pg_upgrade_rollback.yml | 5 ----- remove_cluster.yml | 5 ----- update_pgcluster.yml | 6 ------ 13 files changed, 8 insertions(+), 64 deletions(-) diff --git a/add_balancer.yml b/add_balancer.yml index 75dafcd7a..07c445b94 100644 --- a/add_balancer.yml +++ b/add_balancer.yml @@ -6,12 +6,6 @@ any_errors_fatal: true gather_facts: true pre_tasks: - - name: "Set variable: ansible_python_interpreter" - ansible.builtin.set_fact: - ansible_python_interpreter: "/usr/bin/env python3" - when: "'python3' not in (ansible_python_interpreter | default(''))" - tags: always - - name: Include main variables ansible.builtin.include_vars: "vars/main.yml" tags: always diff --git a/add_pgnode.yml b/add_pgnode.yml index 6dd6f68b7..15d301160 100644 --- a/add_pgnode.yml +++ b/add_pgnode.yml @@ -9,12 +9,6 @@ - ansible.builtin.import_tasks: roles/patroni/handlers/main.yml pre_tasks: - - name: "Set variable: ansible_python_interpreter" - ansible.builtin.set_fact: - ansible_python_interpreter: "/usr/bin/env python3" - when: "'python3' not in (ansible_python_interpreter | default(''))" - tags: always - - name: Include main variables ansible.builtin.include_vars: "vars/main.yml" tags: always diff --git a/balancers.yml b/balancers.yml index 9a2cfb218..36525dc15 100644 --- a/balancers.yml +++ b/balancers.yml @@ -9,12 +9,6 @@ vip_manager_disable: false # or 'true' for disable vip-manager service (if installed) pre_tasks: - - name: "Set variable: ansible_python_interpreter" - ansible.builtin.set_fact: - ansible_python_interpreter: "/usr/bin/env python3" - when: "'python3' not in (ansible_python_interpreter | default(''))" - tags: always - - name: Include main variables ansible.builtin.include_vars: "vars/main.yml" tags: always diff --git a/config_pgcluster.yml b/config_pgcluster.yml index 42110ab41..54e382778 100644 --- a/config_pgcluster.yml +++ b/config_pgcluster.yml @@ -3,12 +3,6 @@ hosts: postgres_cluster gather_facts: true pre_tasks: - - name: "Set variable: ansible_python_interpreter" - ansible.builtin.set_fact: - ansible_python_interpreter: "/usr/bin/env python3" - when: "'python3' not in (ansible_python_interpreter | default(''))" - tags: always - - name: Include main variables ansible.builtin.include_vars: "vars/main.yml" diff --git a/consul.yml b/consul.yml index 38e9238e5..5e94229d3 100644 --- a/consul.yml +++ b/consul.yml @@ -8,12 +8,6 @@ environment: "{{ proxy_env | default({}) }}" pre_tasks: - - name: "Set variable: ansible_python_interpreter" - ansible.builtin.set_fact: - ansible_python_interpreter: "/usr/bin/env python3" - when: "'python3' not in (ansible_python_interpreter | default(''))" - tags: always - - name: Include main variables ansible.builtin.include_vars: "vars/main.yml" tags: always diff --git a/deploy_pgcluster.yml b/deploy_pgcluster.yml index c3e795d57..699ec3b6e 100644 --- a/deploy_pgcluster.yml +++ b/deploy_pgcluster.yml @@ -10,12 +10,6 @@ environment: "{{ proxy_env | default({}) }}" pre_tasks: - - name: "Set variable: ansible_python_interpreter" - ansible.builtin.set_fact: - ansible_python_interpreter: "/usr/bin/env python3" - when: "'python3' not in (ansible_python_interpreter | default(''))" - tags: always - - name: Include main variables ansible.builtin.include_vars: "vars/main.yml" tags: always diff --git a/etcd_cluster.yml b/etcd_cluster.yml index 9ad971691..6ef34d5ec 100644 --- a/etcd_cluster.yml +++ b/etcd_cluster.yml @@ -7,12 +7,6 @@ gather_facts: true pre_tasks: - - name: "Set variable: ansible_python_interpreter" - ansible.builtin.set_fact: - ansible_python_interpreter: "/usr/bin/env python3" - when: "'python3' not in (ansible_python_interpreter | default(''))" - tags: always - - name: Include main variables ansible.builtin.include_vars: "vars/main.yml" tags: always diff --git a/group_vars/all b/group_vars/all index a9954175f..55de5ec90 100644 --- a/group_vars/all +++ b/group_vars/all @@ -18,3 +18,10 @@ os_minimum_versions: OracleLinux: 8 Ubuntu: 22.04 Debian: 11 + +# Set correct interpreter for ansible-core +# Since ansible-core 2.17 (ansible 10 on pypi), ansible_python_interpreter wouldn't accept arguments anymore +# See: +# - https://github.com/ansible/ansible/issues/83476 +# - https://github.com/ansible/ansible/issues/83603 +ansible_python_interpreter: "{{ ansible_version['full'] is version('2.17', '>=') | ternary('/usr/bin/python3', '/usr/bin/env python3') }}" \ No newline at end of file diff --git a/inventory b/inventory index 41e6d366e..97eb4ef5f 100644 --- a/inventory +++ b/inventory @@ -56,7 +56,7 @@ ansible_ssh_port='22' ansible_user='root' ansible_ssh_pass='secretpassword' # "sshpass" package is required for use "ansible_ssh_pass" #ansible_ssh_private_key_file= -ansible_python_interpreter='/usr/bin/env python3' +#ansible_python_interpreter='/usr/bin/env python3' [pgbackrest:vars] #ansible_user='postgres' diff --git a/pg_upgrade.yml b/pg_upgrade.yml index 78ff9eea9..584862c3d 100644 --- a/pg_upgrade.yml +++ b/pg_upgrade.yml @@ -8,11 +8,6 @@ become_user: postgres any_errors_fatal: true pre_tasks: - - name: "Set variable: ansible_python_interpreter" - ansible.builtin.set_fact: - ansible_python_interpreter: "/usr/bin/env python3" - when: "'python3' not in (ansible_python_interpreter | default(''))" - - name: Include main variables ansible.builtin.include_vars: "vars/main.yml" diff --git a/pg_upgrade_rollback.yml b/pg_upgrade_rollback.yml index c711f5ae2..f88d48480 100644 --- a/pg_upgrade_rollback.yml +++ b/pg_upgrade_rollback.yml @@ -10,11 +10,6 @@ gather_facts: true any_errors_fatal: true pre_tasks: - - name: "Set variable: ansible_python_interpreter" - ansible.builtin.set_fact: - ansible_python_interpreter: "/usr/bin/env python3" - when: "'python3' not in (ansible_python_interpreter | default(''))" - - name: Include main variables ansible.builtin.include_vars: "vars/main.yml" - name: Include upgrade variables diff --git a/remove_cluster.yml b/remove_cluster.yml index 47d0982b5..cea78b465 100644 --- a/remove_cluster.yml +++ b/remove_cluster.yml @@ -3,11 +3,6 @@ hosts: postgres_cluster become: true pre_tasks: - - name: "Set variable: ansible_python_interpreter" - ansible.builtin.set_fact: - ansible_python_interpreter: "/usr/bin/env python3" - when: "'python3' not in (ansible_python_interpreter | default(''))" - - name: Include main variables ansible.builtin.include_vars: "vars/main.yml" - name: Include OS-specific variables diff --git a/update_pgcluster.yml b/update_pgcluster.yml index 2bf087bf1..7cef73c52 100644 --- a/update_pgcluster.yml +++ b/update_pgcluster.yml @@ -6,12 +6,6 @@ become_method: sudo any_errors_fatal: true pre_tasks: - - name: "Set variable: ansible_python_interpreter" - ansible.builtin.set_fact: - ansible_python_interpreter: "/usr/bin/env python3" - when: "'python3' not in (ansible_python_interpreter | default(''))" - tags: always - - name: Include main variables ansible.builtin.include_vars: "vars/main.yml" tags: always