mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-10-23 12:33:59 -07:00
Add better error messages and checking to known_hosts (#38307)
This commit is contained in:
parent
02bc4c570f
commit
13aff08748
2 changed files with 39 additions and 2 deletions
|
@ -17,7 +17,9 @@
|
|||
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
- name: copy an existing file in place
|
||||
copy: src=existing_known_hosts dest="{{output_dir|expanduser}}/known_hosts"
|
||||
copy:
|
||||
src: existing_known_hosts
|
||||
dest: "{{ output_dir | expanduser }}/known_hosts"
|
||||
|
||||
# test addition
|
||||
|
||||
|
@ -167,3 +169,33 @@
|
|||
- 'not result.changed'
|
||||
- 'result.diff.before == result.diff.after'
|
||||
- 'known_hosts_v3.stdout == known_hosts_v4.stdout'
|
||||
|
||||
# test errors
|
||||
|
||||
- name: Try using a comma separated list of hosts
|
||||
known_hosts:
|
||||
name: example.org,acme.com
|
||||
key: "{{ example_org_rsa_key }}"
|
||||
path: "{{output_dir|expanduser}}/known_hosts"
|
||||
ignore_errors: yes
|
||||
register: result
|
||||
|
||||
- name: Assert that error message was displayed
|
||||
assert:
|
||||
that:
|
||||
- result is failed
|
||||
- result.msg == 'Comma separated list of names is not supported. Please pass a single name to lookup in the known_hosts file.'
|
||||
|
||||
- name: Try using a name that does not match the key
|
||||
known_hosts:
|
||||
name: example.com
|
||||
key: "{{ example_org_rsa_key }}"
|
||||
path: "{{output_dir|expanduser}}/known_hosts"
|
||||
ignore_errors: yes
|
||||
register: result
|
||||
|
||||
- name: Assert that name checking failed with error message
|
||||
assert:
|
||||
that:
|
||||
- result is failed
|
||||
- result.msg == 'Host parameter does not match hashed host field in supplied key'
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue