forked from UCCNetsoc/NaC
-
Notifications
You must be signed in to change notification settings - Fork 0
/
create-docker-nodes.yml
114 lines (111 loc) · 3.87 KB
/
create-docker-nodes.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
---
- name: "Ensure Docker Nodes"
hosts: proxmox_hosts
roles:
# Manager VM
- role: proxmox-infra-cloudinit-vm
when: "ansible_play_hosts_all.index(inventory_hostname) < 5"
vars:
vm:
name: "manager{{ ansible_play_hosts_all.index(inventory_hostname) }}.docker.vm.netsoc.co"
clone: "netsoc-ubuntu-server-{{ inventory_hostname }}"
timeout: 300
description: |
groups:
- vm
- docker
- docker_managers
vars:
ansible_ssh_private_key_file: "/root/NaC-repo/keys/docker/id_rsa"
net:
net0: "virtio,bridge=vmbr0,tag=30"
resize_disks:
virtio0: "+5G"
cores: 4
memory: 4096
cloudinit:
metadata: ""
userdata: |
#cloud-config
users:
- name: netsoc
gecos: Netsoc Management User
primary_group: netsoc
sudo: ALL=(ALL) NOPASSWD:ALL
ssh_authorized_keys:
- {{ ssh_key_sig }}
preserve_hostname: false
manage_etc_hosts: true
fqdn: manager{{ ansible_play_hosts_all.index(inventory_hostname) }}.docker.vm.netsoc.co
networkconfig: |
version: 2
ethernets:
30:
match:
name: "en*"
addresses:
- {{ ip_allocation.docker_manager_base | ipmath(ansible_play_hosts_all.index(inventory_hostname)) }}/24
gateway4: 10.0.30.1
nameservers:
search: {{ ip_allocation.search }}
addresses: {{ ip_allocation.nameservers }}
wait_for_ssh: "{{ ip_allocation.docker_manager_base | ipmath(ansible_play_hosts_all.index(inventory_hostname)) }}"
# Worker VM
- role: proxmox-infra-cloudinit-vm
vars:
vm:
name: "worker{{ ansible_play_hosts_all.index(inventory_hostname) }}.docker.vm.netsoc.co"
clone: "netsoc-ubuntu-server-{{ inventory_hostname }}"
timeout: 300
description: |
groups:
- vm
- docker
- docker_workers
vars:
ansible_ssh_private_key_file: "/root/NaC-repo/keys/docker/id_rsa"
net:
net0: "virtio,bridge=vmbr0,tag=30"
resize_disks:
virtio0: "+5G"
cores: 4
memory: 4096
cloudinit:
metadata: ""
userdata: |
#cloud-config
users:
- name: netsoc
gecos: Netsoc Management User
primary_group: netsoc
sudo: ALL=(ALL) NOPASSWD:ALL
ssh_authorized_keys:
- {{ ssh_key_sig }}
preserve_hostname: false
manage_etc_hosts: true
fqdn: worker{{ ansible_play_hosts_all.index(inventory_hostname) }}.docker.vm.netsoc.co
networkconfig: |
version: 2
ethernets:
30:
match:
name: "en*"
addresses:
- {{ ip_allocation.docker_worker_base | ipmath(ansible_play_hosts_all.index(inventory_hostname)) }}/24
gateway4: 10.0.30.1
nameservers:
search: {{ ip_allocation.search }}
addresses: {{ ip_allocation.nameservers }}
wait_for_ssh: "{{ ip_allocation.docker_worker_base | ipmath(ansible_play_hosts_all.index(inventory_hostname)) }}"
vars:
ssh_key_sig: "{{ lookup('file', './keys/docker/id_rsa.pub') }}"
vars_files:
- vars/ip_allocation.yml
- vars/proxmox.yml
- vars/secrets.yml
- name: "Reload inventory to pull new VMs"
hosts: 127.0.0.1
connection: local
tasks:
- meta: refresh_inventory
- import_playbook: "provision-docker-nodes.yml"