Skip to content

Commit

Permalink
Added default ansible_python_interpreter; Compatibility with Ansibl…
Browse files Browse the repository at this point in the history
…e 10 (#730)
  • Loading branch information
tk-nguyen authored Aug 12, 2024
1 parent 63ef2ec commit cd180bb
Show file tree
Hide file tree
Showing 13 changed files with 8 additions and 64 deletions.
6 changes: 0 additions & 6 deletions add_balancer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 0 additions & 6 deletions add_pgnode.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 0 additions & 6 deletions balancers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 0 additions & 6 deletions config_pgcluster.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
6 changes: 0 additions & 6 deletions consul.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 0 additions & 6 deletions deploy_pgcluster.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 0 additions & 6 deletions etcd_cluster.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 7 additions & 0 deletions group_vars/all
Original file line number Diff line number Diff line change
Expand Up @@ -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') }}"
2 changes: 1 addition & 1 deletion inventory
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
5 changes: 0 additions & 5 deletions pg_upgrade.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
5 changes: 0 additions & 5 deletions pg_upgrade_rollback.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 0 additions & 5 deletions remove_cluster.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 0 additions & 6 deletions update_pgcluster.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit cd180bb

Please sign in to comment.