Skip to content

Commit

Permalink
test: fix ssh wrapper test
Browse files Browse the repository at this point in the history
Simplify the inventory to make it easier to debug the nested
ansible-playbook --check call
Only generate an inventory for the current inventory hostname.
Add -b to the nested call for permissions

Signed-off-by: Rich Megginson <[email protected]>
  • Loading branch information
richm committed Feb 4, 2025
1 parent 463d74f commit ef54420
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
12 changes: 11 additions & 1 deletion tests/inventory.yaml.j2
Original file line number Diff line number Diff line change
@@ -1 +1,11 @@
{{ { 'all': { 'hosts': hostvars } } | to_yaml }}
all:
hosts:
{{ inventory_hostname }}:
{% for key in ["ansible_all_ipv4_addresses", "ansible_all_ipv6_addresses",
"ansible_default_ipv4", "ansible_default_ipv6", "ansible_host",
"ansible_port", "ansible_ssh_common_args",
"ansible_ssh_private_key_file","ansible_user"] %}
{% if key in hostvars[inventory_hostname] %}
{{ key }}: {{ hostvars[inventory_hostname][key] }}
{% endif %}
{% endfor %}
2 changes: 1 addition & 1 deletion tests/tests_ssh_wrapper.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
tasks:
- name: Run ansible-playbook with tests_ssh.yml in check mode
command: |
ansible-playbook -vvv -i {{ tempinventory.path }} --check tests_ssh.yml
ansible-playbook -b -vv -i {{ tempinventory.path }} --check tests_ssh.yml
delegate_to: localhost
changed_when: false

Expand Down

0 comments on commit ef54420

Please sign in to comment.