tripleo-common/playbooks/roles/octavia-controller-post-config/tasks/main.yml

55 lines
1.9 KiB
YAML

- debug:
msg: "Octavia services will be restarted because of updated configuration"
when: octavia_config_updated
- name: create ip list
set_fact:
o_hm_ip_list: "{% for octavia_node in groups['octavia_nodes'] %}{{ hostvars[octavia_node].o_hm_ip }}, {%endfor%}"
- set_fact:
o_hm_ip_list: "{{ o_hm_ip_list[:-2] }}" #remove the last two characters
- name: read the current IP list
become: true
become_user: root
shell: |
awk -F '=' -e '/^controller_ip_port_list/ { print $2; }' "{{octavia_confd_prefix}}/etc/octavia/post-deploy.conf"
register: config_contents
failed_when: config_contents.rc != 0
changed_when: false
ignore_errors: true
- name: retrieve current ip list
set_fact:
current_ip_list: "{{config_contents.stdout}}"
# This isn't perfect as they execution order will make them not match, but we can avoid a restart
# if things have stayed the same.
- name: check if ip list needs updating
set_fact:
octavia_config_updated: true
when: current_ip_list != o_hm_ip_list
- name: setting [health_manager]/controller_ip_port_list
become: true
become_user: root
ini_file:
section: "health_manager"
option: "controller_ip_port_list"
value: "{{ o_hm_ip_list }}"
path: "{{ octavia_confd_prefix }}/etc/octavia/post-deploy.conf"
selevel: s0
setype: svirt_sandbox_file_t
when: octavia_config_updated
- name: create a symbolic link conf.d/post-deploy -> post-deploy.conf (LP#1836074)
file:
src: "../../post-deploy.conf"
dest: "{{ octavia_confd_prefix }}/etc/octavia/conf.d/common/post-deploy.conf"
state: link
selevel: s0
setype: svirt_sandbox_file_t
- name: restart octavia containers
become: true
become_user: root
shell: "{{ container_cli }} restart $(sudo {{ container_cli }} ps -f name=octavia -q)"
when: octavia_config_updated