2019-04-04 10:54:41 +08:00
|
|
|
---
|
|
|
|
- name: install haproxy and keepalived
|
|
|
|
package:
|
|
|
|
name: ['haproxy', 'keepalived']
|
|
|
|
state: present
|
|
|
|
register: result
|
|
|
|
until: result is succeeded
|
|
|
|
|
|
|
|
- name: "generate haproxy configuration file: haproxy.cfg"
|
|
|
|
template:
|
|
|
|
src: haproxy.cfg.j2
|
|
|
|
dest: /etc/haproxy/haproxy.cfg
|
|
|
|
owner: "root"
|
|
|
|
group: "root"
|
|
|
|
mode: "0644"
|
|
|
|
validate: "haproxy -f %s -c"
|
|
|
|
notify:
|
|
|
|
- restart haproxy
|
|
|
|
|
|
|
|
- name: set_fact vip to vrrp_instance
|
|
|
|
set_fact:
|
2020-06-01 23:09:18 +08:00
|
|
|
vrrp_instances: "{{ vrrp_instances | default([]) | union([{ 'name': 'VI_' + index|string , 'vip': item, 'master': groups[rgwloadbalancer_group_name][index] }]) }}"
|
2019-04-04 10:54:41 +08:00
|
|
|
loop: "{{ virtual_ips | flatten(levels=1) }}"
|
2020-05-26 19:18:03 +08:00
|
|
|
loop_control:
|
|
|
|
index_var: index
|
2019-04-04 10:54:41 +08:00
|
|
|
|
|
|
|
- name: "generate keepalived: configuration file: keepalived.conf"
|
|
|
|
template:
|
|
|
|
src: keepalived.conf.j2
|
|
|
|
dest: /etc/keepalived/keepalived.conf
|
|
|
|
owner: "root"
|
|
|
|
group: "root"
|
|
|
|
mode: "0644"
|
|
|
|
notify:
|
|
|
|
- restart keepalived
|
2021-04-01 15:50:54 +08:00
|
|
|
|
|
|
|
- name: selinux related tasks
|
|
|
|
when: ansible_facts['os_family'] == 'RedHat'
|
|
|
|
block:
|
|
|
|
- name: set_fact rgw_ports
|
|
|
|
set_fact:
|
|
|
|
rgw_ports: "{{ rgw_ports | default([]) + [hostvars[item]['rgw_instances']['radosgw_frontend_port']] | unique }}"
|
|
|
|
with_items: "{{ groups.get(rgw_group_name, []) }}"
|
|
|
|
|
|
|
|
- name: add selinux rules
|
|
|
|
seport:
|
|
|
|
ports: "{{ rgw_ports }}"
|
|
|
|
proto: tcp
|
|
|
|
setype: http_port_t
|
|
|
|
state: present
|