mirror of
https://github.com/ansible-collections/hetzner.hcloud.git
synced 2026-02-04 08:01:49 +00:00
##### 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.
126 lines
4.1 KiB
YAML
126 lines
4.1 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: setup load_balancer
|
|
hetzner.hcloud.load_balancer:
|
|
name: "{{hcloud_load_balancer_name}}"
|
|
load_balancer_type: lb11
|
|
state: present
|
|
location: "{{ hcloud_location_name }}"
|
|
register: load_balancer
|
|
- name: verify setup load_balancer
|
|
assert:
|
|
that:
|
|
- load_balancer is success
|
|
|
|
- name: test fail load balancer does not exist
|
|
hetzner.hcloud.load_balancer_service:
|
|
load_balancer: does-not-exist
|
|
protocol: http
|
|
listen_port: 80
|
|
state: present
|
|
register: result
|
|
ignore_errors: true
|
|
- name: verify test fail load_balancer does not exist
|
|
assert:
|
|
that:
|
|
- result is failed
|
|
- "result.msg == 'resource (load_balancer) does not exist: does-not-exist'"
|
|
|
|
- name: test create load_balancer service with checkmode
|
|
hetzner.hcloud.load_balancer_service:
|
|
load_balancer: "{{hcloud_load_balancer_name}}"
|
|
protocol: "http"
|
|
listen_port: 80
|
|
state: present
|
|
register: result
|
|
check_mode: true
|
|
- name: verify test create load_balancer service with checkmode
|
|
assert:
|
|
that:
|
|
- result is changed
|
|
|
|
- name: test create load_balancer service
|
|
hetzner.hcloud.load_balancer_service:
|
|
load_balancer: "{{hcloud_load_balancer_name}}"
|
|
protocol: "http"
|
|
listen_port: 80
|
|
state: present
|
|
register: load_balancer_service
|
|
- name: verify create load_balancer service
|
|
assert:
|
|
that:
|
|
- load_balancer_service is changed
|
|
- load_balancer_service.hcloud_load_balancer_service.protocol == "http"
|
|
- load_balancer_service.hcloud_load_balancer_service.listen_port == 80
|
|
- load_balancer_service.hcloud_load_balancer_service.destination_port == 80
|
|
- load_balancer_service.hcloud_load_balancer_service.proxyprotocol is sameas false
|
|
|
|
- name: test create load_balancer service idempotency
|
|
hetzner.hcloud.load_balancer_service:
|
|
load_balancer: "{{hcloud_load_balancer_name}}"
|
|
protocol: "http"
|
|
listen_port: 80
|
|
state: present
|
|
register: load_balancer_service
|
|
- name: verify create load_balancer service idempotency
|
|
assert:
|
|
that:
|
|
- load_balancer_service is not changed
|
|
|
|
- name: test update load_balancer service
|
|
hetzner.hcloud.load_balancer_service:
|
|
load_balancer: "{{hcloud_load_balancer_name}}"
|
|
protocol: "tcp"
|
|
listen_port: 80
|
|
state: present
|
|
register: load_balancer_service
|
|
- name: verify create load_balancer service
|
|
assert:
|
|
that:
|
|
- load_balancer_service is changed
|
|
- load_balancer_service.hcloud_load_balancer_service.protocol == "tcp"
|
|
- load_balancer_service.hcloud_load_balancer_service.listen_port == 80
|
|
- load_balancer_service.hcloud_load_balancer_service.destination_port == 80
|
|
- load_balancer_service.hcloud_load_balancer_service.proxyprotocol is sameas false
|
|
|
|
- name: test absent load_balancer service
|
|
hetzner.hcloud.load_balancer_service:
|
|
load_balancer: "{{hcloud_load_balancer_name}}"
|
|
protocol: "http"
|
|
listen_port: 80
|
|
state: absent
|
|
register: result
|
|
- name: verify test absent load_balancer service
|
|
assert:
|
|
that:
|
|
- result is changed
|
|
|
|
- name: test create load_balancer service with http
|
|
hetzner.hcloud.load_balancer_service:
|
|
load_balancer: "{{hcloud_load_balancer_name}}"
|
|
protocol: "http"
|
|
listen_port: 80
|
|
http:
|
|
cookie_name: "Test"
|
|
sticky_sessions: true
|
|
state: present
|
|
register: load_balancer_service
|
|
- name: verify create load_balancer service
|
|
assert:
|
|
that:
|
|
- load_balancer_service is changed
|
|
- load_balancer_service.hcloud_load_balancer_service.protocol == "http"
|
|
- load_balancer_service.hcloud_load_balancer_service.listen_port == 80
|
|
- load_balancer_service.hcloud_load_balancer_service.destination_port == 80
|
|
- load_balancer_service.hcloud_load_balancer_service.proxyprotocol is sameas false
|
|
|
|
- name: cleanup load_balancer
|
|
hetzner.hcloud.load_balancer:
|
|
name: "{{ hcloud_load_balancer_name }}"
|
|
state: absent
|
|
register: result
|
|
- name: verify cleanup load_balancer
|
|
assert:
|
|
that:
|
|
- result is success
|