Add loadbalancer task file

This commit is contained in:
Adrien Reslinger 2019-07-16 19:31:16 +02:00
parent c541ea67b3
commit 2019ac846d

32
tasks/load_balancer.yml Normal file
View file

@ -0,0 +1,32 @@
---
- name: Install needed packages
package:
name: "{{ item }}"
state: latest
update_cache: yes
with_items:
- keepalived
- curl
notify: Restart keepalived
- name: Install check_apiserver.sh script for keepalived
template:
src: etc/keepalived/check_apiserver.sh.j2
dest: /etc/keepalived/check_apiserver.sh
- name: Install keepalived config file
template:
src: etc/keepalived/keepalived.conf.j2
dest: /etc/keepalived/keepalived.conf
with_items:
- { lbip: '{{ lbip_kubeapiserver }}', state: "MASTER", interface: '{{ lb_interface }}', auth_pass: '{{ lb_auth_pass }}' }
when:
- groups['Kube-masters'][0] == ansible_hostname
notify: Restart keepalived
- name: Install keepalived config file
template:
src: etc/keepalived/keepalived.conf.j2
dest: /etc/keepalived/keepalived.conf
with_items:
- { lbip: '{{ lbip_kubeapiserver }}', state: "BACKUP", interface: '{{ lb_interface }}', auth_pass: '{{ lb_auth_pass }}' }
when:
- not groups['Kube-masters'][0] == ansible_hostname
notify: Restart keepalived