This repository has been archived by the owner on Jun 13, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 72
/
config.yml
123 lines (107 loc) · 3.5 KB
/
config.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
# Desription: Create a virtual environment using Lago.
# The specification of the environment can be found in LagoInitFile.yaml
#
# PARAMETERS:
# inventory_file: Path to the inventory file,
# Lago will populate it with the vms details.
#
# prefix: Where to create the lago environment
- hosts: localhost
connection: local
gather_facts: False
vars_files:
- "{{ playbook_dir }}/defaults/main.yml"
tasks:
- name: Set prefix
set_fact:
prefix: "{{ prefix | default('.lago') }}"
lago_init_file: "{{ playbook_dir }}/LagoInitFile.yml"
- name: Render LagoInitFile
template:
src: "{{ lago_init_file }}.j2"
dest: "{{ lago_init_file }}"
- name: Init Lago env
command:
lago init --template-repo-path "{{ lago_template_repo }}" "{{ prefix }}" "{{ lago_init_file }}"
args:
creates: "{{ prefix }}/default/uuid"
- name: Remove user defined settings from inventory
register: remove_user_settings
blockinfile:
path: "{{ inventory_file }}"
marker: "# {mark} CUSTOM SETTINGS"
state: absent
- name: Render inventory
when: remove_user_settings.changed
block:
- name: Create Ansible Hosts file from Lago env
shell: lago --workdir "{{ prefix }}" ansible_hosts >> "{{ inventory_file }}"
- name: Normalize inventory file
replace:
path: "{{ inventory_file }}"
regexp: '\[groups=(.*)\]'
replace: '[\1]'
- name: Refresh inventory
meta: refresh_inventory
- name: Start Lago env
command: lago --workdir "{{ prefix }}" start
- hosts: all
any_errors_fatal: True
gather_facts: no
tasks:
- name: Wait for ssh
wait_for:
port: 22
host: "{{ ansible_host }}"
search_regex: OpenSSH
delay: 10
delegate_to: localhost
connection: local
- name: Mount container storage
shell: |
disk="/dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_2"
mount_path="/var/lib/containers"
findmnt --source "$disk" --target "$mount_path" && exit 0
mkdir -p "$mount_path"
mkfs.xfs "$disk"
echo -e "${disk}\t${mount_path}\txfs\tdefaults\t0 0" >> /etc/fstab
mount "$disk" "$mount_path"
- name: Set gluster disk idx
set_fact:
gluster_disk_idx: "{{ '4' if inventory_hostname == groups['masters'][0] else '3' }}"
- name: Set gluster disk path
set_fact:
glusterfs_devices: ["/dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_{{ gluster_disk_idx }}"]
when:
- storage_role is defined
- storage_role == 'storage-glusterfs'
- hosts: nfs
any_errors_fatal: True
tasks:
- name: Mount nfs storage
shell: |
disk="/dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_3"
mount_path="/opt"
findmnt --source "$disk" --target "$mount_path" && exit 0
mkdir -p "$mount_path"
mkfs.ext4 -F "$disk"
echo -e "${disk}\t${mount_path}\text4\tdefaults\t0 0" >> /etc/fstab
mount "$disk" "$mount_path"
- hosts: lago-node0
tasks:
- name: Mark lago-node0 as infra
set_fact:
openshift_node_labels:
region: infra
zone: default
# For Openshift 3.10
- hosts: nodes
tasks:
- name: Set openshift_node_group_name for nodes
set_fact:
openshift_node_group_name: node-config-infra-compute
- hosts: masters
tasks:
- name: Set openshift_node_group_name for master
set_fact:
openshift_node_group_name: node-config-master