Answer the question
In order to leave comments, you need to log in
How to correctly pass the value of a variable to ansible_python_interpreter?
I have a playbook.yml that deploys containers to a test environment.
For Tasks that do
Docker Pull and Docker Container restart
I want to override ansible_python_interpreter with ansible_python3_interpreter
which comes after Task
Create Python ENV and install requerements - docker
---
- name: Deploy Web on Host
hosts: '{{ target_host }}'
vars:
python_virtualenv: /opt/python_envs/py36
ansible_python3_interpreter: "/opt/python_envs/py36/bin/python"
ansible_python2_interpreter: "/usr/bin/python2.7"
CI_REGISTRY: "{{ lookup('env','CI_REGISTRY') }}"
- name: Create Python ENV and install requirements - docker
pip:
name: [ "docker", "docker-compose"]
# extra_args: "--user"
virtualenv: '{{ python_virtualenv }}'
virtualenv_command: /usr/bin/python3.6 -m venv
# virtualenv_site_packages: yes
- name: Pull Docker image api
docker_image:
name: "{{CI_REGISTRY}}/mvp1/tools/web:{{ api_version }}"
source: pull
vars:
ansible_python_interpreter: "{{ ansible_python3_interpreter }}"
fatal: [project-test]: UNREACHABLE! => {
"changed": false,
"unreachable": true
}
MSG:
EOF on stream; last 100 lines received:
bash: {{: command not found
Answer the question
In order to leave comments, you need to log in
so you have a bash error, why do you run yaml in bash?
you also have a lot of variables in single quotes, some in double quotes, some without,
do everything uniformly at first
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question