mirror of
https://opendev.org/openstack/ansible-collections-openstack.git
synced 2026-07-28 02:34:30 +00:00
Refactored loadbalancer module breaking backward compatibility
Module option 'listeners' has been removed because it shares
functionality and a huge amount of code with
lb_{listener,member,pool} modules.
Co-Authored-By: Rafael Castillo <rcastill@redhat.com>
Change-Id: I839365bd3485859a2351b0124eae9d09a9d0b31a
This commit is contained in:
14
.zuul.yaml
14
.zuul.yaml
@@ -79,19 +79,25 @@
|
|||||||
- ^plugins/modules/lb_pool.py
|
- ^plugins/modules/lb_pool.py
|
||||||
- ^plugins/modules/loadbalancer.py
|
- ^plugins/modules/loadbalancer.py
|
||||||
vars:
|
vars:
|
||||||
configure_swap_size: 8192
|
configure_swap_size: 4096
|
||||||
tox_install_siblings: false
|
devstack_local_conf:
|
||||||
|
post-config:
|
||||||
|
$OCTAVIA_CONF:
|
||||||
|
controller_worker:
|
||||||
|
amphora_driver: amphora_noop_driver
|
||||||
devstack_plugins:
|
devstack_plugins:
|
||||||
designate: https://opendev.org/openstack/designate
|
designate: https://opendev.org/openstack/designate
|
||||||
octavia: https://opendev.org/openstack/octavia
|
octavia: https://opendev.org/openstack/octavia
|
||||||
devstack_services:
|
devstack_services:
|
||||||
designate: true
|
designate: true
|
||||||
neutron-dns: true
|
|
||||||
octavia: true
|
octavia: true
|
||||||
o-api: true
|
o-api: true
|
||||||
o-cw: true
|
o-cw: true
|
||||||
o-hk: true
|
|
||||||
o-hm: true
|
o-hm: true
|
||||||
|
o-hk: true
|
||||||
|
neutron-dns: true
|
||||||
|
tox_extra_args: -vv --skip-missing-interpreters=false -- loadbalancer
|
||||||
|
tox_install_siblings: false
|
||||||
|
|
||||||
- job:
|
- job:
|
||||||
name: ansible-collections-openstack-functional-devstack-octavia
|
name: ansible-collections-openstack-functional-devstack-octavia
|
||||||
|
|||||||
@@ -1,3 +1,22 @@
|
|||||||
network_name: network_lb
|
expected_fields:
|
||||||
subnet_name: subnet_lb
|
- additional_vips
|
||||||
lb_name: test_lb
|
- availability_zone
|
||||||
|
- created_at
|
||||||
|
- description
|
||||||
|
- flavor_id
|
||||||
|
- id
|
||||||
|
- is_admin_state_up
|
||||||
|
- listeners
|
||||||
|
- name
|
||||||
|
- operating_status
|
||||||
|
- pools
|
||||||
|
- project_id
|
||||||
|
- provider
|
||||||
|
- provisioning_status
|
||||||
|
- tags
|
||||||
|
- updated_at
|
||||||
|
- vip_address
|
||||||
|
- vip_network_id
|
||||||
|
- vip_port_id
|
||||||
|
- vip_qos_policy_id
|
||||||
|
- vip_subnet_id
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
url: "https://tarballs.openstack.org/octavia/test-images/test-only-amphora-x64-haproxy-ubuntu-bionic.qcow2"
|
url: "https://tarballs.openstack.org/octavia/test-images/test-only-amphora-x64-haproxy-ubuntu-bionic.qcow2"
|
||||||
dest: /tmp/test-only-amphora-x64-haproxy-ubuntu-bionic.qcow2
|
dest: /tmp/test-only-amphora-x64-haproxy-ubuntu-bionic.qcow2
|
||||||
|
|
||||||
- name: Upload Amphora image for Octavia to test load balancers
|
- name: Upload Amphora image for Octavia to test load-balancers
|
||||||
openstack.cloud.image:
|
openstack.cloud.image:
|
||||||
cloud: "{{ cloud }}"
|
cloud: "{{ cloud }}"
|
||||||
container_format: bare
|
container_format: bare
|
||||||
@@ -20,17 +20,33 @@
|
|||||||
tags:
|
tags:
|
||||||
- amphora
|
- amphora
|
||||||
|
|
||||||
- name: Create network {{ network_name }} for LB
|
- name: Create external network
|
||||||
openstack.cloud.network:
|
openstack.cloud.network:
|
||||||
cloud: "{{ cloud }}"
|
cloud: "{{ cloud }}"
|
||||||
name: "{{ network_name }}"
|
external: true
|
||||||
|
name: ansible_external_network
|
||||||
|
state: present
|
||||||
|
register: external_network
|
||||||
|
|
||||||
|
- name: Create external subnet
|
||||||
|
openstack.cloud.subnet:
|
||||||
|
cidr: 10.6.6.0/24
|
||||||
|
cloud: "{{ cloud }}"
|
||||||
|
name: ansible_external_subnet
|
||||||
|
network_name: ansible_external_network
|
||||||
state: present
|
state: present
|
||||||
|
|
||||||
- name: Create subnet {{ subnet_name }} on network {{ network_name }} for LB
|
- name: Create internal network
|
||||||
|
openstack.cloud.network:
|
||||||
|
cloud: "{{ cloud }}"
|
||||||
|
name: ansible_internal_network
|
||||||
|
state: present
|
||||||
|
|
||||||
|
- name: Create internal subnet
|
||||||
openstack.cloud.subnet:
|
openstack.cloud.subnet:
|
||||||
cloud: "{{ cloud }}"
|
cloud: "{{ cloud }}"
|
||||||
network_name: "{{ network_name }}"
|
network_name: ansible_internal_network
|
||||||
name: "{{ subnet_name }}"
|
name: ansible_internal_subnet
|
||||||
state: present
|
state: present
|
||||||
enable_dhcp: true
|
enable_dhcp: true
|
||||||
dns_nameservers:
|
dns_nameservers:
|
||||||
@@ -41,30 +57,228 @@
|
|||||||
allocation_pool_start: 192.168.0.2
|
allocation_pool_start: 192.168.0.2
|
||||||
allocation_pool_end: 192.168.0.254
|
allocation_pool_end: 192.168.0.254
|
||||||
|
|
||||||
- name: Create loadbalancer - generic
|
- name: Create router 1
|
||||||
|
openstack.cloud.router:
|
||||||
|
cloud: "{{ cloud }}"
|
||||||
|
external_fixed_ips:
|
||||||
|
- subnet: ansible_external_subnet
|
||||||
|
ip: 10.6.6.10
|
||||||
|
interfaces:
|
||||||
|
- net: ansible_internal_network
|
||||||
|
subnet: ansible_internal_subnet
|
||||||
|
portip: 192.168.0.1
|
||||||
|
name: ansible_router1
|
||||||
|
network: ansible_external_network
|
||||||
|
state: present
|
||||||
|
|
||||||
|
- name: Create load-balancer
|
||||||
openstack.cloud.loadbalancer:
|
openstack.cloud.loadbalancer:
|
||||||
cloud: "{{ cloud }}"
|
cloud: "{{ cloud }}"
|
||||||
state: present
|
state: present
|
||||||
name: "{{ lb_name }}"
|
name: ansible_lb
|
||||||
vip_subnet: "{{ subnet_name }}"
|
vip_subnet: ansible_internal_subnet
|
||||||
timeout: 450
|
timeout: 1200
|
||||||
|
register: load_balancer
|
||||||
|
|
||||||
- name: Delete loadbalancer
|
- name: Assert return values of loadbalancer module
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
# allow new fields to be introduced but prevent fields from being removed
|
||||||
|
- expected_fields|difference(load_balancer.load_balancer.keys())|length == 0
|
||||||
|
|
||||||
|
- name: Create load-balancer again
|
||||||
openstack.cloud.loadbalancer:
|
openstack.cloud.loadbalancer:
|
||||||
cloud: "{{ cloud }}"
|
cloud: "{{ cloud }}"
|
||||||
|
state: present
|
||||||
|
name: ansible_lb
|
||||||
|
vip_subnet: ansible_internal_subnet
|
||||||
|
timeout: 1200
|
||||||
|
register: load_balancer
|
||||||
|
|
||||||
|
- name: Assert return values of loadbalancer module
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- load_balancer is not changed
|
||||||
|
|
||||||
|
- name: Update load-balancer description
|
||||||
|
openstack.cloud.loadbalancer:
|
||||||
|
cloud: "{{ cloud }}"
|
||||||
|
description: "Ansible load-balancer"
|
||||||
|
state: present
|
||||||
|
name: ansible_lb
|
||||||
|
vip_subnet: ansible_internal_subnet
|
||||||
|
timeout: 1200
|
||||||
|
register: load_balancer
|
||||||
|
|
||||||
|
- name: Assert return values of loadbalancer module
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- load_balancer.load_balancer.description == "Ansible load-balancer"
|
||||||
|
|
||||||
|
- name: Delete load-balancer
|
||||||
|
openstack.cloud.loadbalancer:
|
||||||
|
cloud: "{{ cloud }}"
|
||||||
|
name: ansible_lb
|
||||||
state: absent
|
state: absent
|
||||||
name: "{{ lb_name }}"
|
|
||||||
timeout: 150
|
timeout: 150
|
||||||
|
|
||||||
- name: Delete subnet {{ subnet_name }} on network {{ network_name }}
|
- name: Create load-balancer with floating ip address
|
||||||
openstack.cloud.subnet:
|
openstack.cloud.loadbalancer:
|
||||||
|
assign_floating_ip: true
|
||||||
cloud: "{{ cloud }}"
|
cloud: "{{ cloud }}"
|
||||||
network_name: "{{ network_name }}"
|
# Help Octavia to find a external network which is connected to ansible_internal_subnet via a router
|
||||||
name: "{{ subnet_name }}"
|
floating_ip_network: ansible_external_network
|
||||||
|
name: ansible_lb
|
||||||
|
state: present
|
||||||
|
timeout: 1200
|
||||||
|
vip_subnet: ansible_internal_subnet
|
||||||
|
register: load_balancer
|
||||||
|
|
||||||
|
- name: Assert return values of loadbalancer module
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- "'floating_ip' in load_balancer.keys()"
|
||||||
|
- load_balancer.load_balancer.vip_address == load_balancer.floating_ip.fixed_ip_address
|
||||||
|
|
||||||
|
- name: Delete load-balancer with floating ip address
|
||||||
|
openstack.cloud.loadbalancer:
|
||||||
|
cloud: "{{ cloud }}"
|
||||||
|
delete_floating_ip: true
|
||||||
|
name: ansible_lb
|
||||||
|
state: absent
|
||||||
|
timeout: 150
|
||||||
|
|
||||||
|
- name: List all floating ips
|
||||||
|
openstack.cloud.floating_ip_info:
|
||||||
|
cloud: "{{ cloud }}"
|
||||||
|
register: floating_ips
|
||||||
|
|
||||||
|
- name: Assert load-balancer's floating ip has been deleted
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- load_balancer.floating_ip.floating_ip_address not in
|
||||||
|
floating_ips.floating_ips|map(attribute='floating_ip_address')|sort|list
|
||||||
|
|
||||||
|
- name: Create load-balancer with floating ip address from specific network
|
||||||
|
openstack.cloud.loadbalancer:
|
||||||
|
assign_floating_ip: true
|
||||||
|
cloud: "{{ cloud }}"
|
||||||
|
floating_ip_network: ansible_external_network
|
||||||
|
name: ansible_lb
|
||||||
|
state: present
|
||||||
|
timeout: 1200
|
||||||
|
vip_subnet: ansible_internal_subnet
|
||||||
|
register: load_balancer
|
||||||
|
|
||||||
|
- name: Assert return values of loadbalancer module
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- load_balancer.floating_ip.floating_network_id == external_network.network.id
|
||||||
|
|
||||||
|
- name: Create load-balancer with floating ip address from specific network again
|
||||||
|
openstack.cloud.loadbalancer:
|
||||||
|
assign_floating_ip: true
|
||||||
|
cloud: "{{ cloud }}"
|
||||||
|
floating_ip_network: ansible_external_network
|
||||||
|
name: ansible_lb
|
||||||
|
state: present
|
||||||
|
timeout: 1200
|
||||||
|
vip_subnet: ansible_internal_subnet
|
||||||
|
register: load_balancer
|
||||||
|
|
||||||
|
- name: Assert return values of loadbalancer module
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- load_balancer is not changed
|
||||||
|
|
||||||
|
# TODO: Replace with appropriate Ansible module once available
|
||||||
|
- name: Disassociate floating ip from load-balancer
|
||||||
|
command: >
|
||||||
|
openstack --os-cloud={{ cloud }} floating ip unset --port {{ load_balancer.floating_ip.floating_ip_address }}
|
||||||
|
|
||||||
|
- name: Reassign floating ip address to load-balancer
|
||||||
|
openstack.cloud.loadbalancer:
|
||||||
|
assign_floating_ip: true
|
||||||
|
cloud: "{{ cloud }}"
|
||||||
|
floating_ip_network: ansible_external_network
|
||||||
|
name: ansible_lb
|
||||||
|
state: present
|
||||||
|
timeout: 1200
|
||||||
|
vip_subnet: ansible_internal_subnet
|
||||||
|
register: load_balancer2
|
||||||
|
|
||||||
|
- name: Assert return values of loadbalancer module
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- load_balancer2.floating_ip.floating_network_id == external_network.network.id
|
||||||
|
- load_balancer.floating_ip.floating_ip_address == load_balancer2.floating_ip.floating_ip_address
|
||||||
|
|
||||||
|
- name: Reassign specific floating ip address to load-balancer
|
||||||
|
openstack.cloud.loadbalancer:
|
||||||
|
assign_floating_ip: true
|
||||||
|
cloud: "{{ cloud }}"
|
||||||
|
floating_ip_address: 10.6.6.42
|
||||||
|
floating_ip_network: ansible_external_network
|
||||||
|
name: ansible_lb
|
||||||
|
state: present
|
||||||
|
timeout: 1200
|
||||||
|
vip_subnet: ansible_internal_subnet
|
||||||
|
register: load_balancer
|
||||||
|
|
||||||
|
- name: Assert return values of loadbalancer module
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- load_balancer.floating_ip.floating_network_id == external_network.network.id
|
||||||
|
- load_balancer.floating_ip.floating_ip_address == '10.6.6.42'
|
||||||
|
|
||||||
|
- name: Disassociate floating ip address with load-balancer
|
||||||
|
openstack.cloud.loadbalancer:
|
||||||
|
cloud: "{{ cloud }}"
|
||||||
|
name: ansible_lb
|
||||||
|
state: present
|
||||||
|
timeout: 1200
|
||||||
|
vip_subnet: ansible_internal_subnet
|
||||||
|
register: load_balancer
|
||||||
|
|
||||||
|
- name: Assert return values of loadbalancer module
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- "'floating_ip' not in load_balancer.keys()"
|
||||||
|
|
||||||
|
- name: Delete load-balancer
|
||||||
|
openstack.cloud.loadbalancer:
|
||||||
|
cloud: "{{ cloud }}"
|
||||||
|
delete_floating_ip: true
|
||||||
|
name: ansible_lb
|
||||||
|
state: absent
|
||||||
|
timeout: 150
|
||||||
|
|
||||||
|
- name: Delete router 1
|
||||||
|
openstack.cloud.router:
|
||||||
|
cloud: "{{ cloud }}"
|
||||||
|
name: ansible_router1
|
||||||
state: absent
|
state: absent
|
||||||
|
|
||||||
- name: Delete network {{ network_name }} of LB
|
- name: Delete internal subnet
|
||||||
|
openstack.cloud.subnet:
|
||||||
|
cloud: "{{ cloud }}"
|
||||||
|
name: ansible_internal_subnet
|
||||||
|
state: absent
|
||||||
|
|
||||||
|
- name: Delete internal network
|
||||||
openstack.cloud.network:
|
openstack.cloud.network:
|
||||||
cloud: "{{ cloud }}"
|
cloud: "{{ cloud }}"
|
||||||
name: "{{ network_name }}"
|
name: ansible_internal_network
|
||||||
|
state: absent
|
||||||
|
|
||||||
|
- name: Delete external subnet
|
||||||
|
openstack.cloud.subnet:
|
||||||
|
cloud: "{{ cloud }}"
|
||||||
|
name: ansible_external_subnet
|
||||||
|
state: absent
|
||||||
|
|
||||||
|
- name: Delete external network
|
||||||
|
openstack.cloud.network:
|
||||||
|
cloud: "{{ cloud }}"
|
||||||
|
name: ansible_external_network
|
||||||
state: absent
|
state: absent
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user