mirror of
https://github.com/ansible-collections/hetzner.hcloud.git
synced 2026-02-04 08:01:49 +00:00
Implement Load Balancers and Certificates and prepare release (#13)
This commit is contained in:
parent
6d83275ffa
commit
769a63ff22
50 changed files with 2817 additions and 18 deletions
2
tests/integration/targets/hcloud_certificate/aliases
Normal file
2
tests/integration/targets/hcloud_certificate/aliases
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
cloud/hcloud
|
||||
shippable/hcloud/group2
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
# 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_prefix: "tests"
|
||||
hcloud_certificate_name: "{{hcloud_prefix}}-integration"
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
dependencies:
|
||||
- setup_selfsigned_certificate
|
||||
collections:
|
||||
- community.general.ipfilter
|
||||
- hetzner.cloud
|
||||
123
tests/integration/targets/hcloud_certificate/tasks/main.yml
Normal file
123
tests/integration/targets/hcloud_certificate/tasks/main.yml
Normal file
|
|
@ -0,0 +1,123 @@
|
|||
# Copyright: (c) 2020, 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 missing required parameters on create certificate
|
||||
hcloud_certificate:
|
||||
name: "{{ hcloud_certificate_name }}"
|
||||
register: result
|
||||
ignore_errors: yes
|
||||
- name: verify fail test missing required parameters on create certificate
|
||||
assert:
|
||||
that:
|
||||
- result is failed
|
||||
- 'result.msg == "missing required arguments: certificate, private_key"'
|
||||
|
||||
- name: test create certificate with check mode
|
||||
hcloud_certificate:
|
||||
name: "{{ hcloud_certificate_name }}"
|
||||
certificate: "{{ certificate_example_com }}"
|
||||
private_key: "{{ certificate_example_com_key }}"
|
||||
register: result
|
||||
check_mode: yes
|
||||
- name: test create certificate with check mode
|
||||
assert:
|
||||
that:
|
||||
- result is changed
|
||||
|
||||
- name: test create certificate
|
||||
hcloud_certificate:
|
||||
name: "{{ hcloud_certificate_name }}"
|
||||
certificate: "{{ certificate_example_com }}"
|
||||
private_key: "{{ certificate_example_com_key }}"
|
||||
labels:
|
||||
key: value
|
||||
my-label: label
|
||||
register: certificate
|
||||
- name: verify create certificate
|
||||
assert:
|
||||
that:
|
||||
- certificate is changed
|
||||
- certificate.hcloud_certificate.name == "{{ hcloud_certificate_name }}"
|
||||
- certificate.hcloud_certificate.domain_names[0] == "www.example.com"
|
||||
- certificate.hcloud_certificate.labels.key == "value"
|
||||
|
||||
- name: test create certificate idempotence
|
||||
hcloud_certificate:
|
||||
name: "{{ hcloud_certificate_name }}"
|
||||
certificate: "{{ certificate_example_com }}"
|
||||
private_key: "{{ certificate_example_com_key }}"
|
||||
register: result
|
||||
- name: verify create certificate idempotence
|
||||
assert:
|
||||
that:
|
||||
- result is not changed
|
||||
|
||||
- name: test update certificate with check mode
|
||||
hcloud_certificate:
|
||||
id: "{{ certificate.hcloud_certificate.id }}"
|
||||
name: "changed-{{ hcloud_certificate_name }}"
|
||||
register: result
|
||||
check_mode: yes
|
||||
- name: test create certificate with check mode
|
||||
assert:
|
||||
that:
|
||||
- result is changed
|
||||
|
||||
- name: test update certificate
|
||||
hcloud_certificate:
|
||||
id: "{{ certificate.hcloud_certificate.id }}"
|
||||
name: "changed-{{ hcloud_certificate_name }}"
|
||||
labels:
|
||||
key: value
|
||||
register: result
|
||||
- name: test update certificate
|
||||
assert:
|
||||
that:
|
||||
- result is changed
|
||||
- result.hcloud_certificate.name == "changed-{{ hcloud_certificate_name }}"
|
||||
|
||||
- name: test update certificate with same labels
|
||||
hcloud_certificate:
|
||||
id: "{{ certificate.hcloud_certificate.id }}"
|
||||
name: "changed-{{ hcloud_certificate_name }}"
|
||||
labels:
|
||||
key: value
|
||||
register: result
|
||||
- name: test update certificate with same labels
|
||||
assert:
|
||||
that:
|
||||
- result is not changed
|
||||
|
||||
- name: test update certificate with other labels
|
||||
hcloud_certificate:
|
||||
id: "{{ certificate.hcloud_certificate.id }}"
|
||||
name: "changed-{{ hcloud_certificate_name }}"
|
||||
labels:
|
||||
key: value
|
||||
test: "val123"
|
||||
register: result
|
||||
- name: test update certificate with other labels
|
||||
assert:
|
||||
that:
|
||||
- result is changed
|
||||
|
||||
- name: test rename certificate
|
||||
hcloud_certificate:
|
||||
id: "{{ certificate.hcloud_certificate.id }}"
|
||||
name: "{{ hcloud_certificate_name }}"
|
||||
register: result
|
||||
- name: test rename certificate
|
||||
assert:
|
||||
that:
|
||||
- result is changed
|
||||
- result.hcloud_certificate.name == "{{ hcloud_certificate_name }}"
|
||||
|
||||
- name: absent certificate
|
||||
hcloud_certificate:
|
||||
id: "{{ certificate.hcloud_certificate.id }}"
|
||||
state: absent
|
||||
register: result
|
||||
- name: verify absent server
|
||||
assert:
|
||||
that:
|
||||
- result is success
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
cloud/hcloud
|
||||
shippable/hcloud/group2
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
# 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_prefix: "tests"
|
||||
hcloud_certificate_name: "always-there-cert"
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
collections:
|
||||
- hetzner.cloud
|
||||
|
|
@ -0,0 +1,39 @@
|
|||
# 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 gather hcloud certificate infos in check mode
|
||||
hcloud_certificate_info:
|
||||
register: hcloud_certificate
|
||||
check_mode: yes
|
||||
- name: verify test gather hcloud certificate infos in check mode
|
||||
assert:
|
||||
that:
|
||||
- hcloud_certificate.hcloud_certificate_info| list | count >= 1
|
||||
|
||||
- name: test gather hcloud certificate infos
|
||||
hcloud_certificate_info:
|
||||
register: hcloud_certificate
|
||||
check_mode: yes
|
||||
- name: verify test gather hcloud certificate infos
|
||||
assert:
|
||||
that:
|
||||
- hcloud_certificate.hcloud_certificate_info| list | count >= 1
|
||||
|
||||
- name: test gather hcloud certificate infos with correct label selector
|
||||
hcloud_certificate_info:
|
||||
label_selector: "key=value"
|
||||
register: hcloud_certificate
|
||||
- name: verify test gather hcloud certificate infos with correct label selector
|
||||
assert:
|
||||
that:
|
||||
- hcloud_certificate.hcloud_certificate_info|selectattr('name','equalto','{{ hcloud_certificate_name }}') | list | count == 1
|
||||
|
||||
- name: test gather hcloud certificate infos with wrong label selector
|
||||
hcloud_certificate_info:
|
||||
label_selector: "key!=value"
|
||||
register: hcloud_certificate
|
||||
- name: verify test gather hcloud certificate infos with wrong label selector
|
||||
assert:
|
||||
that:
|
||||
- hcloud_certificate.hcloud_certificate_info | list | count == 0
|
||||
2
tests/integration/targets/hcloud_load_balancer/aliases
Normal file
2
tests/integration/targets/hcloud_load_balancer/aliases
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
cloud/hcloud
|
||||
shippable/hcloud/group1
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
# Copyright: (c) 2020, 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_prefix: "tests"
|
||||
hcloud_load_balancer_name: "{{hcloud_prefix}}-integration"
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
collections:
|
||||
- community.general.ipfilter
|
||||
- hetzner.cloud
|
||||
176
tests/integration/targets/hcloud_load_balancer/tasks/main.yml
Normal file
176
tests/integration/targets/hcloud_load_balancer/tasks/main.yml
Normal file
|
|
@ -0,0 +1,176 @@
|
|||
# Copyright: (c) 2020, 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
|
||||
hcloud_load_balancer:
|
||||
name: "{{ hcloud_load_balancer_name }}"
|
||||
state: absent
|
||||
register: result
|
||||
- name: verify setup
|
||||
assert:
|
||||
that:
|
||||
- result is success
|
||||
- name: test missing required parameters on create Load Balancer
|
||||
hcloud_load_balancer:
|
||||
name: "{{ hcloud_load_balancer_name }}"
|
||||
register: result
|
||||
ignore_errors: yes
|
||||
- name: verify fail test missing required parameters on create Load Balancer
|
||||
assert:
|
||||
that:
|
||||
- result is failed
|
||||
- 'result.msg == "missing required arguments: load_balancer_type"'
|
||||
|
||||
- name: test create Load Balancer with check mode
|
||||
hcloud_load_balancer:
|
||||
name: "{{ hcloud_load_balancer_name }}"
|
||||
load_balancer_type: lb11
|
||||
network_zone: eu-central
|
||||
state: present
|
||||
register: result
|
||||
check_mode: yes
|
||||
- name: test create Load Balancer Load Balancer
|
||||
assert:
|
||||
that:
|
||||
- result is changed
|
||||
|
||||
- name: test create Load Balancer
|
||||
hcloud_load_balancer:
|
||||
name: "{{ hcloud_load_balancer_name}}"
|
||||
load_balancer_type: lb11
|
||||
network_zone: eu-central
|
||||
state: present
|
||||
register: main_load_balancer
|
||||
- name: verify create Load Balancer
|
||||
assert:
|
||||
that:
|
||||
- main_load_balancer is changed
|
||||
- main_load_balancer.hcloud_load_balancer.name == "{{ hcloud_load_balancer_name }}"
|
||||
- main_load_balancer.hcloud_load_balancer.load_balancer_type == "lb11"
|
||||
|
||||
- name: test create Load Balancer idempotence
|
||||
hcloud_load_balancer:
|
||||
name: "{{ hcloud_load_balancer_name }}"
|
||||
state: present
|
||||
register: result
|
||||
- name: verify create Load Balancer idempotence
|
||||
assert:
|
||||
that:
|
||||
- result is not changed
|
||||
|
||||
- name: test update Load Balancer protection
|
||||
hcloud_load_balancer:
|
||||
name: "{{ hcloud_load_balancer_name }}"
|
||||
delete_protection: true
|
||||
state: present
|
||||
register: result_after_test
|
||||
ignore_errors: true
|
||||
- name: verify update Load Balancer protection
|
||||
assert:
|
||||
that:
|
||||
- result_after_test is changed
|
||||
- result_after_test.hcloud_load_balancer.delete_protection is sameas true
|
||||
|
||||
- name: test Load Balancer without protection set to be idempotent
|
||||
hcloud_load_balancer:
|
||||
name: "{{hcloud_load_balancer_name}}"
|
||||
register: result_after_test
|
||||
- name: verify test Load Balancer without protection set to be idempotent
|
||||
assert:
|
||||
that:
|
||||
- result_after_test is not changed
|
||||
- result_after_test.hcloud_load_balancer.delete_protection is sameas true
|
||||
|
||||
- name: test delete Load Balancer fails if it is protected
|
||||
hcloud_load_balancer:
|
||||
name: "{{hcloud_load_balancer_name}}"
|
||||
state: absent
|
||||
ignore_errors: yes
|
||||
register: result
|
||||
- name: verify delete Load Balancer fails if it is protected
|
||||
assert:
|
||||
that:
|
||||
- result is failed
|
||||
- 'result.msg == "load balancer deletion is protected"'
|
||||
|
||||
- name: test remove Load Balancer protection
|
||||
hcloud_load_balancer:
|
||||
name: "{{ hcloud_load_balancer_name }}"
|
||||
delete_protection: false
|
||||
state: present
|
||||
register: result_after_test
|
||||
ignore_errors: true
|
||||
- name: verify remove Load Balancer protection
|
||||
assert:
|
||||
that:
|
||||
- result_after_test is changed
|
||||
- result_after_test.hcloud_load_balancer.delete_protection is sameas false
|
||||
|
||||
- name: absent Load Balancer
|
||||
hcloud_load_balancer:
|
||||
name: "{{ hcloud_load_balancer_name }}"
|
||||
state: absent
|
||||
register: result
|
||||
- name: verify absent Load Balancer
|
||||
assert:
|
||||
that:
|
||||
- result is success
|
||||
|
||||
- name: test create Load Balancer with labels
|
||||
hcloud_load_balancer:
|
||||
name: "{{ hcloud_load_balancer_name}}"
|
||||
load_balancer_type: lb11
|
||||
network_zone: eu-central
|
||||
labels:
|
||||
key: value
|
||||
mylabel: "val123"
|
||||
state: present
|
||||
register: main_load_balancer
|
||||
- name: verify create Load Balancer with labels
|
||||
assert:
|
||||
that:
|
||||
- main_load_balancer is changed
|
||||
- main_load_balancer.hcloud_load_balancer.labels.key == "value"
|
||||
- main_load_balancer.hcloud_load_balancer.labels.mylabel == "val123"
|
||||
|
||||
- name: test update Load Balancer with labels
|
||||
hcloud_load_balancer:
|
||||
name: "{{ hcloud_load_balancer_name}}"
|
||||
load_balancer_type: lb11
|
||||
network_zone: eu-central
|
||||
labels:
|
||||
key: other
|
||||
mylabel: "val123"
|
||||
state: present
|
||||
register: main_load_balancer
|
||||
- name: verify update Load Balancer with labels
|
||||
assert:
|
||||
that:
|
||||
- main_load_balancer is changed
|
||||
- main_load_balancer.hcloud_load_balancer.labels.key == "other"
|
||||
- main_load_balancer.hcloud_load_balancer.labels.mylabel == "val123"
|
||||
|
||||
- name: test update Load Balancer with labels in other order
|
||||
hcloud_load_balancer:
|
||||
name: "{{ hcloud_load_balancer_name}}"
|
||||
load_balancer_type: lb11
|
||||
network_zone: eu-central
|
||||
labels:
|
||||
mylabel: "val123"
|
||||
key: other
|
||||
state: present
|
||||
register: main_load_balancer
|
||||
- name: verify update Load Balancer with labels in other order
|
||||
assert:
|
||||
that:
|
||||
- main_load_balancer is not changed
|
||||
|
||||
- name: cleanup with labels
|
||||
hcloud_load_balancer:
|
||||
name: "{{ hcloud_load_balancer_name }}"
|
||||
state: absent
|
||||
register: result
|
||||
- name: verify cleanup
|
||||
assert:
|
||||
that:
|
||||
- result is success
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
cloud/hcloud
|
||||
shippable/hcloud/group1
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
# 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_prefix: "tests"
|
||||
hcloud_network_name: "{{hcloud_prefix}}-load_balancer-network"
|
||||
hcloud_load_balancer_name: "{{hcloud_prefix}}-load_balancer-network"
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
collections:
|
||||
- community.general.ipfilter
|
||||
- hetzner.cloud
|
||||
|
|
@ -0,0 +1,155 @@
|
|||
# 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 network
|
||||
hcloud_network:
|
||||
name: "{{ hcloud_network_name }}"
|
||||
ip_range: "10.0.0.0/8"
|
||||
state: present
|
||||
register: network
|
||||
- name: verify setup network
|
||||
assert:
|
||||
that:
|
||||
- network is success
|
||||
|
||||
- name: setup subnetwork
|
||||
hcloud_subnetwork:
|
||||
network: "{{ hcloud_network_name }}"
|
||||
ip_range: "10.0.0.0/16"
|
||||
type: "cloud"
|
||||
network_zone: "eu-central"
|
||||
state: present
|
||||
register: subnetwork
|
||||
- name: verify subnetwork
|
||||
assert:
|
||||
that:
|
||||
- subnetwork is success
|
||||
|
||||
- name: setup load_balancer
|
||||
hcloud_load_balancer:
|
||||
name: "{{hcloud_load_balancer_name}}"
|
||||
load_balancer_type: lb11
|
||||
state: present
|
||||
location: "fsn1"
|
||||
register: load_balancer
|
||||
- name: verify setup load_balancer
|
||||
assert:
|
||||
that:
|
||||
- load_balancer is success
|
||||
|
||||
- name: test missing required parameters on create load_balancer network
|
||||
hcloud_load_balancer_network:
|
||||
state: present
|
||||
register: result
|
||||
ignore_errors: yes
|
||||
- name: verify fail test missing required parameters on create load_balancer network
|
||||
assert:
|
||||
that:
|
||||
- result is failed
|
||||
- 'result.msg == "missing required arguments: load_balancer, network"'
|
||||
|
||||
- name: test create load_balancer network with checkmode
|
||||
hcloud_load_balancer_network:
|
||||
network: "{{ hcloud_network_name }}"
|
||||
load_balancer: "{{hcloud_load_balancer_name}}"
|
||||
state: present
|
||||
register: result
|
||||
check_mode: yes
|
||||
- name: verify test create load_balancer network with checkmode
|
||||
assert:
|
||||
that:
|
||||
- result is changed
|
||||
|
||||
- name: test create load_balancer network
|
||||
hcloud_load_balancer_network:
|
||||
network: "{{ hcloud_network_name }}"
|
||||
load_balancer: "{{hcloud_load_balancer_name}}"
|
||||
state: present
|
||||
register: load_balancerNetwork
|
||||
- name: verify create load_balancer network
|
||||
assert:
|
||||
that:
|
||||
- load_balancerNetwork is changed
|
||||
- load_balancerNetwork.hcloud_load_balancer_network.network == hcloud_network_name
|
||||
- load_balancerNetwork.hcloud_load_balancer_network.load_balancer == hcloud_load_balancer_name
|
||||
|
||||
- name: test create load_balancer network idempotency
|
||||
hcloud_load_balancer_network:
|
||||
network: "{{ hcloud_network_name }}"
|
||||
load_balancer: "{{hcloud_load_balancer_name}}"
|
||||
state: present
|
||||
register: load_balancerNetwork
|
||||
- name: verify create load_balancer network idempotency
|
||||
assert:
|
||||
that:
|
||||
- load_balancerNetwork is not changed
|
||||
|
||||
- name: test absent load_balancer network
|
||||
hcloud_load_balancer_network:
|
||||
network: "{{ hcloud_network_name }}"
|
||||
load_balancer: "{{hcloud_load_balancer_name}}"
|
||||
state: absent
|
||||
register: result
|
||||
- name: verify test absent load_balancer network
|
||||
assert:
|
||||
that:
|
||||
- result is changed
|
||||
|
||||
- name: test create load_balancer network with specified ip
|
||||
hcloud_load_balancer_network:
|
||||
network: "{{ hcloud_network_name }}"
|
||||
load_balancer: "{{hcloud_load_balancer_name}}"
|
||||
ip: "10.0.0.2"
|
||||
state: present
|
||||
register: load_balancerNetwork
|
||||
- name: verify create load_balancer network with specified ip
|
||||
assert:
|
||||
that:
|
||||
- load_balancerNetwork is changed
|
||||
- load_balancerNetwork.hcloud_load_balancer_network.network == hcloud_network_name
|
||||
- load_balancerNetwork.hcloud_load_balancer_network.load_balancer == hcloud_load_balancer_name
|
||||
- load_balancerNetwork.hcloud_load_balancer_network.ip == "10.0.0.2"
|
||||
|
||||
- name: cleanup create load_balancer network with specified ip
|
||||
hcloud_load_balancer_network:
|
||||
network: "{{ hcloud_network_name }}"
|
||||
load_balancer: "{{hcloud_load_balancer_name}}"
|
||||
state: absent
|
||||
register: result
|
||||
- name: verify cleanup create load_balancer network with specified ip
|
||||
assert:
|
||||
that:
|
||||
- result is changed
|
||||
|
||||
- name: cleanup load_balancer
|
||||
hcloud_load_balancer:
|
||||
name: "{{ hcloud_load_balancer_name }}"
|
||||
state: absent
|
||||
register: result
|
||||
- name: verify cleanup load_balancer
|
||||
assert:
|
||||
that:
|
||||
- result is success
|
||||
|
||||
- name: cleanup subnetwork
|
||||
hcloud_subnetwork:
|
||||
network: "{{ hcloud_network_name }}"
|
||||
ip_range: "10.0.0.0/16"
|
||||
type: "load_balancer"
|
||||
network_zone: "eu-central"
|
||||
state: absent
|
||||
register: result
|
||||
- name: verify cleanup subnetwork
|
||||
assert:
|
||||
that:
|
||||
- result is changed
|
||||
|
||||
- name: cleanup
|
||||
hcloud_network:
|
||||
name: "{{hcloud_network_name}}"
|
||||
state: absent
|
||||
register: result
|
||||
- name: verify cleanup
|
||||
assert:
|
||||
that:
|
||||
- result is success
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
cloud/hcloud
|
||||
shippable/hcloud/group1
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
# 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_prefix: "tests"
|
||||
hcloud_load_balancer_name: "{{hcloud_prefix}}-load_balancer-target"
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
collections:
|
||||
- community.general.ipfilter
|
||||
- hetzner.cloud
|
||||
|
|
@ -0,0 +1,112 @@
|
|||
# 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
|
||||
hcloud_load_balancer:
|
||||
name: "{{hcloud_load_balancer_name}}"
|
||||
load_balancer_type: lb11
|
||||
state: present
|
||||
location: "fsn1"
|
||||
register: load_balancer
|
||||
- name: verify setup load_balancer
|
||||
assert:
|
||||
that:
|
||||
- load_balancer is success
|
||||
|
||||
- name: test create load_balancer service with checkmode
|
||||
hcloud_load_balancer_service:
|
||||
load_balancer: "{{hcloud_load_balancer_name}}"
|
||||
protocol: "http"
|
||||
listen_port: 80
|
||||
state: present
|
||||
register: result
|
||||
check_mode: yes
|
||||
- name: verify test create load_balancer service with checkmode
|
||||
assert:
|
||||
that:
|
||||
- result is changed
|
||||
|
||||
- name: test create load_balancer service
|
||||
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
|
||||
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
|
||||
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
|
||||
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
|
||||
hcloud_load_balancer_service:
|
||||
load_balancer: "{{hcloud_load_balancer_name}}"
|
||||
protocol: "http"
|
||||
listen_port: 80
|
||||
http:
|
||||
cookie_name: "Test"
|
||||
sticky_sessions: yes
|
||||
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
|
||||
hcloud_load_balancer:
|
||||
name: "{{ hcloud_load_balancer_name }}"
|
||||
state: absent
|
||||
register: result
|
||||
- name: verify cleanup load_balancer
|
||||
assert:
|
||||
that:
|
||||
- result is success
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
cloud/hcloud
|
||||
shippable/hcloud/group1
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
# 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_prefix: "tests"
|
||||
hcloud_server_name: "{{hcloud_prefix}}-lb-target"
|
||||
hcloud_load_balancer_name: "{{hcloud_prefix}}-load_balancer-target"
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
collections:
|
||||
- community.general.ipfilter
|
||||
- hetzner.cloud
|
||||
|
|
@ -0,0 +1,99 @@
|
|||
# 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 server
|
||||
hcloud_server:
|
||||
name: "{{hcloud_server_name}}"
|
||||
server_type: cx11
|
||||
image: ubuntu-20.04
|
||||
state: started
|
||||
location: "fsn1"
|
||||
register: server
|
||||
- name: verify setup server
|
||||
assert:
|
||||
that:
|
||||
- server is success
|
||||
|
||||
- name: setup load_balancer
|
||||
hcloud_load_balancer:
|
||||
name: "{{hcloud_load_balancer_name}}"
|
||||
load_balancer_type: lb11
|
||||
state: present
|
||||
location: "fsn1"
|
||||
register: load_balancer
|
||||
- name: verify setup load_balancer
|
||||
assert:
|
||||
that:
|
||||
- load_balancer is success
|
||||
|
||||
- name: test create load_balancer target with checkmode
|
||||
hcloud_load_balancer_target:
|
||||
type: "server"
|
||||
load_balancer: "{{hcloud_load_balancer_name}}"
|
||||
server: "{{hcloud_server_name}}"
|
||||
state: present
|
||||
register: result
|
||||
check_mode: yes
|
||||
- name: verify test create load_balancer target with checkmode
|
||||
assert:
|
||||
that:
|
||||
- result is changed
|
||||
|
||||
- name: test create load_balancer target
|
||||
hcloud_load_balancer_target:
|
||||
type: "server"
|
||||
load_balancer: "{{hcloud_load_balancer_name}}"
|
||||
server: "{{hcloud_server_name}}"
|
||||
state: present
|
||||
register: load_balancer_target
|
||||
- name: verify create load_balancer target
|
||||
assert:
|
||||
that:
|
||||
- load_balancer_target is changed
|
||||
- load_balancer_target.hcloud_load_balancer_target.type == "server"
|
||||
- load_balancer_target.hcloud_load_balancer_target.server == hcloud_server_name
|
||||
- load_balancer_target.hcloud_load_balancer_target.load_balancer == hcloud_load_balancer_name
|
||||
|
||||
- name: test create load_balancer target idempotency
|
||||
hcloud_load_balancer_target:
|
||||
type: "server"
|
||||
load_balancer: "{{hcloud_load_balancer_name}}"
|
||||
server: "{{hcloud_server_name}}"
|
||||
state: present
|
||||
register: load_balancer_target
|
||||
- name: verify create load_balancer target idempotency
|
||||
assert:
|
||||
that:
|
||||
- load_balancer_target is not changed
|
||||
|
||||
- name: test absent load_balancer target
|
||||
hcloud_load_balancer_target:
|
||||
type: "server"
|
||||
load_balancer: "{{hcloud_load_balancer_name}}"
|
||||
server: "{{hcloud_server_name}}"
|
||||
state: absent
|
||||
register: result
|
||||
- name: verify test absent load_balancer target
|
||||
assert:
|
||||
that:
|
||||
- result is changed
|
||||
|
||||
- name: cleanup load_balancer
|
||||
hcloud_load_balancer:
|
||||
name: "{{ hcloud_load_balancer_name }}"
|
||||
state: absent
|
||||
register: result
|
||||
- name: verify cleanup load_balancer
|
||||
assert:
|
||||
that:
|
||||
- result is success
|
||||
|
||||
- name: cleanup
|
||||
hcloud_server:
|
||||
name: "{{hcloud_server_name}}"
|
||||
state: absent
|
||||
register: result
|
||||
- name: verify cleanup
|
||||
assert:
|
||||
that:
|
||||
- result is success
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
cloud/hcloud
|
||||
shippable/hcloud/group2
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
# Copyright: (c) 2020, 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_load_balancer_type_name: "lb11"
|
||||
hcloud_load_balancer_type_id: 1
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
collections:
|
||||
- community.general.ipfilter
|
||||
- hetzner.cloud
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
# Copyright: (c) 2020, 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 gather hcloud Load Balancer type infos
|
||||
hcloud_load_balancer_type_info:
|
||||
register: hcloud_load_balancer_types
|
||||
- name: verify test gather hcloud Load Balancer type infos
|
||||
assert:
|
||||
that:
|
||||
- hcloud_load_balancer_types.hcloud_load_balancer_type_info| list | count >= 1
|
||||
|
||||
- name: test gather hcloud Load Balancer type infos in check mode
|
||||
hcloud_load_balancer_type_info:
|
||||
check_mode: yes
|
||||
register: hcloud_load_balancer_types
|
||||
|
||||
- name: verify test gather hcloud Load Balancer type infos in check mode
|
||||
assert:
|
||||
that:
|
||||
- hcloud_load_balancer_types.hcloud_load_balancer_type_info| list | count >= 1
|
||||
|
||||
- name: test gather hcloud Load Balancer type infos with name
|
||||
hcloud_load_balancer_type_info:
|
||||
name: "{{hcloud_load_balancer_type_name}}"
|
||||
register: hcloud_load_balancer_types
|
||||
- name: verify test gather hcloud Load Balancer type with name
|
||||
assert:
|
||||
that:
|
||||
- hcloud_load_balancer_types.hcloud_load_balancer_type_info|selectattr('name','equalto','{{ hcloud_load_balancer_type_name }}') | list | count == 1
|
||||
|
||||
- name: test gather hcloud Load Balancer type infos with correct id
|
||||
hcloud_load_balancer_type_info:
|
||||
id: "{{hcloud_load_balancer_type_id}}"
|
||||
register: hcloud_load_balancer_types
|
||||
- name: verify test gather hcloud Load Balancer type with correct id
|
||||
assert:
|
||||
that:
|
||||
- hcloud_load_balancer_types.hcloud_load_balancer_type_info|selectattr('name','equalto','{{ hcloud_load_balancer_type_name }}') | list | count == 1
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
# Copyright: (c) 2020, 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: create a cert temp file
|
||||
tempfile:
|
||||
state: file
|
||||
register: certificate_example_com
|
||||
tags:
|
||||
- prepare
|
||||
- name: create a key temp file
|
||||
tempfile:
|
||||
state: file
|
||||
register: certificate_example_com_key
|
||||
tags:
|
||||
- prepare
|
||||
-
|
||||
- name: generate certificate
|
||||
shell: openssl req -nodes -new -x509 -keyout {{ certificate_example_com_key.path }} -out {{ certificate_example_com.path }} -subj "/C=DE/ST=Munich/L=Bavaria/O=Dis/CN=www.example.com"
|
||||
tags:
|
||||
- prepare
|
||||
|
||||
- name: set facts for future roles
|
||||
set_fact:
|
||||
certificate_example_com: "{{ lookup('file',certificate_example_com.path) }}"
|
||||
certificate_example_com_key: "{{ lookup('file',certificate_example_com_key.path) }}"
|
||||
tags:
|
||||
- prepare
|
||||
|
|
@ -55,7 +55,7 @@ retry ansible-galaxy -vvv collection install community.general
|
|||
retry ansible-galaxy -vvv collection install ansible.netcommon
|
||||
retry ansible-galaxy -vvv collection install community.internal_test_tools
|
||||
retry pip install netaddr --disable-pip-version-check
|
||||
retry pip install hcloud
|
||||
retry python -m pip install hcloud
|
||||
# END: HACK
|
||||
|
||||
export PYTHONIOENCODING='utf-8'
|
||||
|
|
|
|||
|
|
@ -12,4 +12,4 @@ hcloud_api_token=${HCLOUD_TOKEN}
|
|||
export SHIPPABLE="true"
|
||||
export SHIPPABLE_BUILD_NUMBER="gl-$(cat prefix.txt)"
|
||||
export SHIPPABLE_JOB_NUMBER="$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 2 | head -n 1)"
|
||||
ansible-test integration --color --local -v "${target}" ${COVERAGE:+"$COVERAGE"} ${CHANGED:+"$CHANGED"} ${UNSTABLE:+"$UNSTABLE"}
|
||||
ansible-test integration --color --local -vvvvv "${target}" ${COVERAGE:+"$COVERAGE"} ${CHANGED:+"$CHANGED"} ${UNSTABLE:+"$UNSTABLE"}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue