TripleO Ansible project repository. Contains playbooks for use with TripleO OpenStack deployments.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
tripleo-ansible/tripleo_ansible/roles/octavia_controller_post_config/tasks/main.yml

103 lines
2.8 KiB

---
- name: Show debug information
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%}"
- name: create ip list (remove the last two characters)
set_fact:
o_hm_ip_list: "{{ o_hm_ip_list[:-2] }}"
- 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: get list of running octavia services
become: true
become_user: root
shell: |
systemctl is-active --quiet {{ item }} && echo {{ item }}
ignore_errors: true
register: octavia_active_services
loop:
- tripleo_octavia_api
- tripleo_octavia_worker
- tripleo_octavia_health_manager
- tripleo_octavia_housekeeping
- tripleo_octavia_driver_agent
when:
- container_cli == "podman"
- octavia_config_updated
- name: restart octavia services
become: true
become_user: root
systemd:
name: "{{ item.stdout }}"
state: restarted
loop: "{{ octavia_active_services.results }}"
when:
- container_cli == "podman"
- octavia_config_updated
- item.rc == 0
- name: get list of running octavia containers
become: true
become_user: root
shell: |
"{{ container_cli }}" ps -f name=octavia -q
register: running_octavia_containers
when:
- container_cli == "docker"
- octavia_config_updated
- name: restart octavia containers
become: true
become_user: root
shell: "{{ container_cli }} restart {{ running_octavia_containers.stdout_lines|join(' ') }}"
when:
- container_cli == "docker"
- octavia_config_updated
- (running_octavia_containers.stdout|length) > 0
- name: remove directory /etc/octavia/conf.d/common (LP#1836074)
file:
path: "{{ octavia_confd_prefix }}/etc/octavia/conf.d/common"
state: absent