Skip to content

Commit 830f917

Browse files
committed
connection/aws_ssm - fix windows tests
1 parent 705a8fa commit 830f917

File tree

6 files changed

+105
-12
lines changed

6 files changed

+105
-12
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ tests/integration/targets/connection_aws_ssm_*/instance_vars_to_delete.yml
88
tests/integration/targets/connection_aws_ssm_*/s3_vars_to_delete.yml
99
tests/integration/targets/connection_aws_ssm_*/ssm_inventory
1010
tests/integration/targets/connection_aws_ssm_*/ssm_vars_to_delete.yml
11+
tests/integration/targets/connection_aws_ssm_*/aws-env-vars.sh
1112

1213
### dotenv ###
1314
.env

tests/integration/targets/connection_aws_ssm_windows/aliases

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,3 @@ time=12m
33
cloud/aws
44
connection_aws_ssm
55

6-
unstable

tests/integration/targets/connection_aws_ssm_windows/runme.sh

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,5 @@ set +x
2323
. ./aws-env-vars.sh
2424
set -x
2525

26-
cd ../connection
27-
2826
# Execute Integration tests
29-
INVENTORY="${PLAYBOOK_DIR}/ssm_inventory" ./test.sh \
30-
-e target_hosts=aws_ssm \
31-
"$@"
27+
ansible-playbook ./test.yml -i "${PLAYBOOK_DIR}/ssm_inventory" "$@"
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
- name: Run connection/aws_ssm tests on Windows managed node.
2+
hosts: aws_ssm_windows
3+
gather_facts: false
4+
5+
vars:
6+
local_dir: '{{ local_tmp }}-{{ inventory_hostname }}-汉语'
7+
local_file: '{{ local_dir }}/汉语.txt'
8+
remote_dir: '{{ remote_tmp }}-汉语'
9+
remote_file: '{{ remote_dir }}/汉语.txt'
10+
remote_empty_file: '{{ remote_dir }}/empty.txt'
11+
12+
tasks:
13+
- name: Wait for connection
14+
ansible.builtin.wait_for_connection:
15+
timeout: 1000
16+
sleep: 10
17+
18+
- name: Gather facts
19+
ansible.builtin.setup:
20+
21+
### raw with unicode arg and output
22+
23+
- name: Raw with unicode arg and output
24+
ansible.builtin.raw: echo 汉语
25+
register: command
26+
27+
- name: Check output of raw with unicode arg and output
28+
ansible.builtin.assert:
29+
that:
30+
- "'汉语' in command.stdout"
31+
- command is changed # as of 2.2, raw should default to changed: true for consistency w/ shell/command/script modules
32+
33+
### copy local file with unicode filename and content
34+
35+
- name: Create local file with unicode filename and content
36+
ansible.builtin.lineinfile:
37+
dest: "{{ local_file }}"
38+
create: true
39+
line: 汉语
40+
mode: "0755"
41+
delegate_to: localhost
42+
43+
- name: Remove remote file with unicode filename and content
44+
ansible.windows.win_file:
45+
path: "{{ remote_file }}"
46+
state: absent
47+
48+
- name: Create remote directory with unicode name
49+
ansible.windows.win_file:
50+
path: "{{ remote_dir }}"
51+
state: directory
52+
53+
- name: Copy local file with unicode filename and content
54+
ansible.windows.win_copy:
55+
src: "{{ local_file }}"
56+
dest: "{{ remote_file }}"
57+
58+
### fetch remote file with unicode filename and content
59+
60+
- name: Remove local file with unicode filename and content
61+
ansible.builtin.file:
62+
path: "{{ local_file }}"
63+
state: absent
64+
delegate_to: localhost
65+
66+
- name: Fetch remote file with unicode filename and content
67+
ansible.builtin.fetch:
68+
src: "{{ remote_file }}"
69+
dest: "{{ local_file }}"
70+
fail_on_missing: true
71+
validate_checksum: true
72+
flat: true
73+
74+
### remove local and remote temp files
75+
76+
- name: Remove local temp file
77+
ansible.builtin.file:
78+
path: "{{ local_file }}"
79+
state: absent
80+
delegate_to: localhost
81+
82+
- name: Remove remote temp file
83+
ansible.windows.win_file:
84+
path: "{{ remote_file }}"
85+
state: absent
86+
87+
### copy an empty file
88+
- name: Copy an empty file
89+
ansible.windows.win_copy:
90+
content: ''
91+
dest: "{{ remote_empty_file }}"
92+
93+
- name: Stat empty file
94+
ansible.windows.win_stat:
95+
path: "{{ remote_empty_file }}"
96+
register: stat_empty_file_cmd
97+
98+
- name: Check that empty file exists
99+
ansible.builtin.assert:
100+
that:
101+
- stat_empty_file_cmd.stat.isreg # it is a regular file
102+
- stat_empty_file_cmd.stat.size == 0

tests/integration/targets/setup_connection_aws_ssm/tasks/main.yml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,6 @@
1010
session_token: '{{ security_token | default(omit) }}'
1111
region: '{{ aws_region }}'
1212
block:
13-
14-
- name: get ARN of calling user
15-
amazon.aws.aws_caller_info:
16-
register: aws_caller_info
17-
1813
- name: setup connection argments fact
1914
ansible.builtin.include_tasks: 'connection_args.yml'
2015

tests/integration/targets/setup_connection_aws_ssm/templates/boto_config.j2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ aws_access_key_id = {{ session_access_key | default(aws_access_key) }}
44
aws_secret_access_key = {{ session_secret_key | default(aws_secret_key) }}
55
{% if security_token is defined or session_security_token is defined %}
66
aws_security_token = {{ session_security_token | default(security_token) }}
7-
{% endif %}
7+
{% endif %}

0 commit comments

Comments
 (0)