Last active
December 16, 2016 15:06
-
-
Save james-nesbitt/059507ec54479c74808ee4003215d46a to your computer and use it in GitHub Desktop.
Kraut UpCloud cloud-init user-data
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#cloud-config | |
coreos: | |
units: | |
- name: "rancher-master.service" | |
command: "start" | |
content: | | |
[Unit] | |
Description=Rancher Master | |
[Service] | |
Type=oneshot | |
RemainAfterExit=yes | |
SuccessExitStatus=137 | |
ExecStartPre=/usr/bin/docker pull rancher/server | |
ExecStart=/usr/bin/docker run -d --name=rancher-master --restart=unless-stopped -p 8080:8080 rancher/server | |
ExecStartPost=while [ "$(curl -s -o /dev/null -w "%{http_code}" http://localhost:8080/v2-beta)" != "200" ]; do echo "api still NOT RESPONDING"; sleep 1; done | |
ExecStop=/usr/bin/docker stop rancher-master | |
- name: "rancher-local.service" | |
command: "start" | |
content: | | |
[Unit] | |
Description=Rancher local agent | |
Requires= rancher-master.service | |
[Service] | |
Type=oneshot | |
RemainAfterExit=yes | |
SuccessExitStatus=137 | |
ExecStartPre=ID=$(curl -s -X POST -H 'Accept: application/json' -H 'Content-Type: application/json' -d '{"description":"Local Agent", "name":"local"}' "http://localhost:8080/v2-beta/projects/1a5/registrationtokens" | jq -r .id); sleep 5 | |
ExecStartPre=REGURL=$(curl -s -X GET -H 'Accept: application/json' -H 'Content-Type: application/json' -d '{"description":"Local Agent", "name":"local"}' "http://localhost:8080/v2-beta/registrationtokens/${ID}" | jq -r .registrationUrl) | |
ExecStart=/usr/bin/docker run -D --name=rancher-LOCAL-AGENT --privileged -e CATTLE_HOST_LABELS='kraut=local-agent' -v /var/run/docker.sock:/var/run/docker.sock rancher/agent "${REGURL}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment