Using a Custom Cloud-Init
In some cases you may need to customize an instance at creation, before the agent is installed and started.
Overriding the default cloud-init file is an advanced feature and should be avoided unless absolutely necessary.
You can customize your instance configuration by providing a custom cloud-init file. Below is sample cloud-init file that you can use as a baseline and customize.
1 #cloud-config
2
3 apt_reboot_if_required: false
4 package_update: false
5 package_upgrade: false
6
7 apt:
8 sources:
9 docker.list:
10 source: deb [arch=amd64] https://download.docker.com/linux/ubuntu $RELEASE stable
11 keyid: 0EBFCD88
12
13 packages:
14 - docker-ce
15
16 write_files:
17 - path: /etc/systemd/system/docker.service.d/override.conf
18 content: |
19 [Service]
20 ExecStart=
21 ExecStart=/usr/bin/dockerd
22 - path: /etc/default/docker
23 content: |
24 DOCKER_OPTS=""
25 - path: /etc/docker/daemon.json
26 content: |
27 {
28 "hosts": [ "0.0.0.0:2376", "unix:///var/run/docker.sock" ],
29 "tls": true,
30 "tlsverify": true,
31 "tlscacert": "/etc/docker/ca.pem",
32 "tlscert": "/etc/docker/server-cert.pem",
33 "tlskey": "/etc/docker/server-key.pem"
34 }
35 - path: /etc/docker/ca.pem
36 encoding: b64
37 content: {{ .CACert | base64 }}
38 - path: /etc/docker/server-cert.pem
39 encoding: b64
40 content: {{ .TLSCert | base64 }}
41 - path: /etc/docker/server-key.pem
42 encoding: b64
43 content: {{ .TLSKey | base64 }}
44
45 runcmd:
46 - [ systemctl, daemon-reload ]
47 - [ systemctl, restart, docker ]
You will need to provide your custom cloud-init file to the autoscale server. You can mount the file as a volume:
--volume=/path/on/host/init.yml:/path/in/container/init.yml
You will also need to tell the autoscale server where to find the file inside the container. Please adjust the configuration based on your provider.
DRONE_AMAZON_USERDATA_FILE=/path/inside/container/init.yml