-
-
Notifications
You must be signed in to change notification settings - Fork 355
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
Ansible hostpattern for ansible connection #602
Comments
Hi, testinfra will match hosts and/or groups but no patterns yet. I guess this should be feasible in the future. |
Hi @philpep As an example, you can consider the corresponding lookup plugin - inventory_hostnames. It returns the list of hostnames which can be used as a source for testinfra_hosts: https://github.com/ansible/ansible/blob/devel/lib/ansible/plugins/lookup/inventory_hostnames.py Is there any reason to use external call to ansible-inventory cmd? |
A've played with this:
Inventory sources can be retrieved from config or from cmdline. |
@ITD27M01 thanks for your inputs ! I think we must avoid to use the "API" because we do this in the past and caused us a lot of issues (tl;dr; ansible API isn't stable and practical).
If some of you have some time to spend on it that would be an awesome contribution :) |
I played a bit with patterns:
It looks like it solves all practical issues. The problem I see here is the |
@amarao yes I think theses special characters should be urlencoded, which will not help humans :/ Note we can also use plain options instead of url, e.g. |
Command line options is not always available. Consider molecule scenario: ...
verifier:
name: testinfra
options:
sudo: false
showlocals: true
verbose: true
color: 'yes' Molecule picks up all tests inside The actual call to Testinfra from Molecule looks like this:
So, the |
#753 improves matching to allow patterns, without being dependent on ansible modules |
Hi,
Is there any way to pass the ansible hostpattern to testinfra_hosts? I have dynamic inventory which provides all the hosts from Prod and Dev environments. I'm working with them like:
But both environments have the same groups (db, web, app). Can I pass host pattern like 'db:&Prod' to testinfra_hosts ?
https://docs.ansible.com/ansible/latest/user_guide/intro_patterns.html
The text was updated successfully, but these errors were encountered: