summaryrefslogtreecommitdiffstats
path: root/test/integration/targets/known_hosts
diff options
context:
space:
mode:
authorMatt Martz <matt@sivel.net>2022-01-26 15:31:19 +0100
committerGitHub <noreply@github.com>2022-01-26 15:31:19 +0100
commitcad200406af5df3e5b5034b141578bc44b142f0d (patch)
tree3cb8ee7ac4be7710663e70ce54c2d26c30a47881 /test/integration/targets/known_hosts
parentAdded restart to the argument condition for AIX (#76841) (diff)
downloadansible-cad200406af5df3e5b5034b141578bc44b142f0d.tar.xz
ansible-cad200406af5df3e5b5034b141578bc44b142f0d.zip
group2 - switch to setup_remote_tmp_dir instead of using output_dir (#76853)
* group2 - switch to setup_remote_tmp_dir instead of using output_dir * output_file needs to be in the tmp dir * Use comparison that should work with macos * remove unused dep
Diffstat (limited to 'test/integration/targets/known_hosts')
-rw-r--r--test/integration/targets/known_hosts/meta/main.yml1
-rw-r--r--test/integration/targets/known_hosts/tasks/main.yml70
2 files changed, 36 insertions, 35 deletions
diff --git a/test/integration/targets/known_hosts/meta/main.yml b/test/integration/targets/known_hosts/meta/main.yml
index 07faa21776..cb6005d042 100644
--- a/test/integration/targets/known_hosts/meta/main.yml
+++ b/test/integration/targets/known_hosts/meta/main.yml
@@ -1,2 +1,3 @@
dependencies:
- prepare_tests
+ - setup_remote_tmp_dir
diff --git a/test/integration/targets/known_hosts/tasks/main.yml b/test/integration/targets/known_hosts/tasks/main.yml
index 4ea91c3542..67f0e5a679 100644
--- a/test/integration/targets/known_hosts/tasks/main.yml
+++ b/test/integration/targets/known_hosts/tasks/main.yml
@@ -19,7 +19,7 @@
- name: copy an existing file in place
copy:
src: existing_known_hosts
- dest: "{{ output_dir }}/known_hosts"
+ dest: "{{ remote_tmp_dir }}/known_hosts"
# test addition
@@ -29,14 +29,14 @@
name: example.org
key: "{{ example_org_rsa_key }}"
state: present
- path: "{{output_dir}}/known_hosts"
+ path: "{{remote_tmp_dir}}/known_hosts"
register: diff
- name: assert that the diff looks as expected (the key was added at the end)
assert:
that:
- 'diff is changed'
- - 'diff.diff.before_header == diff.diff.after_header == output_dir|expanduser + "/known_hosts"'
+ - 'diff.diff.before_header == diff.diff.after_header == remote_tmp_dir|expanduser + "/known_hosts"'
- 'diff.diff.after.splitlines()[:-1] == diff.diff.before.splitlines()'
- 'diff.diff.after.splitlines()[-1] == example_org_rsa_key.strip()'
@@ -45,11 +45,11 @@
name: example.org
key: "{{ example_org_rsa_key }}"
state: present
- path: "{{output_dir}}/known_hosts"
+ path: "{{remote_tmp_dir}}/known_hosts"
register: result
- name: get the file content
- command: "cat {{output_dir}}/known_hosts"
+ command: "cat {{remote_tmp_dir}}/known_hosts"
register: known_hosts
- name: assert that the key was added and ordering preserved
@@ -68,7 +68,7 @@
name: example.org
key: "{{ example_org_rsa_key }}"
state: present
- path: "{{output_dir}}/known_hosts"
+ path: "{{remote_tmp_dir}}/known_hosts"
register: check
- name: assert that no changes were expected
@@ -82,11 +82,11 @@
name: example.org
key: "{{ example_org_rsa_key }}"
state: present
- path: "{{output_dir}}/known_hosts"
+ path: "{{remote_tmp_dir}}/known_hosts"
register: result
- name: get the file content
- command: "cat {{output_dir}}/known_hosts"
+ command: "cat {{remote_tmp_dir}}/known_hosts"
register: known_hosts_v2
- name: assert that no changes happened
@@ -104,13 +104,13 @@
name: example.org
key: "{{ example_org_rsa_key }}"
state: absent
- path: "{{output_dir}}/known_hosts"
+ path: "{{remote_tmp_dir}}/known_hosts"
register: diff
- name: assert that the diff looks as expected (the key was removed)
assert:
that:
- - 'diff.diff.before_header == diff.diff.after_header == output_dir|expanduser + "/known_hosts"'
+ - 'diff.diff.before_header == diff.diff.after_header == remote_tmp_dir|expanduser + "/known_hosts"'
- 'diff.diff.before.splitlines()[-1] == example_org_rsa_key.strip()'
- 'diff.diff.after.splitlines() == diff.diff.before.splitlines()[:-1]'
@@ -119,11 +119,11 @@
name: example.org
key: "{{ example_org_rsa_key }}"
state: absent
- path: "{{output_dir}}/known_hosts"
+ path: "{{remote_tmp_dir}}/known_hosts"
register: result
- name: get the file content
- command: "cat {{output_dir}}/known_hosts"
+ command: "cat {{remote_tmp_dir}}/known_hosts"
register: known_hosts_v3
- name: assert that the key was removed and ordering preserved
@@ -142,7 +142,7 @@
name: example.org
key: "{{ example_org_rsa_key }}"
state: absent
- path: "{{output_dir}}/known_hosts"
+ path: "{{remote_tmp_dir}}/known_hosts"
register: check
- name: assert that no changes were expected
@@ -156,11 +156,11 @@
name: example.org
key: "{{ example_org_rsa_key }}"
state: absent
- path: "{{output_dir}}/known_hosts"
+ path: "{{remote_tmp_dir}}/known_hosts"
register: result
- name: get the file content
- command: "cat {{output_dir}}/known_hosts"
+ command: "cat {{remote_tmp_dir}}/known_hosts"
register: known_hosts_v4
- name: assert that no changes happened
@@ -177,12 +177,12 @@
name: example.org
key: "{{ example_org_rsa_key }}"
state: present
- path: "{{output_dir}}/known_hosts"
+ path: "{{remote_tmp_dir}}/known_hosts"
hash_host: yes
register: result
- name: get the file content
- command: "cat {{output_dir}}/known_hosts"
+ command: "cat {{remote_tmp_dir}}/known_hosts"
register: known_hosts_v5
- name: assert that the key was added and ordering preserved
@@ -201,12 +201,12 @@
name: example.org
key: "{{ example_org_rsa_key }}"
state: present
- path: "{{output_dir}}/known_hosts"
+ path: "{{remote_tmp_dir}}/known_hosts"
hash_host: yes
register: result
- name: get the file content
- command: "cat {{output_dir}}/known_hosts"
+ command: "cat {{remote_tmp_dir}}/known_hosts"
register: known_hosts_v6
- name: assert that no changes happened
@@ -223,11 +223,11 @@
name: example.org
key: "{{ example_org_rsa_key }}"
state: absent
- path: "{{output_dir}}/known_hosts"
+ path: "{{remote_tmp_dir}}/known_hosts"
register: result
- name: get the file content
- command: "cat {{output_dir}}/known_hosts"
+ command: "cat {{remote_tmp_dir}}/known_hosts"
register: known_hosts_v7
- name: assert that the key was removed and ordering preserved
@@ -245,11 +245,11 @@
name: example.org
key: "{{ example_org_rsa_key }}"
state: absent
- path: "{{output_dir}}/known_hosts"
+ path: "{{remote_tmp_dir}}/known_hosts"
register: result
- name: get the file content
- command: "cat {{output_dir}}/known_hosts"
+ command: "cat {{remote_tmp_dir}}/known_hosts"
register: known_hosts_v8
- name: assert that no changes happened
@@ -267,10 +267,10 @@
name: example.org
key: "{{ example_org_rsa_key }}"
state: present
- path: "{{output_dir}}/known_hosts"
+ path: "{{remote_tmp_dir}}/known_hosts"
- name: get the file content
- command: "cat {{output_dir}}/known_hosts"
+ command: "cat {{remote_tmp_dir}}/known_hosts"
register: known_hosts_v8
- name: assert the plaintext host is there
@@ -283,11 +283,11 @@
name: example.org
key: "{{ example_org_rsa_key }}"
state: present
- path: "{{output_dir}}/known_hosts"
+ path: "{{remote_tmp_dir}}/known_hosts"
hash_host: true
- name: get the file content
- command: "cat {{output_dir}}/known_hosts"
+ command: "cat {{remote_tmp_dir}}/known_hosts"
register: known_hosts_v9
- name: assert the hashed host is there
@@ -301,10 +301,10 @@
name: example.org
key: "{{ example_org_rsa_key }}"
state: present
- path: "{{output_dir}}/known_hosts"
+ path: "{{remote_tmp_dir}}/known_hosts"
- name: get the file content
- command: "cat {{output_dir}}/known_hosts"
+ command: "cat {{remote_tmp_dir}}/known_hosts"
register: known_hosts_v10
- name: assert the plaintext host is there
@@ -317,7 +317,7 @@
- name: copy an existing file in place
copy:
src: existing_known_hosts
- dest: "{{ output_dir }}/known_hosts"
+ dest: "{{ remote_tmp_dir }}/known_hosts"
# Test key changes
@@ -326,7 +326,7 @@
name: example.org
key: "{{ example_org_rsa_key }}"
state: present
- path: "{{output_dir}}/known_hosts"
+ path: "{{remote_tmp_dir}}/known_hosts"
hash_host: true
- name: change the key of a hashed host
@@ -334,11 +334,11 @@
name: example.org
key: "{{ example_org_rsa_key.strip()[:-7] + 'RANDOM=' }}"
state: present
- path: "{{output_dir}}/known_hosts"
+ path: "{{remote_tmp_dir}}/known_hosts"
hash_host: true
- name: get the file content
- command: "cat {{output_dir}}/known_hosts"
+ command: "cat {{remote_tmp_dir}}/known_hosts"
register: known_hosts_v11
- name: assert the change took place and the key got modified
@@ -352,7 +352,7 @@
known_hosts:
name: example.org,acme.com
key: "{{ example_org_rsa_key }}"
- path: "{{output_dir}}/known_hosts"
+ path: "{{remote_tmp_dir}}/known_hosts"
ignore_errors: yes
register: result
@@ -366,7 +366,7 @@
known_hosts:
name: example.com
key: "{{ example_org_rsa_key }}"
- path: "{{output_dir}}/known_hosts"
+ path: "{{remote_tmp_dir}}/known_hosts"
ignore_errors: yes
register: result