haproxy-wi/app/scripts/ansible/roles/keepalived/tasks/install.yml

101 lines
2.2 KiB
YAML
Raw Normal View History

2019-11-06 15:15:41 +00:00
---
- name: check if Keepalived is installed
2019-11-28 16:39:24 +00:00
package_facts:
manager: "auto"
2019-11-06 15:15:41 +00:00
- name: install EPEL Repository
yum:
name: epel-release
state: latest
when:
- ansible_facts['os_family'] == "RedHat" or ansible_facts['os_family'] == 'CentOS'
- ansible_facts['distribution_major_version'] == '7'
ignore_errors: yes
environment:
http_proxy: "{{PROXY}}"
https_proxy: "{{PROXY}}"
2019-11-06 15:15:41 +00:00
- name: Install the latest version of Keepalived
package:
name: keepalived
2019-11-06 15:15:41 +00:00
state: present
when: "'keepalived' not in ansible_facts.packages"
2019-11-06 15:15:41 +00:00
environment:
http_proxy: "{{PROXY}}"
https_proxy: "{{PROXY}}"
- name: Ensure group "keepalived_script" exists
group:
name: keepalived_script
state: present
system: yes
- name: Add the user 'keepalived_script'
user:
name: keepalived_script
comment: User for keepalived_script
group: keepalived_script
shell: /sbin/nologin
create_home: no
system: yes
2019-11-06 15:15:41 +00:00
- name: Copy keepalived configuration in place.
template:
src: keepalived.conf.j2
dest: /etc/keepalived/keepalived.conf
mode: 0644
notify: restart keepalived
- name: test to see if selinux is running
command: getenforce
register: sestatus
changed_when: false
when: (ansible_facts['os_family'] == "RedHat" or ansible_facts['os_family'] == 'CentOS')
2019-11-06 15:15:41 +00:00
- name: Disble SELINUX in config
template:
src: ../../haproxy/templates/selinux.j2
dest: /etc/selinux/config
ignore_errors: yes
when:
- sestatus.stdout is defined
- '"Enforcing" in sestatus.stdout'
- name: Disble SELINUX in env
shell: setenforce 0 2> /dev/null
ignore_errors: yes
debugger: never
when:
- sestatus.stdout is defined
- '"Enforcing" in sestatus.stdout'
2019-11-06 15:15:41 +00:00
- name: Enable and start service keepalived
service:
name: keepalived
daemon_reload: yes
state: started
enabled: yes
ignore_errors: yes
- name: Enable net.ipv4.ip_forward
sysctl:
name: net.ipv4.ip_forward
value: '1'
sysctl_set: yes
state: present
reload: yes
- name: Add syn_flood tasks
include: ../../haproxy/tasks/syn_flood.yml
2019-11-28 16:39:24 +00:00
when: (SYN_FLOOD is defined) and (SYN_FLOOD|length > 0)