This commit is contained in:
jo 2024-02-06 19:43:22 +01:00
parent 4916673ccb
commit 5db7a8311d
No known key found for this signature in database
GPG key ID: B2FEC9B22722B984
3 changed files with 55 additions and 67 deletions

View file

@ -7,7 +7,7 @@
register: result
check_mode: true
- name: test create server server
assert:
ansible.builtin.assert:
that:
- result is changed
@ -20,7 +20,7 @@
state: started
register: main_server
- name: verify create server
assert:
ansible.builtin.assert:
that:
- main_server is changed
- main_server.hcloud_server.name == hcloud_server_name
@ -34,7 +34,7 @@
state: started
register: result
- name: verify create server idempotence
assert:
ansible.builtin.assert:
that:
- result is not changed
@ -45,7 +45,7 @@
register: result
check_mode: true
- name: verify stop server with check mode
assert:
ansible.builtin.assert:
that:
- result is changed
- result.hcloud_server.status == "running"
@ -56,7 +56,7 @@
state: stopped
register: result
- name: verify stop server
assert:
ansible.builtin.assert:
that:
- result is changed
- result.hcloud_server.status == "off"
@ -68,7 +68,7 @@
register: result
check_mode: true
- name: verify start server with check mode
assert:
ansible.builtin.assert:
that:
- result is changed
@ -78,7 +78,7 @@
state: started
register: result
- name: verify start server
assert:
ansible.builtin.assert:
that:
- result is changed
- result.hcloud_server.status == "running"
@ -89,7 +89,7 @@
state: started
register: result
- name: verify start server idempotence
assert:
ansible.builtin.assert:
that:
- result is not changed
- result.hcloud_server.status == "running"
@ -100,7 +100,7 @@
state: stopped
register: result
- name: verify stop server by its id
assert:
ansible.builtin.assert:
that:
- result is changed
- result.hcloud_server.status == "off"
@ -113,7 +113,7 @@
register: result
check_mode: true
- name: verify test resize server running without force
assert:
ansible.builtin.assert:
that:
- result is changed
- result.hcloud_server.server_type == "cx11"
@ -126,7 +126,7 @@
register: result
check_mode: true
- name: verify resize server with check mode
assert:
ansible.builtin.assert:
that:
- result is changed
@ -137,7 +137,7 @@
state: stopped
register: result
- name: verify resize server without disk
assert:
ansible.builtin.assert:
that:
- result is changed
- result.hcloud_server.server_type == "cx21"
@ -149,7 +149,7 @@
state: stopped
register: result
- name: verify resize server idempotence
assert:
ansible.builtin.assert:
that:
- result is not changed
@ -160,7 +160,7 @@
state: stopped
register: result
- name: verify resize server to smaller plan
assert:
ansible.builtin.assert:
that:
- result is changed
- result.hcloud_server.server_type == "cx11"
@ -173,7 +173,7 @@
state: stopped
register: result
- name: verify resize server with disk
assert:
ansible.builtin.assert:
that:
- result is changed
- result.hcloud_server.server_type == "cx21"
@ -186,7 +186,7 @@
register: result
check_mode: true
- name: verify enable backups with check mode
assert:
ansible.builtin.assert:
that:
- result is changed
@ -197,7 +197,7 @@
state: stopped
register: result
- name: verify enable backups
assert:
ansible.builtin.assert:
that:
- result is changed
- result.hcloud_server.backup_window != ""
@ -209,7 +209,7 @@
state: stopped
register: result
- name: verify enable backups idempotence
assert:
ansible.builtin.assert:
that:
- result is not changed
- result.hcloud_server.backup_window != ""
@ -224,7 +224,7 @@
state: stopped
register: result
- name: verify backups are not accidentally disabled
assert:
ansible.builtin.assert:
that:
- result is not changed
- result.hcloud_server.backup_window != ""
@ -236,7 +236,7 @@
state: rebuild
register: result_after_test
- name: verify rebuild server
assert:
ansible.builtin.assert:
that:
- result_after_test is changed
- result.hcloud_server.id == result_after_test.hcloud_server.id
@ -249,7 +249,7 @@
register: result_after_test
check_mode: true
- name: verify rebuild server with check mode
assert:
ansible.builtin.assert:
that:
- result_after_test is changed
@ -261,7 +261,7 @@
register: result_after_test
ignore_errors: true
- name: verify update server protection booth protection arguments are required
assert:
ansible.builtin.assert:
that:
- result_after_test is failed
- 'result_after_test.msg == "parameters are required together: delete_protection, rebuild_protection"'
@ -275,7 +275,7 @@
register: result_after_test
ignore_errors: true
- name: verify update server protection fails if they are not the same
assert:
ansible.builtin.assert:
that:
- result_after_test is failed
@ -288,7 +288,7 @@
register: result_after_test
ignore_errors: true
- name: verify update server protection
assert:
ansible.builtin.assert:
that:
- result_after_test is changed
- result_after_test.hcloud_server.delete_protection is sameas true
@ -299,7 +299,7 @@
name: "{{hcloud_server_name}}"
register: result_after_test
- name: verify test server without protection set to be idempotent
assert:
ansible.builtin.assert:
that:
- result_after_test is not changed
- result_after_test.hcloud_server.delete_protection is sameas true
@ -312,7 +312,7 @@
ignore_errors: true
register: result
- name: verify delete server fails if it is protected
assert:
ansible.builtin.assert:
that:
- result is failed
- 'result.msg == "server deletion is protected"'
@ -325,7 +325,7 @@
ignore_errors: true
register: result
- name: verify rebuild server fails if it is protected
assert:
ansible.builtin.assert:
that:
- result is failed
- 'result.msg == "server rebuild is protected"'
@ -339,7 +339,7 @@
register: result_after_test
ignore_errors: true
- name: verify remove server protection
assert:
ansible.builtin.assert:
that:
- result_after_test is changed
- result_after_test.hcloud_server.delete_protection is sameas false
@ -351,7 +351,7 @@
state: absent
register: result
- name: verify absent server
assert:
ansible.builtin.assert:
that:
- result is success
@ -365,7 +365,7 @@
state: started
register: main_server
- name: verify create server with ssh key
assert:
ansible.builtin.assert:
that:
- main_server is changed
- main_server.hcloud_server.name == hcloud_server_name
@ -383,7 +383,7 @@
register: main_server
check_mode: true
- name: verify activate rescue mode
assert:
ansible.builtin.assert:
that:
- main_server is changed
@ -396,7 +396,7 @@
state: present
register: main_server
- name: verify activate rescue mode
assert:
ansible.builtin.assert:
that:
- main_server is changed
- main_server.hcloud_server.rescue_enabled is sameas true
@ -409,7 +409,7 @@
state: present
register: main_server
- name: verify activate rescue mode
assert:
ansible.builtin.assert:
that:
- main_server is changed
- main_server.hcloud_server.rescue_enabled is sameas false
@ -421,7 +421,7 @@
state: present
register: main_server
- name: verify activate rescue mode without ssh keys
assert:
ansible.builtin.assert:
that:
- main_server is changed
- main_server.hcloud_server.rescue_enabled is sameas true
@ -432,7 +432,7 @@
state: absent
register: result
- name: verify absent server
assert:
ansible.builtin.assert:
that:
- result is success
@ -447,7 +447,7 @@
state: started
register: main_server
- name: verify create server with rescue_mode
assert:
ansible.builtin.assert:
that:
- main_server is changed
- main_server.hcloud_server.name == hcloud_server_name
@ -462,7 +462,7 @@
state: absent
register: result
- name: verify absent server
assert:
ansible.builtin.assert:
that:
- result is success
- name: test create server with labels
@ -478,7 +478,7 @@
state: started
register: main_server
- name: verify create server with labels
assert:
ansible.builtin.assert:
that:
- main_server is changed
- main_server.hcloud_server.labels.key == "value"
@ -497,7 +497,7 @@
state: started
register: main_server
- name: verify update server with labels
assert:
ansible.builtin.assert:
that:
- main_server is changed
- main_server.hcloud_server.labels.key == "other"
@ -516,7 +516,7 @@
state: started
register: main_server
- name: verify update server with labels in other order
assert:
ansible.builtin.assert:
that:
- main_server is not changed
@ -526,7 +526,7 @@
state: absent
register: result
- name: verify cleanup
assert:
ansible.builtin.assert:
that:
- result is success
@ -541,7 +541,7 @@
state: present
register: result
- name: verify enable backups
assert:
ansible.builtin.assert:
that:
- result is changed
- result.hcloud_server.backup_window != ""
@ -552,7 +552,7 @@
state: absent
register: result
- name: verify cleanup
assert:
ansible.builtin.assert:
that:
- result is success
@ -569,7 +569,7 @@
register: result_after_test
ignore_errors: true
- name: verify create server with protection
assert:
ansible.builtin.assert:
that:
- result_after_test is changed
- result_after_test.hcloud_server.delete_protection is sameas true
@ -582,7 +582,7 @@
ignore_errors: true
register: result
- name: verify delete server fails if it is protected
assert:
ansible.builtin.assert:
that:
- result is failed
- 'result.msg == "server deletion is protected"'
@ -596,7 +596,7 @@
register: result_after_test
ignore_errors: true
- name: verify update server protection
assert:
ansible.builtin.assert:
that:
- result_after_test is changed
- result_after_test.hcloud_server.delete_protection is sameas false
@ -608,6 +608,6 @@
state: absent
register: result
- name: verify cleanup
assert:
ansible.builtin.assert:
that:
- result is success

View file

@ -10,22 +10,10 @@
ignore_errors: true
register: result
- name: verify add not existing firewall should fail
assert:
ansible.builtin.assert:
that:
- result is failed
- 'result.msg == "firewall not-existing was not found"'
- name: setup create firewalls
hetzner.hcloud.firewall:
name: "{{ item }}"
rules:
- direction: in
protocol: icmp
source_ips:
- 0.0.0.0/0
- ::/0
with_items:
- "{{ hcloud_firewall_name }}"
- "{{ hcloud_firewall_name }}2"
- name: test create server with firewalls
hetzner.hcloud.server:
@ -39,7 +27,7 @@
state: present
register: result
- name: verify test create server with firewalls
assert:
ansible.builtin.assert:
that:
- result is changed
@ -55,7 +43,7 @@
state: present
register: result
- name: verify test create server with firewalls idempotence
assert:
ansible.builtin.assert:
that:
- result is not changed
@ -71,7 +59,7 @@
state: present
register: result
- name: verify test update server with firewalls
assert:
ansible.builtin.assert:
that:
- result is changed
@ -87,7 +75,7 @@
state: present
register: result
- name: verify test update server with firewalls idempotence
assert:
ansible.builtin.assert:
that:
- result is not changed

View file

@ -75,7 +75,7 @@
state: stopped
register: result
- name: verify test create server with primary network
assert:
ansible.builtin.assert:
that:
- result is changed
@ -95,7 +95,7 @@
state: stopped
register: result
- name: verify test update server by adding secondary network
assert:
ansible.builtin.assert:
that:
- result is changed
@ -115,7 +115,7 @@
state: stopped
register: result
- name: verify test update server idem
assert:
ansible.builtin.assert:
that:
- result is not changed