-
Notifications
You must be signed in to change notification settings - Fork 2
/
cloud-init.tf
134 lines (130 loc) · 5.14 KB
/
cloud-init.tf
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
124
125
126
127
128
129
130
131
132
133
134
resource "proxmox_cloud_init_disk" "cp_ci" {
name = "${var.proxmox_vm_name}-cp-${count.index + 1}-cloud-init"
pve_node = var.proxmox_target_node
storage = var.proxmox_cloudinit_pool
count = var.vm_count
vendor_data = <<EOT
EOT
meta_data = <<EOT
instance_id: ${sha1("${var.proxmox_vm_name}-cp-${count.index + 1}")}
EOT
user_data = <<EOT
#cloud-config
package_update: false
package_upgrade: false
locale: "en_US.UTF-8"
keyboard:
layout: "hu"
variant: ""
timezone: "Europa/Budapest"
users:
- name: ${var.cloud_init_username}
groups: sudo
shell: /bin/bash
sudo: ['ALL=(ALL) NOPASSWD:ALL']
ssh_authorized_keys:
- ${var.cloud_init_pub_ssh_key}
lock_passwd: false
passwd: ${var.cloud_init_password}
ssh_pwauth: true
preserve_hostname: false
hostname: ${var.proxmox_vm_name}-cp-${count.index + 1}
fqdn: ${var.proxmox_vm_name}-cp-${count.index + 1}.${var.cloud_init_domain}
write_files:
- path: /usr/local/bin/update-issue.sh
permissions: '0755'
content: |
#!/bin/bash
echo "Welcome to $(lsb_release -d -s)" > /etc/issue
echo "" >> /etc/issue
for interface in $(ls /sys/class/net | grep -v lo); do
IP=$(ip addr show $interface | grep 'inet ' | awk '{print $2}')
echo "$interface: $IP" >> /etc/issue
done
echo "" >> /etc/issue
systemctl restart getty@tty1.service
- path: /usr/local/share/ca-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XU4IV5SmHkQDPDx27DTrhJ9Wfml8ZfOz9oGLWpF8FSI+i5JbTkyu1c+2xN6Z
WZfm2rHRGf87Y+qG5K/QPT1dCqNRtNCb67+U/qZZF83j+Gr0p5HMseuq5N8q5V93
jJWp7PpOvPUJHt4rqutKQL0fnhrnMTnESpuyJw==
-----END CERTIFICATE-----
packages:
- qemu-guest-agent
bootcmd:
- sysctl -w net.ipv6.conf.all.disable_ipv6=1
- sysctl -w net.ipv6.conf.default.disable_ipv6=1
- sysctl -w net.ipv4.ip_forward=1
- sysctl -w vm.swappiness=1
- sysctl -w vm.panic_on_oom=0
- sysctl -w vm.overcommit_memory=1
- sysctl -w kernel.panic=10
- sysctl -w kernel.panic_on_oops=1
- systemctl disable --now ufw.service
runcmd:
- systemctl start ssh.service
- systemctl start qemu-guest-agent.service
- /usr/local/bin/update-issue.sh
- update-ca-certificates
EOT
network_config = <<EOT
#cloud-config
network:
version: 2
ethernets:
enp6s18:
dhcp4: no
addresses:
- ${var.cloud_init_ip_pool0}${count.index + var.cloud_init_ip_increase}/${var.cloud_init_netmask}
nameservers:
addresses: [192.168.2.10, 192.168.2.5]
search: [adamkoro.local]
routes:
- to: 0.0.0.0/0
via: ${var.cloud_init_gateway0}
metric: 50
enp6s19:
dhcp4: no
addresses:
- ${var.cloud_init_ip_pool1}${count.index + var.cloud_init_ip_increase}/${var.cloud_init_netmask}
nameservers:
addresses: [${var.cloud_init_gateway1}]
routes:
- to: 0.0.0.0/0
via: ${var.cloud_init_gateway1}
metric: 100
EOT
}