1
0
Fork 0
mirror of https://github.com/ansible-collections/hetzner.hcloud.git synced 2026-02-04 08:01:49 +00:00
hetzner.hcloud/tests/integration/targets/server/tasks/test_firewalls.yml
Jonas L f3d697c006
test: use shared variable for server type, image and location (#522)
##### SUMMARY

Use shared variables to store information about which server type, image
or location to use for our integrations tests.

- The location was changed from FSN to HEL.
- The image was changed from ubuntu-22.04 to debian-12.
2024-06-26 16:10:58 +02:00

107 lines
2.9 KiB
YAML

# 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)
---
- name: test add not existing firewall should fail
hetzner.hcloud.server:
name: "{{ hcloud_server_name }}"
firewalls:
- not-existing
state: present
ignore_errors: true
register: result
- name: verify add not existing firewall should fail
assert:
that:
- result is failed
- result.failure.code == "not_found"
- 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:
name: "{{ hcloud_server_name }}"
server_type: "{{ hcloud_server_type_name }}"
firewalls:
- "{{ hcloud_firewall_name }}"
image: "{{ hcloud_image_name }}"
ssh_keys:
- "{{ hcloud_ssh_key_name }}"
state: present
register: result
- name: verify test create server with firewalls
assert:
that:
- result is changed
- name: test create server with firewalls idempotence
hetzner.hcloud.server:
name: "{{ hcloud_server_name }}"
server_type: "{{ hcloud_server_type_name }}"
firewalls:
- "{{ hcloud_firewall_name }}"
image: "{{ hcloud_image_name }}"
ssh_keys:
- "{{ hcloud_ssh_key_name }}"
state: present
register: result
- name: verify test create server with firewalls idempotence
assert:
that:
- result is not changed
- name: test update server with firewalls
hetzner.hcloud.server:
name: "{{ hcloud_server_name }}"
server_type: "{{ hcloud_server_type_name }}"
firewalls:
- "{{ hcloud_firewall_name }}2"
image: "{{ hcloud_image_name }}"
ssh_keys:
- "{{ hcloud_ssh_key_name }}"
state: present
register: result
- name: verify test update server with firewalls
assert:
that:
- result is changed
- name: test update server with firewalls idempotence
hetzner.hcloud.server:
name: "{{ hcloud_server_name }}"
server_type: "{{ hcloud_server_type_name }}"
firewalls:
- "{{ hcloud_firewall_name }}2"
image: "{{ hcloud_image_name }}"
ssh_keys:
- "{{ hcloud_ssh_key_name }}"
state: present
register: result
- name: verify test update server with firewalls idempotence
assert:
that:
- result is not changed
- name: cleanup server with firewalls
hetzner.hcloud.server:
name: "{{ hcloud_server_name }}"
state: absent
- name: cleanup test create firewall
hetzner.hcloud.firewall:
name: "{{ item }}"
state: absent
with_items:
- "{{ hcloud_firewall_name }}"
- "{{ hcloud_firewall_name }}2"