forked from kubealex/libvirt-k8s-provisioner
-
Notifications
You must be signed in to change notification settings - Fork 0
/
06_provisioning_loadbalancer.yml
57 lines (52 loc) · 1.95 KB
/
06_provisioning_loadbalancer.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
- name: This play provisions loadbalancer VM for control plane
hosts: vm_host
vars_files:
- vars/k8s_cluster.yml
tasks:
- name: Provision loadbalancer vm
block:
- terraform:
project_path: "files/terraform/loadbalancer"
force_init: true
variables:
hostname: "{{ k8s.cluster_name }}-loadbalancer"
domain: "{{ k8s.network.domain }}"
os: "{{ 'ubuntu' if k8s.cluster_os == 'Ubuntu' else 'centos' }}"
libvirt_network: "{{ k8s.cluster_name }}"
libvirt_pool: "{{ k8s.cluster_name }}"
os_image_name: "{{ image_name }}.qcow2"
state: present
become: true
register: output_loadbalancer
- name: Add loadbalancer to inventory
add_host:
hostname: '{{ k8s.cluster_name }}-loadbalancer.{{ k8s.network.domain }}'
node_hostname: '{{ k8s.cluster_name }}-loadbalancer.{{ k8s.network.domain }}'
node_mac: "{{ output_loadbalancer.outputs.macs.value[0]|lower }}"
node_fqdn: "{{ k8s.cluster_name }}-loadbalancer.{{ k8s.network.domain }}"
ansible_ssh_private_key_file: "id_rsa"
ansible_user: kube
ansible_ssh_common_args: '-o StrictHostKeyChecking=no'
groups:
- "loadbalancer"
- name: Ensure to clean known_hosts
known_hosts:
host: "{{ item }}"
path: ~/.ssh/known_hosts
state: absent
loop: "{{ groups['loadbalancer'] }}"
become: true
when: k8s.control_plane.vms > 1
- name: Check connection to loadbalancer
hosts: loadbalancer
gather_facts: no
vars_files:
- vars/k8s_cluster.yml
tasks:
- block:
- name: Wait 600 seconds for target connection to become reachable/usable
wait_for_connection:
timeout: 600
delay: 0
- ping:
when: k8s.control_plane.vms > 1