-
Notifications
You must be signed in to change notification settings - Fork 0
/
user-data.consul-bootstrap.txt
195 lines (176 loc) · 5.04 KB
/
user-data.consul-bootstrap.txt
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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
#cloud-config
apt_update: true
apt_upgrade: true
apt_reboot_if_required: true
manage_etc_hosts: localhost
ssh_authorized_keys:
- ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA6NF8iallvQVp22WDkTkyrtvp9eWW6A8YVr+kz4TjGYe7gHzIw+niNltGEFHzD8+v1I2YJ6oXevct1YeS0o9HZyN1Q9qgCgzUFtdOKLv6IedplqoPkcmF0aYet2PkEDo3MlTBckFXPITAMzF8dJSIFo9D8HfdOV0IAdx4O7PtixWKn5y2hMNG0zQPyUecp4pzC6kivAIhyfHilFR61RGL+GPXQ2MWZWFYbAGjyiYJnAmCP3NOTd0jMZEnDkbUvxhMmBYSdETk1rRgm+R4LOzFUGaHqHDLKLX+FIPKcF96hrucXzcWyLbIbEgE98OHlnVYCzRdK8jlqm8tehUc9c9WhQ== vagrant insecure public key
bootcmd:
- "ln -snf /run/resolvconf/resolv.conf /etc/resolv.conf"
groups:
- "sudo"
- "users"
users:
# The ubuntu/xenial64 Vagrant box uses the "ubuntu" user that seems to be
# created by a Cloud Config file which gets overwritten by this file, so
# creating the ubuntu user with the same settings as best as I can.
- name: "ubuntu"
gecos: "Ubuntu"
shell: "/bin/bash"
primary-group: "ubuntu"
groups:
- adm
- dialout
- cdrom
- floppy
- sudo
- audio
- dip
- video
- plugdev
- netdev
- lxd
sudo:
- "ALL=(ALL) NOPASSWD:ALL"
ssh_authorized_keys:
- "ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA6NF8iallvQVp22WDkTkyrtvp9eWW6A8YVr+kz4TjGYe7gHzIw+niNltGEFHzD8+v1I2YJ6oXevct1YeS0o9HZyN1Q9qgCgzUFtdOKLv6IedplqoPkcmF0aYet2PkEDo3MlTBckFXPITAMzF8dJSIFo9D8HfdOV0IAdx4O7PtixWKn5y2hMNG0zQPyUecp4pzC6kivAIhyfHilFR61RGL+GPXQ2MWZWFYbAGjyiYJnAmCP3NOTd0jMZEnDkbUvxhMmBYSdETk1rRgm+R4LOzFUGaHqHDLKLX+FIPKcF96hrucXzcWyLbIbEgE98OHlnVYCzRdK8jlqm8tehUc9c9WhQ== vagrant insecure public key"
- name: "vtse"
gecos: "foobar"
primary-group: "users"
groups:
- sudo
shell: "/bin/bash"
sudo:
- "ALL=(ALL) NOPASSWD:ALL"
ssh-import-id: "gh:vincetse"
apt_sources:
# ssh-import-id. get v5.6 cos v5.5 that comes with Xenial has a bug
# that only gets one ssh key from github.
- source: "ppa:ssh-import-id/ppa"
filename: "ssh_import_id.list"
# The modules that run in the 'init' stage
cloud_init_modules:
- migrator
- ubuntu-init-switch
- seed_random
- bootcmd
- write-files
- growpart
- resizefs
- set_hostname
- update_hostname
- update_etc_hosts
- ca-certs
- rsyslog
- users-groups
- ssh
# The modules that run in the 'config' stage
cloud_config_modules:
# Emit the cloud config ready event
# this can be used by upstart jobs for 'start on cloud-config'.
- emit_upstart
- disk_setup
- mounts
- locale
- set-passwords
- snappy
- grub-dpkg
- apt-pipelining
- apt-configure
- package-update-upgrade-install
- ssh-import-id
- fan
- landscape
- timezone
- lxd
- puppet
- chef
- salt-minion
- mcollective
- disable-ec2-metadata
- runcmd
- byobu
# The modules that run in the 'final' stage
cloud_final_modules:
- rightscale_userdata
- scripts-vendor
- scripts-per-once
- scripts-per-boot
- scripts-per-instance
- scripts-user
- ssh-authkey-fingerprints
- keys-to-console
- phone-home
- final-message
- power-state-change
packages:
- wget
- zip
write_files:
- path: "/opt/install-consul.sh"
owner: "root:root"
permissions: "0755"
content: |
#!/bin/bash -eux
VERSION="0.8.0"
FILE="consul_${VERSION}_linux_amd64.zip"
URL="https://releases.hashicorp.com/consul/${VERSION}/${FILE}"
WORKDIR="/tmp"
INSTALLDIR="/usr/local/bin"
DATADIR="/var/lib/consul"
cd "${WORKDIR}"
pwd
wget --quiet "${URL}" --output-document "${FILE}"
unzip "${FILE}"
rm "${FILE}"
chmod +x consul
mkdir --verbose --parents "${INSTALLDIR}" "${DATADIR}"
mv consul "${INSTALLDIR}"
cd -
pwd
- path: "/lib/systemd/system/setup-network-environment.service"
owner: "root:root"
permissions: "0644"
content: |
[Unit]
Description=Setup Network Environment
Documentation=https://github.com/kelseyhightower/setup-network-environment
Requires=network-online.target
After=network-online.target
[Service]
ExecStartPre=-/bin/mkdir -p /usr/local/bin
ExecStartPre=/usr/bin/wget -N -P /usr/local/bin https://github.com/kelseyhightower/setup-network-environment/releases/download/v1.0.0/setup-network-environment
ExecStartPre=/bin/chmod +x /usr/local/bin/setup-network-environment
ExecStart=/usr/local/bin/setup-network-environment
RemainAfterExit=yes
Type=oneshot
- path: "/lib/systemd/system/consul-server.service"
owner: "root:root"
permissions: "0644"
content: |
[Unit]
Description=Consul Server
Requires=setup-network-environment.service
After=network.target setup-network-environment.service
[Service]
User=root
Group=root
Environment="GOMAXPROCS=2"
EnvironmentFile=/etc/network-environment
ExecStart=/usr/local/bin/consul agent \
-server \
-bind=0.0.0.0 \
-advertise=${ENP0S8_IPV4} \
-data-dir=/var/lib/consul \
-bootstrap-expect=2
ExecReload=/bin/kill -9 $MAINPID
KillSignal=SIGINT
Restart=on-failure
[Install]
WantedBy=multi-user.target
runcmd:
- /opt/install-consul.sh
- /bin/systemctl enable setup-network-environment.service
- /bin/systemctl start setup-network-environment.service
- /bin/systemctl enable consul-server.service
- /bin/systemctl start consul-server.service