mirror of
https://github.com/ansible-collections/hetzner.hcloud.git
synced 2026-02-04 08:01:49 +00:00
test: update ssh_key force tests
This commit is contained in:
parent
e7f37fdece
commit
1c8f3cfe9d
2 changed files with 30 additions and 30 deletions
|
|
@ -18,14 +18,14 @@
|
|||
force: true
|
||||
register: test_ssh_keypair
|
||||
|
||||
- name: Create temporary file for test_ssh_keypair_2
|
||||
- name: Create temporary file for test_ssh_keypair2
|
||||
ansible.builtin.tempfile:
|
||||
path: ~/tmp
|
||||
suffix: "{{ hcloud_ssh_key_name }}"
|
||||
register: _tmp_ssh_key_file_2
|
||||
register: _tmp_ssh_key_file2
|
||||
|
||||
- name: Create test_ssh_keypair_2
|
||||
- name: Create test_ssh_keypair2
|
||||
community.crypto.openssh_keypair:
|
||||
path: "{{ _tmp_ssh_key_file_2.path }}"
|
||||
path: "{{ _tmp_ssh_key_file2.path }}"
|
||||
force: true
|
||||
register: test_ssh_keypair_2
|
||||
register: test_ssh_keypair2
|
||||
|
|
|
|||
|
|
@ -49,17 +49,6 @@
|
|||
that:
|
||||
- result is not changed
|
||||
|
||||
- name: test create ssh key idempotence with force
|
||||
hetzner.hcloud.ssh_key:
|
||||
name: "{{ hcloud_ssh_key_name }}"
|
||||
public_key: "{{ test_ssh_keypair.public_key }}"
|
||||
force: true
|
||||
register: result
|
||||
- name: verify create ssh key idempotence with force
|
||||
assert:
|
||||
that:
|
||||
- result is not changed
|
||||
|
||||
- name: test update ssh key with check mode
|
||||
hetzner.hcloud.ssh_key:
|
||||
id: "{{ ssh_key.hcloud_ssh_key.id }}"
|
||||
|
|
@ -147,34 +136,45 @@
|
|||
- result is failed
|
||||
- result.failure.code == "uniqueness_error"
|
||||
|
||||
- name: test force update ssh key with new public key with check mode
|
||||
- name: test update public key warning
|
||||
hetzner.hcloud.ssh_key:
|
||||
name: "{{ hcloud_ssh_key_name }}-other-name"
|
||||
public_key: "{{ test_ssh_keypair_2.public_key }}"
|
||||
name: "{{ hcloud_ssh_key_name }}"
|
||||
public_key: "{{ test_ssh_keypair2.public_key }}"
|
||||
register: result
|
||||
- name: verify update public key warning
|
||||
assert:
|
||||
that:
|
||||
- result is not changed
|
||||
- result.hcloud_ssh_key.name == hcloud_ssh_key_name
|
||||
- result.hcloud_ssh_key.public_key == test_ssh_keypair.public_key
|
||||
|
||||
- name: test update public key with force
|
||||
hetzner.hcloud.ssh_key:
|
||||
name: "{{ hcloud_ssh_key_name }}"
|
||||
public_key: "{{ test_ssh_keypair2.public_key }}"
|
||||
force: true
|
||||
register: result
|
||||
check_mode: true
|
||||
- name: verify force update ssh key with new public key with check mode
|
||||
- name: verify update public key with force
|
||||
assert:
|
||||
that:
|
||||
- result is changed
|
||||
- result.hcloud_ssh_key.name == hcloud_ssh_key_name
|
||||
- result.hcloud_ssh_key.public_key == test_ssh_keypair2.public_key
|
||||
|
||||
- name: test force update ssh key with new public key
|
||||
- name: test update public key with force idempotence
|
||||
hetzner.hcloud.ssh_key:
|
||||
name: "{{ hcloud_ssh_key_name }}-other-name"
|
||||
public_key: "{{ test_ssh_keypair_2.public_key }}"
|
||||
name: "{{ hcloud_ssh_key_name }}"
|
||||
public_key: "{{ test_ssh_keypair2.public_key }}"
|
||||
force: true
|
||||
register: ssh_key
|
||||
- name: verify force update ssh key with new public key
|
||||
register: result
|
||||
- name: verify update public key with force idempotence
|
||||
assert:
|
||||
that:
|
||||
- ssh_key is changed
|
||||
- ssh_key.hcloud_ssh_key.name == "{{ hcloud_ssh_key_name }}-other-name"
|
||||
- ssh_key.hcloud_ssh_key.public_key == test_ssh_keypair_2.public_key
|
||||
- result is not changed
|
||||
|
||||
- name: test delete ssh key
|
||||
hetzner.hcloud.ssh_key:
|
||||
id: "{{ ssh_key.hcloud_ssh_key.id }}"
|
||||
name: "{{ hcloud_ssh_key_name }}"
|
||||
state: absent
|
||||
register: result
|
||||
- name: verify absent ssh_key
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue