how to set python interpreter between different roles

21 views
Skip to first unread message

christia...@itsv.at

unread,
Apr 17, 2019, 5:56:48 AM4/17/19
to Ansible Project

so i have this play to do some rpm package management. this involves removing the python package from the system. so i install some fallback python package which should be used while the sytem python is not available.
my play consists of three roles, the first two should use the system python and the third should use the fallback python. i have set the "ansible_python_interpreter" var in the third role but for unknown reasons this gest smeared over
to the first two roles, so i get "/usr/bin/ksh: /opt/bin/python:  not found." so how to set the "ansible_python_interpreter" var solely for  one role?

the play:

root@lpgaixmgmtlx01:/etc/ansible/aix/roles/do_aixtoolbox_migration>cat ../../deploy_aixtoolbox.yml
- name: deploy aixtoolbox
  hosts
: AIXTESTLPAR01
  gather_facts
: false

  environment
:
         PATH
: "/opt/bin:/opt/freeware/bin:{{ ansible_env.PATH }}"
         SHELL
: "/usr/bin/ksh"
         LIBPATH
: "/opt/lib:/usr/lib:/lib:/opt/freeware/lib"


  roles
:
       
- install_additional_python
       
- update_openssl_lpp
       
- do_aixtoolbox_migration



 ansible_python_interpreter is set in role "do_aixtoolbox_migration" but also effects two two other roles.

root@lpgaixmgmtlx01:/etc/ansible/aix/roles/do_aixtoolbox_migration>cat vars/main.yml

ansible_shell_executable
: "/usr/bin/ksh"
ansible_shell_interpreter
: "/usr/bin/ksh"
ansible_python_interpreter
: "/opt/bin/python"





christia...@itsv.at

unread,
Apr 18, 2019, 3:32:35 AM4/18/19
to Ansible Project

nobody?

Brian Coca

unread,
Apr 18, 2019, 11:51:06 AM4/18/19
to Ansible Project
First, I would use 'defaults/main.yml' instead of vars, it has lower
precedence, also look into:

roles:
- name: X
vars:
ansible_python_intepreter: /path/x

or set in block inside the role that needs it, which would keep it
from bleeding over.

Role vars/ and defaults/ are meant to be inserted in rest of play, if
you do not want that behaviour, you should use other ways to declare
that variable.


--
----------
Brian Coca
Reply all
Reply to author
Forward
0 new messages