forked from openshift/installer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdown-load-balancers.yaml
76 lines (67 loc) · 2.74 KB
/
down-load-balancers.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# Required Python packages:
#
# ansible
# openstackcli
# openstacksdk
- import_playbook: common.yaml
- hosts: all
gather_facts: no
tasks:
- name: 'Get an auth token'
os_auth:
register: cloud
when: os_networking_type == "Kuryr"
- name: 'List octavia versions'
uri:
method: GET
headers:
X-Auth-Token: "{{ cloud.ansible_facts.auth_token }}"
Content-Type: 'application/json'
url: "{{ cloud.ansible_facts.service_catalog | selectattr('name', 'match', 'octavia') | first | json_query('endpoints') | selectattr('interface', 'match', 'public') | first | json_query('url') }}/"
register: octavia_versions
when: os_networking_type == "Kuryr"
- set_fact:
versions: "{{ octavia_versions.json.versions | selectattr('id', 'match', 'v2.5') | map(attribute='id') | list }}"
when: os_networking_type == "Kuryr"
- name: 'List tagged loadbalancers'
uri:
method: GET
headers:
X-Auth-Token: "{{ cloud.ansible_facts.auth_token }}"
url: "{{ cloud.ansible_facts.service_catalog | selectattr('name', 'match', 'octavia') | first | json_query('endpoints') | selectattr('interface', 'match', 'public') | first | json_query('url') }}/v2.0/lbaas/loadbalancers?tags={{cluster_id_tag}}"
when:
- os_networking_type == "Kuryr"
- versions | length > 0
register: lbs_tagged
# NOTE: Kuryr creates an Octavia load balancer
# for each service present on the cluster. Let's make
# sure to remove the resources generated.
- name: 'Remove the cluster load balancers'
command:
cmd: "openstack loadbalancer delete --cascade {{ item.id }}"
with_items: "{{ lbs_tagged.json.loadbalancers }}"
when:
- os_networking_type == "Kuryr"
- versions | length > 0
- '"PENDING" not in item.provisioning_status'
- name: 'List loadbalancers tagged on description'
uri:
method: GET
headers:
X-Auth-Token: "{{ cloud.ansible_facts.auth_token }}"
url: "{{ cloud.ansible_facts.service_catalog | selectattr('name', 'match', 'octavia') | first | json_query('endpoints') | selectattr('interface', 'match', 'public') | first | json_query('url') }}/v2.0/lbaas/loadbalancers?description={{cluster_id_tag}}"
when:
- os_networking_type == "Kuryr"
- versions | length == 0
register: lbs_description
# NOTE: Kuryr creates an Octavia load balancer
# for each service present on the cluster. Let's make
# sure to remove the resources generated.
- name: 'Remove the cluster load balancers'
command:
cmd: "openstack loadbalancer delete --cascade {{ item.id }}"
with_items: "{{ lbs_description.json.loadbalancers }}"
when:
- os_networking_type == "Kuryr"
- versions | length == 0
- '"PENDING" not in item.provisioning_status'