forked from kubealex/libvirt-k8s-provisioner
-
Notifications
You must be signed in to change notification settings - Fork 0
/
06_provisioning_nfs.yml
63 lines (57 loc) · 2.12 KB
/
06_provisioning_nfs.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
58
59
60
61
62
63
- name: This play provisions NFS Server VM for the cluster
hosts: vm_host
become: true
vars_files:
- vars/k8s_cluster.yml
tasks:
- name: Provision NFS Server VM
block:
- community.general.terraform:
project_path: "clusters/{{ k8s.cluster_name }}/nfs"
force_init: true
variables:
hostname: "{{ k8s.cluster_name }}-nfs"
domain: "{{ k8s.network.domain }}"
nfs_fsSize: "{{ k8s.storage.nfs_fsSize }}"
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
register: output_nfs
- name: Add NFS server to inventory
add_host:
hostname: '{{ k8s.cluster_name }}-nfs.{{ k8s.network.domain }}'
ansible_ssh_private_key_file: "clusters/{{ k8s.cluster_name }}/id_rsa"
ansible_user: kube
ansible_ssh_common_args: '-o StrictHostKeyChecking=no'
groups:
- "nfs"
- name: Ensure to clean known_hosts
known_hosts:
host: "{{ item }}"
path: ~/.ssh/known_hosts
state: absent
loop: "{{ groups['nfs'] }}"
when: k8s.storage.nfs_enabled
- name: Check connection to NFS server
hosts: nfs
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:
- name: Extract some facts from setup
setup:
register: nfs_facts
- set_fact:
host_ip: "{{ nfs_facts.ansible_facts.ansible_default_ipv4.address }}"
host_interface: "{{ nfs_facts.ansible_facts.ansible_default_ipv4.interface }}"
host_mac: "{{ nfs_facts.ansible_facts.ansible_default_ipv4.macaddress }}"
host_fqdn: "{{ nfs_facts.ansible_facts.ansible_fqdn }}"
when: k8s.storage.nfs_enabled