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
|
force: true
|
||||||
register: test_ssh_keypair
|
register: test_ssh_keypair
|
||||||
|
|
||||||
- name: Create temporary file for test_ssh_keypair_2
|
- name: Create temporary file for test_ssh_keypair2
|
||||||
ansible.builtin.tempfile:
|
ansible.builtin.tempfile:
|
||||||
path: ~/tmp
|
path: ~/tmp
|
||||||
suffix: "{{ hcloud_ssh_key_name }}"
|
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:
|
community.crypto.openssh_keypair:
|
||||||
path: "{{ _tmp_ssh_key_file_2.path }}"
|
path: "{{ _tmp_ssh_key_file2.path }}"
|
||||||
force: true
|
force: true
|
||||||
register: test_ssh_keypair_2
|
register: test_ssh_keypair2
|
||||||
|
|
|
||||||
|
|
@ -49,17 +49,6 @@
|
||||||
that:
|
that:
|
||||||
- result is not changed
|
- 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
|
- name: test update ssh key with check mode
|
||||||
hetzner.hcloud.ssh_key:
|
hetzner.hcloud.ssh_key:
|
||||||
id: "{{ ssh_key.hcloud_ssh_key.id }}"
|
id: "{{ ssh_key.hcloud_ssh_key.id }}"
|
||||||
|
|
@ -147,34 +136,45 @@
|
||||||
- result is failed
|
- result is failed
|
||||||
- result.failure.code == "uniqueness_error"
|
- 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:
|
hetzner.hcloud.ssh_key:
|
||||||
name: "{{ hcloud_ssh_key_name }}-other-name"
|
name: "{{ hcloud_ssh_key_name }}"
|
||||||
public_key: "{{ test_ssh_keypair_2.public_key }}"
|
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
|
force: true
|
||||||
register: result
|
register: result
|
||||||
check_mode: true
|
- name: verify update public key with force
|
||||||
- name: verify force update ssh key with new public key with check mode
|
|
||||||
assert:
|
assert:
|
||||||
that:
|
that:
|
||||||
- result is changed
|
- 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:
|
hetzner.hcloud.ssh_key:
|
||||||
name: "{{ hcloud_ssh_key_name }}-other-name"
|
name: "{{ hcloud_ssh_key_name }}"
|
||||||
public_key: "{{ test_ssh_keypair_2.public_key }}"
|
public_key: "{{ test_ssh_keypair2.public_key }}"
|
||||||
force: true
|
force: true
|
||||||
register: ssh_key
|
register: result
|
||||||
- name: verify force update ssh key with new public key
|
- name: verify update public key with force idempotence
|
||||||
assert:
|
assert:
|
||||||
that:
|
that:
|
||||||
- ssh_key is changed
|
- result is not 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
|
|
||||||
|
|
||||||
- name: test delete ssh key
|
- name: test delete ssh key
|
||||||
hetzner.hcloud.ssh_key:
|
hetzner.hcloud.ssh_key:
|
||||||
id: "{{ ssh_key.hcloud_ssh_key.id }}"
|
name: "{{ hcloud_ssh_key_name }}"
|
||||||
state: absent
|
state: absent
|
||||||
register: result
|
register: result
|
||||||
- name: verify absent ssh_key
|
- name: verify absent ssh_key
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue