Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix ansible_python_interpreter #89

Merged
merged 2 commits into from
May 2, 2020

Conversation

kdhlab
Copy link

@kdhlab kdhlab commented Apr 29, 2020

In the role's current format it sets ansible_python_interpreter to netbox_python_binary before executing any tasks, however it does not return it to the original value when the role completes. This can cause issues with subsequently executing modules such as yum, that require a python2 interpreter.

This can be resolved by the enduser by setting ansible_python_interpreter to the desired binary(assuming he knows it) after an include_role or import_role task before moving on to the next task/role but obviously this is not desirable. More importantly it does not solve for calling roles the old fashioned way such as this:

  roles: 
    - geerlingguy.postgresql
    - davidwittman.redis
    - lae.netbox
    - nginxinc.nginx

Capturing the initial value of ansible_python_interpreter on load and resetting it to something similar when we are done is the best way I can think of to deal with this, because you can't undefine a variable the best solution is to set it to the auto_legacy value as described here: https://docs.ansible.com/ansible/latest/reference_appendices/interpreter_discovery.html

One thing I didn't account for was if the role exits with an error the variable will not be reset, but I don't know why you would want to run subsequent tasks/roles after a failed install, so does it matter?

@lae lae added the bug label Apr 29, 2020
tasks/main.yml Outdated Show resolved Hide resolved
@lae
Copy link
Owner

lae commented Apr 29, 2020

One thing I didn't account for...

Yeah, shouldn't need to worry about that..

@lae lae merged commit 3191deb into lae:feature/netbox-2.8 May 2, 2020
@lae lae added this to the 1.0 milestone May 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants