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

testinfra 9.0.0 use the same ssh connection as molecule/ansible… which can lead to wrong environment variables #4066

Open
7 tasks done
tchernomax opened this issue Oct 12, 2023 · 0 comments
Labels

Comments

@tchernomax
Copy link

Prerequisites

  • This was not already reported in the past (duplicate check)
  • It does reproduce it with code from main branch (latest unreleased version)
  • I include a minimal example for reproducing the bug
  • The bug is not trivial, as for those a direct pull-request is preferred
  • Running pip check does not report any conflicts
  • I was able to reproduce the issue on a different machine
  • The issue is not specific to any driver other than 'default' one

Environment

molecule 5.1.0 using python 3.9
    ansible:2.14.9
    delegated:5.1.0 from molecule
    ec2:0.4 from molecule_ec2

What happened

cat molecule/default/molecule.yml
…
verifier:
  name: testinfra
  options:
    verbose: true
    sudo: true
cat molecule/default/tests/test_default.py
…
def test_locales(host):
    locale_ = host.check_output("locale")
    assert "LANG=fr_FR.UTF-8" in locale_
    assert "LC_MESSAGES=en_US.UTF-8" in locale_

molecule verify report failure at first… then 60s or so later, the verify is ok.

This is because testinfra use the same ssh connection from ansible, which was created before ansible/molecule change the locales on the host.
60s later, the ssh persistent connection expire and testinfra use a new ssh connection with new environment (with the good locales).

What I did to bypass the problem:

cat molecule/default/molecule.yml
…
verifier:
  name: testinfra
  options:
    verbose: true
    sudo: true
  env:
    ANSIBLE_SSH_EXTRA_ARGS: '-o ControlPath=/tmp/testinfra_cp_%h-%p-%r'

Reproducing example

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Community
Development

No branches or pull requests

2 participants