diff --git a/tests/inventory.yaml.j2 b/tests/inventory.yaml.j2 index c3dffa24..7b463727 100644 --- a/tests/inventory.yaml.j2 +++ b/tests/inventory.yaml.j2 @@ -1,11 +1,16 @@ all: hosts: {{ inventory_hostname }}: -{% for key in ["ansible_all_ipv4_addresses", "ansible_all_ipv6_addresses", +{% if __ansible_connection == "local" %} + ansible_connection: local + ansible_host: localhost +{% else %} +{% 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] %} +{% if key in hostvars[inventory_hostname] %} {{ key }}: {{ hostvars[inventory_hostname][key] }} -{% endif %} -{% endfor %} +{% endif %} +{% endfor %} +{% endif %} diff --git a/tests/tests_default_wrapper.yml b/tests/tests_default_wrapper.yml index 2f828eb1..281e17d9 100644 --- a/tests/tests_default_wrapper.yml +++ b/tests/tests_default_wrapper.yml @@ -4,6 +4,10 @@ tags: - 'tests::slow' tasks: + - name: Save connection method + set_fact: + __ansible_connection: "{{ ansible_connection }}" + - name: Create temporary file tempfile: state: file diff --git a/tests/tests_ssh_wrapper.yml b/tests/tests_ssh_wrapper.yml index 494b1400..b3614f8b 100644 --- a/tests/tests_ssh_wrapper.yml +++ b/tests/tests_ssh_wrapper.yml @@ -4,6 +4,10 @@ tags: - 'tests::slow' tasks: + - name: Save connection method + set_fact: + __ansible_connection: "{{ ansible_connection }}" + - name: Create temporary file tempfile: state: file @@ -18,7 +22,6 @@ mode: "0644" delegate_to: localhost - - name: Run tests_ssh.yml normally tags: - 'tests::slow'