Skip to content

Instantly share code, notes, and snippets.

@james-nesbitt
Last active January 17, 2017 08:52
Show Gist options
  • Save james-nesbitt/59961a713853688039e5e58ff0dfc2ce to your computer and use it in GitHub Desktop.
Save james-nesbitt/59961a713853688039e5e58ff0dfc2ce to your computer and use it in GitHub Desktop.
UpCloud Rancher master cloud-init
#cloud-config
write_files:
- path: /etc/rancher.environment
content: |
CATTLE_DB_CATTLE_USERNAME=cattle
CATTLE_DB_CATTLE_PASSWORD=cattle
coreos:
units:
- name: "rancher-db.service"
command: "start"
content: |
[Unit]
Description=Rancher DB
[Service]
EnvironmentFile=/etc/rancher.environment
ExecStartPre=-/usr/bin/docker create --env-file=/etc/rancher.environment --name=rancher-db --restart=unless-stopped -e MYSQL_RANDOM_ROOT_PASSWORD=yes -e MYSQL_DATABASE="cattle" -e MYSQL_USER="${CATTLE_DB_CATTLE_USERNAME}" -e MYSQL_PASSWORD="${CATTLE_DB_CATTLE_PASSWORD}" mariadb
ExecStart=/usr/bin/docker start -a rancher-db
ExecStop=/usr/bin/docker stop rancher-db
units:
- name: "rancher-master.service"
command: "start"
content: |
[Unit]
Description=Rancher Master
Requires=rancher-db.service
[Service]
EnvironmentFile=/etc/rancher.environment
ExecStartPre=-/usr/bin/docker create --env-file=/etc/rancher.environment --name=rancher-master --restart=unless-stopped -p 8080:8080 --link rancher-db:db.app rancher/server --db-host "db.app" --db-user "${CATTLE_DB_CATTLE_USERNAME}" --db-pass "${CATTLE_DB_CATTLE_PASSWORD}"
ExecStart=/usr/bin/docker start -a rancher-master
ExecStop=/usr/bin/docker stop rancher-master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment