Skip to content

Commit

Permalink
test: improve tests using new setup_ssh_keypair helper (#285)
Browse files Browse the repository at this point in the history
* test: use new setup_ssh_keypair helper

Remove the previous setup_sshkey helper

* ci: fix tmp dir location to please chattr
  • Loading branch information
jooola committed Aug 4, 2023
1 parent 020b313 commit 13868c3
Show file tree
Hide file tree
Showing 28 changed files with 128 additions and 141 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
---
hcloud_placement_group_name: "{{ hcloud_ns }}"
hcloud_server_name: "{{ hcloud_ns }}"
hcloud_ssh_key_name: "{{ hcloud_ns }}"
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
dependencies:
- setup_ssh_keypair
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
- name: Cleanup test_ssh_key
hetzner.hcloud.hcloud_ssh_key:
name: "{{ hcloud_ssh_key_name }}"
state: absent
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
- name: Create test_ssh_key
hetzner.hcloud.hcloud_ssh_key:
name: "{{ hcloud_ssh_key_name }}"
public_key: "{{ test_ssh_keypair.public_key }}"
register: test_ssh_key
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
placement_group: "{{ hcloud_placement_group_name }}"
image: "ubuntu-22.04"
ssh_keys:
- ci@ansible.hetzner.cloud
- "{{ hcloud_ssh_key_name }}"
state: present
register: server
- name: verify create server with placement group
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ hcloud_server_name: "{{ hcloud_ns }}"
hcloud_floating_ip_name: "{{ hcloud_ns }}"
hcloud_primary_ip_name: "{{ hcloud_ns }}"
hcloud_load_balancer_name: "{{ hcloud_ns }}"
hcloud_ssh_key_name: "{{ hcloud_ns }}"
3 changes: 3 additions & 0 deletions tests/integration/targets/hcloud_rdns/meta/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
dependencies:
- setup_ssh_keypair
5 changes: 5 additions & 0 deletions tests/integration/targets/hcloud_rdns/tasks/cleanup.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
- name: Cleanup test_ssh_key
hetzner.hcloud.hcloud_ssh_key:
name: "{{ hcloud_ssh_key_name }}"
state: absent
6 changes: 6 additions & 0 deletions tests/integration/targets/hcloud_rdns/tasks/prepare.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
- name: Create test_ssh_key
hetzner.hcloud.hcloud_ssh_key:
name: "{{ hcloud_ssh_key_name }}"
public_key: "{{ test_ssh_keypair.public_key }}"
register: test_ssh_key
2 changes: 1 addition & 1 deletion tests/integration/targets/hcloud_rdns/tasks/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
server_type: cx11
image: "ubuntu-22.04"
ssh_keys:
- ci@ansible.hetzner.cloud
- "{{ hcloud_ssh_key_name }}"
state: present
register: setup
- name: verify setup
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Copyright: (c) 2019, Hetzner Cloud GmbH <info@hetzner-cloud.de>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
---
hcloud_ssh_key_name: "{{ hcloud_ns }}"
hcloud_server_name: "{{ hcloud_ns }}"
hcloud_firewall_name: "{{ hcloud_ns }}"
hcloud_primary_ip_name: "{{ hcloud_ns }}"
Expand Down
3 changes: 3 additions & 0 deletions tests/integration/targets/hcloud_server/meta/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
dependencies:
- setup_ssh_keypair
5 changes: 5 additions & 0 deletions tests/integration/targets/hcloud_server/tasks/cleanup.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
- name: Cleanup test_ssh_key
hetzner.hcloud.hcloud_ssh_key:
name: "{{ hcloud_ssh_key_name }}"
state: absent
6 changes: 6 additions & 0 deletions tests/integration/targets/hcloud_server/tasks/prepare.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
- name: Create test_ssh_key
hetzner.hcloud.hcloud_ssh_key:
name: "{{ hcloud_ssh_key_name }}"
public_key: "{{ test_ssh_keypair.public_key }}"
register: test_ssh_key
20 changes: 10 additions & 10 deletions tests/integration/targets/hcloud_server/tasks/test_basic.yml
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@
server_type: cx11
image: "ubuntu-22.04"
ssh_keys:
- ci@ansible.hetzner.cloud
- "{{ hcloud_ssh_key_name }}"
state: started
register: main_server
- name: verify create server with ssh key
Expand All @@ -378,7 +378,7 @@
name: "{{ hcloud_server_name }}"
rescue_mode: "linux64"
ssh_keys:
- ci@ansible.hetzner.cloud
- "{{ hcloud_ssh_key_name }}"
state: present
register: main_server
check_mode: true
Expand All @@ -392,7 +392,7 @@
name: "{{ hcloud_server_name }}"
rescue_mode: "linux64"
ssh_keys:
- ci@ansible.hetzner.cloud
- "{{ hcloud_ssh_key_name }}"
state: present
register: main_server
- name: verify activate rescue mode
Expand All @@ -405,7 +405,7 @@
hetzner.hcloud.hcloud_server:
name: "{{ hcloud_server_name }}"
ssh_keys:
- ci@ansible.hetzner.cloud
- "{{ hcloud_ssh_key_name }}"
state: present
register: main_server
- name: verify activate rescue mode
Expand Down Expand Up @@ -442,7 +442,7 @@
server_type: cx11
image: "ubuntu-22.04"
ssh_keys:
- ci@ansible.hetzner.cloud
- "{{ hcloud_ssh_key_name }}"
rescue_mode: "linux64"
state: started
register: main_server
Expand Down Expand Up @@ -471,7 +471,7 @@
server_type: cx11
image: "ubuntu-22.04"
ssh_keys:
- ci@ansible.hetzner.cloud
- "{{ hcloud_ssh_key_name }}"
labels:
key: value
mylabel: "val123"
Expand All @@ -490,7 +490,7 @@
server_type: cx11
image: "ubuntu-22.04"
ssh_keys:
- ci@ansible.hetzner.cloud
- "{{ hcloud_ssh_key_name }}"
labels:
key: other
mylabel: "val123"
Expand All @@ -509,7 +509,7 @@
server_type: cx11
image: "ubuntu-22.04"
ssh_keys:
- ci@ansible.hetzner.cloud
- "{{ hcloud_ssh_key_name }}"
labels:
mylabel: "val123"
key: other
Expand Down Expand Up @@ -537,7 +537,7 @@
backups: true
image: "ubuntu-22.04"
ssh_keys:
- ci@ansible.hetzner.cloud
- "{{ hcloud_ssh_key_name }}"
state: present
register: result
- name: verify enable backups
Expand All @@ -564,7 +564,7 @@
server_type: cpx11
image: "ubuntu-22.04"
ssh_keys:
- ci@ansible.hetzner.cloud
- "{{ hcloud_ssh_key_name }}"
state: present
register: result_after_test
ignore_errors: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
- "{{ hcloud_firewall_name }}"
image: "ubuntu-22.04"
ssh_keys:
- ci@ansible.hetzner.cloud
- "{{ hcloud_ssh_key_name }}"
state: present
register: result
- name: verify test create server with firewalls
Expand All @@ -51,7 +51,7 @@
- "{{ hcloud_firewall_name }}"
image: "ubuntu-22.04"
ssh_keys:
- ci@ansible.hetzner.cloud
- "{{ hcloud_ssh_key_name }}"
state: present
register: result
- name: verify test create server with firewalls idempotence
Expand All @@ -67,7 +67,7 @@
- "{{ hcloud_firewall_name }}2"
image: "ubuntu-22.04"
ssh_keys:
- ci@ansible.hetzner.cloud
- "{{ hcloud_ssh_key_name }}"
state: present
register: result
- name: verify test update server with firewalls
Expand All @@ -83,7 +83,7 @@
- "{{ hcloud_firewall_name }}2"
image: "ubuntu-22.04"
ssh_keys:
- ci@ansible.hetzner.cloud
- "{{ hcloud_ssh_key_name }}"
state: present
register: result
- name: verify test update server with firewalls idempotence
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
ipv4: "{{primaryIPv4.hcloud_primary_ip.id}}"
ipv6: "{{primaryIPv6.hcloud_primary_ip.id}}"
ssh_keys:
- ci@ansible.hetzner.cloud
- "{{ hcloud_ssh_key_name }}"
state: stopped
register: result
- name: verify test create server with primary ips
Expand All @@ -49,7 +49,7 @@
ipv6: ""
enable_ipv6: false
ssh_keys:
- ci@ansible.hetzner.cloud
- "{{ hcloud_ssh_key_name }}"
state: stopped
register: result
- name: verify test create server with primary ips
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
private_networks:
- "{{ primaryNetwork.hcloud_network.name }}"
ssh_keys:
- ci@ansible.hetzner.cloud
- "{{ hcloud_ssh_key_name }}"
state: stopped
register: result
- name: verify test create server with primary network
Expand All @@ -91,7 +91,7 @@
- "{{ primaryNetwork.hcloud_network.name }}"
- "{{ secondaryNetwork.hcloud_network.id }}"
ssh_keys:
- ci@ansible.hetzner.cloud
- "{{ hcloud_ssh_key_name }}"
state: stopped
register: result
- name: verify test update server by adding secondary network
Expand All @@ -111,7 +111,7 @@
- "{{ primaryNetwork.hcloud_network.name }}"
- "{{ secondaryNetwork.hcloud_network.id }}"
ssh_keys:
- ci@ansible.hetzner.cloud
- "{{ hcloud_ssh_key_name }}"
state: stopped
register: result
- name: verify test update server idem
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,3 @@
---
hcloud_server_name: "{{ hcloud_ns }}"
hcloud_ssh_key_name: "{{ hcloud_ns }}"
hcloud_ssh_key_public_key: "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDnaTPfKaX1QKcRLOfr34buVLh5FhJAThI9NYB0xNdXsMd4Y0zLyyCQzHbx4eWCVZxym/s6csWSeLaAhO1GOHeAw3hQFMqf1oTBx6Y8g0pKpeotKPa/PDSUzdZF9Lc+DadtpQd8kFVHAu1Kd3zoEUnk1u6kP7I4qu4Z/6F9qBDF+M3aobiPVxdS7GwaVRW3nZu+FcQDLiBiNOjuRDyjHcDfEUkoh2SOu25RrFtGPzFu5mGmBJwotKpWAocLGfHzyn/fAHxgw3jKZVH/t+XWQFnl82Ie8yE3Z1EZ7oDkNRqFQT9AdXEQOLycTTYTQMJZpgeFTv3sAo6lPRCusiFmmLcf ci@ansible.hetzner.cloud"
hcloud_ssh_key_fingerprint: "56:89:c4:d6:a7:4a:79:82:f4:c2:58:9c:e1:d2:2d:4e"

hcloud_doubled_ssh_key_public_key: "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC1AiuN3UMQKzOs4tNudmlDSkSebC+savc6CivoHGflUKeli7nKb5pKgGiqH+zeWZc+8+flUa2BxsJWmi7d1nGJ++W4BnzmqW78ApelpJnGtuX8IKNcq/trhVTQyaShPiLluoBs7bXyyZpAKNGkk3jHrgwwYD/QQDN0CJnQUM18fjH5CUes2vmaG/kkhn7ctuVHDOvDcEy8KdBX3fYyrtXw5GgWDC5borG6yT1f3E9AXfRPL9OQjMTeC+G4FHscJAZjNnYav+jLrQLdV1xJ0JgbjRyBgTAfBszx9oKIjzCUPvpj4npju0WFGu10pIh0w7bluMoVn1tS6Y3gxE/Cepwt ci@ansible.hetzner.cloud"
hcloud_doubled_ssh_key_fingerprint: "f9:33:40:ff:77:f3:3e:85:f2:9e:8f:98:71:fd:a0:58"
2 changes: 1 addition & 1 deletion tests/integration/targets/hcloud_ssh_key/meta/main.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
---
dependencies:
- setup_sshkey
- setup_ssh_keypair
10 changes: 10 additions & 0 deletions tests/integration/targets/hcloud_ssh_key/tasks/cleanup.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
- name: Cleanup test_ssh_key
hetzner.hcloud.hcloud_ssh_key:
name: "{{ hcloud_ssh_key_name }}"
state: absent

- name: Cleanup test_server
hetzner.hcloud.hcloud_server:
name: "{{ hcloud_server_name }}"
state: absent
Loading

0 comments on commit 13868c3

Please sign in to comment.