Skip to content

Commit f14191a

Browse files
committed
Use ansible_python_interpreter: /usr/bin/python3 for pip3 tasks
An error is possible when using default ansible_python_interpreter: TASK [patroni : Install setuptools] ******************************************** An exception occurred during task execution. To see the full traceback, use -vvv. The error was: ImportError: No module named pkg_resources fatal: [10.172.0.21]: FAILED! => {"changed": false, "msg": "Failed to import the required Python library (setuptools) on pgnode02's Python /usr/bin/python. Please read module documentation and install in the appropriate location. If the required library is installed, but Ansible is using the wrong Python interpreter, please consult the documentation on ansible_python_interpreter"}
1 parent 2575ed1 commit f14191a

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

roles/patroni/tasks/main.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@
6161
when: patroni_pip_package_repo | length < 1 and patroni_install_version != "latest"
6262
when: installation_method == "repo" and patroni_installation_method == "pip"
6363
environment: "{{ proxy_env | default({}) }}"
64+
vars:
65+
ansible_python_interpreter: /usr/bin/python3
6466
tags: patroni, patroni_install
6567

6668
- block: # when "patroni_pip_requirements_repo" and "patroni_pip_package_repo" is defined
@@ -104,6 +106,8 @@
104106
PATH: "{{ ansible_env.PATH }}:/usr/local/bin:/usr/bin"
105107
when: patroni_pip_package_repo | length > 0
106108
when: installation_method == "repo" and patroni_installation_method == "pip"
109+
vars:
110+
ansible_python_interpreter: /usr/bin/python3
107111
tags: patroni, patroni_install
108112

109113
- block: # installation_method: "file" and patroni_installation_method: "pip"
@@ -143,6 +147,8 @@
143147
PATH: "{{ ansible_env.PATH }}:/usr/local/bin:/usr/bin"
144148
when: patroni_pip_package_file | length > 0
145149
when: installation_method == "file" and patroni_installation_method == "pip"
150+
vars:
151+
ansible_python_interpreter: /usr/bin/python3
146152
tags: patroni, patroni_install
147153

148154
- block: # installation_method: "repo" and patroni_installation_method: "rpm/deb"
@@ -588,6 +594,8 @@
588594
- ruamel.yaml
589595
environment:
590596
PATH: "{{ ansible_env.PATH }}:/usr/local/bin:/usr/bin"
597+
vars:
598+
ansible_python_interpreter: /usr/bin/python3
591599
# Run PITR
592600
- name: Stop patroni service on the Replica servers (if running)
593601
systemd:

0 commit comments

Comments
 (0)