Skip to content

Commit 8a74cff

Browse files
committed
test: default wrapper should use local connection if local
If the ansible connection is local, make the tests_default_wrapper.yml test use local connection also. Signed-off-by: Rich Megginson <rmeggins@redhat.com>
1 parent 78b35a0 commit 8a74cff

File tree

3 files changed

+17
-5
lines changed

3 files changed

+17
-5
lines changed

tests/inventory.yaml.j2

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
11
all:
22
hosts:
33
{{ inventory_hostname }}:
4-
{% for key in ["ansible_all_ipv4_addresses", "ansible_all_ipv6_addresses",
4+
{% if __ansible_connection == "local" %}
5+
ansible_connection: local
6+
ansible_host: localhost
7+
{% else %}
8+
{% for key in ["ansible_all_ipv4_addresses", "ansible_all_ipv6_addresses",
59
"ansible_default_ipv4", "ansible_default_ipv6", "ansible_host",
610
"ansible_port", "ansible_ssh_common_args",
711
"ansible_ssh_private_key_file","ansible_user"] %}
8-
{% if key in hostvars[inventory_hostname] %}
12+
{% if key in hostvars[inventory_hostname] %}
913
{{ key }}: {{ hostvars[inventory_hostname][key] }}
10-
{% endif %}
11-
{% endfor %}
14+
{% endif %}
15+
{% endfor %}
16+
{% endif %}

tests/tests_default_wrapper.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44
tags:
55
- 'tests::slow'
66
tasks:
7+
- name: Save connection method
8+
set_fact:
9+
__ansible_connection: "{{ ansible_connection }}"
10+
711
- name: Create temporary file
812
tempfile:
913
state: file

tests/tests_ssh_wrapper.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44
tags:
55
- 'tests::slow'
66
tasks:
7+
- name: Save connection method
8+
set_fact:
9+
__ansible_connection: "{{ ansible_connection }}"
10+
711
- name: Create temporary file
812
tempfile:
913
state: file
@@ -18,7 +22,6 @@
1822
mode: "0644"
1923
delegate_to: localhost
2024

21-
2225
- name: Run tests_ssh.yml normally
2326
tags:
2427
- 'tests::slow'

0 commit comments

Comments
 (0)