diff --git a/tasks/load_balancer.yml b/tasks/load_balancer.yml new file mode 100644 index 0000000..5fbe33c --- /dev/null +++ b/tasks/load_balancer.yml @@ -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