summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatt Clay <matt@mystile.com>2019-08-20 16:17:32 +0200
committerGitHub <noreply@github.com>2019-08-20 16:17:32 +0200
commit92380d7050676525e4cabd6de37865cee28e61e0 (patch)
treee3d2081c398403bd2526163f0cffc6668ff69d2a
parentgluster_heal_facts: rename to gluster_heal_info (#60919) (diff)
downloadansible-92380d7050676525e4cabd6de37865cee28e61e0.tar.xz
ansible-92380d7050676525e4cabd6de37865cee28e61e0.zip
Update ansible-test --windows inventory creation. (#60911)
Host specific settings are created as part of the generated inventory instead of using a host_vars directory. Also update connection tests to work properly with the generated inventory changes.
-rw-r--r--test/integration/host_vars/windows-20084
-rw-r--r--test/integration/host_vars/windows-20164
-rw-r--r--test/integration/targets/connection_psrp/inventory.ini3
-rwxr-xr-xtest/integration/targets/connection_psrp/runme.sh13
-rw-r--r--test/integration/targets/connection_psrp/test_connection.inventory.j29
-rw-r--r--test/integration/targets/connection_psrp/tests.yml2
-rwxr-xr-xtest/integration/targets/connection_windows_ssh/runme.sh4
-rw-r--r--test/integration/targets/connection_windows_ssh/test_connection.inventory.j26
-rw-r--r--test/integration/targets/connection_windows_ssh/tests.yml2
-rw-r--r--test/integration/targets/connection_windows_ssh/tests_fetch.yml2
-rwxr-xr-xtest/integration/targets/connection_windows_ssh/windows.sh2
-rwxr-xr-xtest/integration/targets/connection_winrm/runme.sh10
-rw-r--r--test/integration/targets/connection_winrm/test_connection.inventory.j210
-rw-r--r--test/lib/ansible_test/_internal/executor.py30
14 files changed, 67 insertions, 34 deletions
diff --git a/test/integration/host_vars/windows-2008 b/test/integration/host_vars/windows-2008
deleted file mode 100644
index 10559a8a67..0000000000
--- a/test/integration/host_vars/windows-2008
+++ /dev/null
@@ -1,4 +0,0 @@
-# force 2008 to use PSRP for the connection plugin
-ansible_connection: psrp
-ansible_psrp_auth: basic
-ansible_psrp_cert_validation: ignore
diff --git a/test/integration/host_vars/windows-2016 b/test/integration/host_vars/windows-2016
deleted file mode 100644
index b7ee4c30db..0000000000
--- a/test/integration/host_vars/windows-2016
+++ /dev/null
@@ -1,4 +0,0 @@
-# force 2016 to use NTLM + HTTP message encryption
-ansible_winrm_transport: ntlm
-ansible_winrm_scheme: http
-ansible_port: 5985
diff --git a/test/integration/targets/connection_psrp/inventory.ini b/test/integration/targets/connection_psrp/inventory.ini
deleted file mode 100644
index 398a7bd322..0000000000
--- a/test/integration/targets/connection_psrp/inventory.ini
+++ /dev/null
@@ -1,3 +0,0 @@
-[windows:vars]
-ansible_connection=psrp
-ansible_psrp_cert_validation=ignore
diff --git a/test/integration/targets/connection_psrp/runme.sh b/test/integration/targets/connection_psrp/runme.sh
index b5d87061f6..35984bba2f 100755
--- a/test/integration/targets/connection_psrp/runme.sh
+++ b/test/integration/targets/connection_psrp/runme.sh
@@ -2,12 +2,17 @@
set -eux
+# make sure hosts are using psrp connections
+ansible -i ../../inventory.winrm localhost \
+ -m template \
+ -a "src=test_connection.inventory.j2 dest=${OUTPUT_DIR}/test_connection.inventory" \
+ "$@"
+
python.py -m pip install pypsrp
cd ../connection
-INVENTORY=../../inventory.winrm ./test.sh \
- -i ../connection_psrp/inventory.ini \
- -e target_hosts=winrm \
+INVENTORY="${OUTPUT_DIR}/test_connection.inventory" ./test.sh \
+ -e target_hosts=windows \
-e action_prefix=win_ \
-e local_tmp=/tmp/ansible-local \
-e remote_tmp=c:/windows/temp/ansible-remote \
@@ -15,5 +20,5 @@ INVENTORY=../../inventory.winrm ./test.sh \
cd ../connection_psrp
-ansible-playbook -i ../../inventory.winrm -i inventory.ini tests.yml \
+ansible-playbook -i "${OUTPUT_DIR}/test_connection.inventory" tests.yml \
"$@"
diff --git a/test/integration/targets/connection_psrp/test_connection.inventory.j2 b/test/integration/targets/connection_psrp/test_connection.inventory.j2
new file mode 100644
index 0000000000..d2d3a4929c
--- /dev/null
+++ b/test/integration/targets/connection_psrp/test_connection.inventory.j2
@@ -0,0 +1,9 @@
+[windows]
+{% for host in vars.groups.windows %}
+{{ host }} ansible_host={{ hostvars[host]['ansible_host'] }} ansible_port={{ hostvars[host]['ansible_port'] }} ansible_user={{ hostvars[host]['ansible_user'] }} ansible_password={{ hostvars[host]['ansible_password'] }}
+{% endfor %}
+
+[windows:vars]
+ansible_connection=psrp
+ansible_psrp_auth=negotiate
+ansible_psrp_cert_validation=ignore
diff --git a/test/integration/targets/connection_psrp/tests.yml b/test/integration/targets/connection_psrp/tests.yml
index 4425d56e02..1247ee1927 100644
--- a/test/integration/targets/connection_psrp/tests.yml
+++ b/test/integration/targets/connection_psrp/tests.yml
@@ -1,7 +1,7 @@
---
# these are extra tests for psrp that aren't covered under test/integration/targets/connection/*
- name: test out psrp specific tests
- hosts: winrm
+ hosts: windows
serial: 1
gather_facts: no
diff --git a/test/integration/targets/connection_windows_ssh/runme.sh b/test/integration/targets/connection_windows_ssh/runme.sh
index 9b7e2d6947..488bb7c5c6 100755
--- a/test/integration/targets/connection_windows_ssh/runme.sh
+++ b/test/integration/targets/connection_windows_ssh/runme.sh
@@ -18,7 +18,7 @@ ansible -i ../../inventory.winrm windows \
"$@"
# Need to flush the connection to ensure we get a new shell for the next tests
-ansible -i "${OUTPUT_DIR}/test_connection.inventory" windows-ssh \
+ansible -i "${OUTPUT_DIR}/test_connection.inventory" windows \
-m meta -a "reset_connection" \
"$@"
@@ -44,7 +44,7 @@ ansible -i ../../inventory.winrm windows \
-a "path=HKLM:\\\\SOFTWARE\\\\OpenSSH name=DefaultShell data=C:\\\\Windows\\\\System32\\\\WindowsPowerShell\\\\v1.0\\\\powershell.exe" \
"$@"
-ansible -i "${OUTPUT_DIR}/test_connection.inventory" windows-ssh \
+ansible -i "${OUTPUT_DIR}/test_connection.inventory" windows \
-m meta -a "reset_connection" \
"$@"
diff --git a/test/integration/targets/connection_windows_ssh/test_connection.inventory.j2 b/test/integration/targets/connection_windows_ssh/test_connection.inventory.j2
index 87c0aea731..5893eafe95 100644
--- a/test/integration/targets/connection_windows_ssh/test_connection.inventory.j2
+++ b/test/integration/targets/connection_windows_ssh/test_connection.inventory.j2
@@ -1,9 +1,9 @@
-[windows-ssh]
-{% for host in vars.groups.winrm %}
+[windows]
+{% for host in vars.groups.windows %}
{{ host }} ansible_host={{ hostvars[host]['ansible_host'] }} ansible_user={{ hostvars[host]['ansible_user'] }}{{ ' ansible_ssh_private_key_file=' ~ hostvars[host]['ansible_ssh_private_key_file'] if (hostvars[host]['ansible_ssh_private_key_file']|default()) else '' }}
{% endfor %}
-[windows-ssh:vars]
+[windows:vars]
ansible_shell_type={{ test_shell_type }}
ansible_connection=ssh
ansible_port=22
diff --git a/test/integration/targets/connection_windows_ssh/tests.yml b/test/integration/targets/connection_windows_ssh/tests.yml
index c1d2908121..e9b538b40a 100644
--- a/test/integration/targets/connection_windows_ssh/tests.yml
+++ b/test/integration/targets/connection_windows_ssh/tests.yml
@@ -1,6 +1,6 @@
---
- name: test out Windows SSH specific tests
- hosts: windows-ssh
+ hosts: windows
serial: 1
gather_facts: no
diff --git a/test/integration/targets/connection_windows_ssh/tests_fetch.yml b/test/integration/targets/connection_windows_ssh/tests_fetch.yml
index 2707c8f900..0b4fe94912 100644
--- a/test/integration/targets/connection_windows_ssh/tests_fetch.yml
+++ b/test/integration/targets/connection_windows_ssh/tests_fetch.yml
@@ -3,7 +3,7 @@
# documented, it isn't actually used hence the separate invocation
---
- name: further fetch tests with metachar characters in filename
- hosts: windows-ssh
+ hosts: windows
force_handlers: yes
serial: 1
gather_facts: no
diff --git a/test/integration/targets/connection_windows_ssh/windows.sh b/test/integration/targets/connection_windows_ssh/windows.sh
index 83895d07ad..d2db50f8f1 100755
--- a/test/integration/targets/connection_windows_ssh/windows.sh
+++ b/test/integration/targets/connection_windows_ssh/windows.sh
@@ -11,7 +11,7 @@ cd ../connection
# https://unix.stackexchange.com/questions/499958/why-does-scps-strict-filename-checking-reject-quoted-last-component-but-not-oth
# https://github.com/openssh/openssh-portable/commit/391ffc4b9d31fa1f4ad566499fef9176ff8a07dc
INVENTORY="${OUTPUT_DIR}/test_connection.inventory" ./test.sh \
- -e target_hosts=windows-ssh \
+ -e target_hosts=windows \
-e action_prefix=win_ \
-e local_tmp=/tmp/ansible-local \
-e remote_tmp=c:/windows/temp/ansible-remote \
diff --git a/test/integration/targets/connection_winrm/runme.sh b/test/integration/targets/connection_winrm/runme.sh
index 5947903bee..e677241591 100755
--- a/test/integration/targets/connection_winrm/runme.sh
+++ b/test/integration/targets/connection_winrm/runme.sh
@@ -2,10 +2,16 @@
set -eux
+# make sure hosts are using winrm connections
+ansible -i ../../inventory.winrm localhost \
+ -m template \
+ -a "src=test_connection.inventory.j2 dest=${OUTPUT_DIR}/test_connection.inventory" \
+ "$@"
+
cd ../connection
-INVENTORY=../../inventory.winrm ./test.sh \
- -e target_hosts=winrm \
+INVENTORY="${OUTPUT_DIR}/test_connection.inventory" ./test.sh \
+ -e target_hosts=windows \
-e action_prefix=win_ \
-e local_tmp=/tmp/ansible-local \
-e remote_tmp=c:/windows/temp/ansible-remote \
diff --git a/test/integration/targets/connection_winrm/test_connection.inventory.j2 b/test/integration/targets/connection_winrm/test_connection.inventory.j2
new file mode 100644
index 0000000000..7c4f3dc9e6
--- /dev/null
+++ b/test/integration/targets/connection_winrm/test_connection.inventory.j2
@@ -0,0 +1,10 @@
+[windows]
+{% for host in vars.groups.windows %}
+{{ host }} ansible_host={{ hostvars[host]['ansible_host'] }} ansible_port={{ hostvars[host]['ansible_port'] }} ansible_user={{ hostvars[host]['ansible_user'] }} ansible_password={{ hostvars[host]['ansible_password'] }}
+{% endfor %}
+
+[windows:vars]
+ansible_connection=winrm
+# we don't know if we're using an encrypted connection or not, so we'll use message encryption
+ansible_winrm_transport=ntlm
+ansible_winrm_server_cert_validation=ignore
diff --git a/test/lib/ansible_test/_internal/executor.py b/test/lib/ansible_test/_internal/executor.py
index dff37a445f..adaa1b1fe7 100644
--- a/test/lib/ansible_test/_internal/executor.py
+++ b/test/lib/ansible_test/_internal/executor.py
@@ -747,6 +747,28 @@ def windows_inventory(remotes):
if remote.ssh_key:
options["ansible_ssh_private_key_file"] = os.path.abspath(remote.ssh_key.key)
+ if remote.name == 'windows-2008':
+ options.update(
+ # force 2008 to use PSRP for the connection plugin
+ ansible_connection='psrp',
+ ansible_psrp_auth='basic',
+ ansible_psrp_cert_validation='ignore',
+ )
+ elif remote.name == 'windows-2016':
+ options.update(
+ # force 2016 to use NTLM + HTTP message encryption
+ ansible_connection='winrm',
+ ansible_winrm_server_cert_validation='ignore',
+ ansible_winrm_transport='ntlm',
+ ansible_winrm_scheme='http',
+ ansible_port='5985',
+ )
+ else:
+ options.update(
+ ansible_connection='winrm',
+ ansible_winrm_server_cert_validation='ignore',
+ )
+
hosts.append(
'%s %s' % (
remote.name.replace('/', '_'),
@@ -758,14 +780,6 @@ def windows_inventory(remotes):
[windows]
%s
- [windows:vars]
- ansible_connection=winrm
- ansible_winrm_server_cert_validation=ignore
-
- # support winrm connection tests (temporary solution, does not support testing enable/disable of pipelining)
- [winrm:children]
- windows
-
# support winrm binary module tests (temporary solution)
[testhost:children]
windows