Skip to content

Commit

Permalink
Updating existing listeners instead of recreating them in tuoni role
Browse files Browse the repository at this point in the history
  • Loading branch information
AllRWeak authored and Lauri-L committed Nov 21, 2024
1 parent 3e1b74d commit d68be51
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions nova/core/roles/tuoni/tasks/listeners.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,35 +11,41 @@
validate_certs: false
register: tuoni_existing_listeners

- name: Deleting existing listeners...
- name: Creating following listeners...
ansible.builtin.uri:
url: https://{{ tuoni_fqdn }}:8443/api/v1/listeners/{{ item.id }}
method: DELETE
url: https://{{ tuoni_fqdn }}:8443/api/v1/listeners
method: POST
headers:
Authorization: Bearer {{ tuoni_api_token.content }}
force_basic_auth: true
body_format: json
status_code: 200
validate_certs: false
loop: "{{ tuoni_existing_listeners.json.values() | list }}"
body: "{{ item }}"
loop: "{{ tuoni_listeners }}"
loop_control:
label: "{{ item.name }}"
when: tuoni_existing_listeners.json.values() | list != []
when: item.name not in tuoni_existing_listeners.json.values() | map(attribute='name')

- name: Creating following listeners...
- name: Updating following listeners...
ansible.builtin.uri:
url: https://{{ tuoni_fqdn }}:8443/api/v1/listeners
method: POST
url: https://{{ tuoni_fqdn }}:8443/api/v1/listeners/{{ tuoni_existing_listeners.json.values()
| selectattr('name', 'equalto', item.name) | map(attribute='id') | first }}
method: PATCH
headers:
Authorization: Bearer {{ tuoni_api_token.content }}
force_basic_auth: true
body_format: json
status_code: 200
validate_certs: false
body: "{{ item }}"
body:
name: "{{ item.name }}"
configuration: "{{ item.configuration }}"
loop: "{{ tuoni_listeners }}"
loop_control:
label: "{{ item.name }}"
index_var: listener_index
when: item.name in tuoni_existing_listeners.json.values() | list | map(attribute='name')

- name: Re-listing all listeners...
ansible.builtin.uri:
Expand Down

0 comments on commit d68be51

Please sign in to comment.