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

Ensure cwd is passed to utils.run_command() in all cases #3313

Merged
merged 1 commit into from Nov 25, 2021
Merged

Ensure cwd is passed to utils.run_command() in all cases #3313

merged 1 commit into from Nov 25, 2021

Conversation

akerouanton
Copy link
Contributor

@akerouanton akerouanton commented Nov 24, 2021

When trying to access Ansible vars in testinfra tests, the following
function call would fail to get values coming from host/group vars:

host.ansible('debug', 'msg={{ hostvars[inventory_hostname] }}')

This was due to: 1. testinfra being executed into the directory where
molecule was launched instead of the scenario directory ; 2. group_vars
being located in the scenario directory.

This fix set the cwd passed to subprocess_tee to the cwd set in
BakedCommand and fixes the issue.

I tested this change by directly changing molecule code in my project and
printing the output of the above line. It shows my group vars as expected.

Fixes #151

Fixes #151.

When trying to access Ansible vars in testinfra tests, the following
function call would fail to get values coming from host/group vars:

    ansible_vars = host.ansible('debug', 'msg={{ hostvars[inventory_hostname] }}')

This was due to: 1. testinfra being executed into the directory where
molecule was launched instead of the scenario directory ; 2. group_vars
being located in the scenario directory.

This fix set the cwd passed to subprocess_tee to the cwd set in
BakedCommand and fixes the issue.

Signed-off-by: Albin Kerouanton <albinker@gmail.com>
@ssbarnea ssbarnea changed the title fix: Use cwd from BakedCommand in utils.run_command() Ensure cwd is passed to utils.run_command() in all cases Nov 25, 2021
@ssbarnea ssbarnea added the bug label Nov 25, 2021
@ssbarnea ssbarnea merged commit bd2f602 into ansible:main Nov 25, 2021
@akerouanton akerouanton deleted the use-baked-cwd-run-command branch November 25, 2021 09:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
2 participants