Skip to content

Instantly share code, notes, and snippets.

@kenperkins
Last active August 29, 2015 14:07
Show Gist options
  • Save kenperkins/9a6481c399a87c971160 to your computer and use it in GitHub Desktop.
Save kenperkins/9a6481c399a87c971160 to your computer and use it in GitHub Desktop.
coreos-cluster generated cloud-config
#cloud-config
coreos:
etcd:
discovery: "https://discovery.etcd.io/b3b602b06366954b02e07d66fc6e68fe"
fleet:
public-ip: $public_ipv4
metadata: "provider=rackspace,region=iad"
update:
reboot-strategy: etcd-lock
units:
- name: etcd.service
command: start
- name: fleet.service
command: start
- name: rackspace-ip-environment.service
command: start
content: "[Unit]\nDescription=Configure /etc/environment variables for Rackspace networks on etcd\nAfter=network-online.target\nRequires=ntpd.service network-online.target\n\n[Service]\nType=oneshot\nRemainAfterExit=yes\nExecStart=/root/bin/rackspace-ips.sh\nExecStart=/root/bin/fixup-etc.sh"
- name: rackspace-monitoring-agent-token.service
command: start
runtime: yes
content: "[Unit]\nDescription=Rackspace Monitoring Agent Token Creation\n\n[Service]\nType=oneshot\nRemainAfterExit=yes\nExecStart=/usr/bin/mkdir -p /opt/rackspace-monitoring-agent/logs\nExecStart=/bin/bash -c 'echo \"monitoring_token 124e0962d94b982f55b44c54b08419129547e3a4dc0d8a9e4d7226834d993af3.809120\""
- name: rackspace-monitoring-agent-id.service
command: start
runtime: yes
content: "[Unit]\nDescription=Rackspace Monitoring Agent Id Creation\n\n[Service]\nAfter=rackspace-monitoring-agent-token.service\nRequires=rackspace-monitoring-agent-token.service\nType=oneshot\nRemainAfterExit=yes\nExecStart=/bin/bash -c '/usr/bin/xenstore read name | /usr/bin/sed \"s:instance-:monitoring_id :\" >> /opt/rackspace-monitoring-agent/rackspace-monitoring-agent.cfg'"
- name: rackspace-monitoring-agent.service
command: start
runtime: yes
content: "[Unit]\nDescription=Rackspace Monitoring Agent\n\n[Service]\nAfter=rackspace-monitoring-agent-token.service rackspace-monitoring-agent-id.service\nRequires=rackspace-monitoring-agent-token.service rackspace-monitoring-agent-id.service\nExecStart=/usr/bin/docker run \\\n -v /proc:/proc \\\n -v /dev:/dev \\\n -v /dev/pts:/dev/pts \\\n -v /sys:/sys \\\n -v /opt/rackspace-monitoring-agent/rackspace-monitoring-agent.cfg:/etc/rackspace-monitoring-agent.cfg \\\n -v /opt/rackspace-monitoring-agent/logs:/var/log rackerlabs/maas-agent-docker\nRestart=always\nRestartSec=30s"
write_files:
- path: /root/bin/fixup-etc.sh
permissions: "0755"
content: "#!/bin/bash -e\nsource /etc/environment\nmkdir -p /etc/systemd/system/etcd.service.d\ncat > /etc/systemd/system/etcd.service.d/50-rackspace.conf <<EOF\n[Service]\nEnvironment=\"ETCD_ADDR=${RAX_SERVICENET_IPV4}:4001\"\nEnvironment=\"ETCD_PEER_ADDR=${RAX_SERVICENET_IPV4}:7001\"\nEOF\nsystemctl daemon-reload\nsystemctl restart etcd.service"
- path: /root/bin/rackspace-ips.sh
permissions: "0755"
content: "#!/bin/bash\nfor i in `ip a | grep -- 'inet ' | awk '{print $2}' | grep -v '^127.' | cut -d'/' -f1`; do\n case `echo $i | cut -d. -f1` in\n \"10\")\n echo \"Writing RAX_SERVICENET_IPV4=$i to /etc/environment\"\n echo \"RAX_SERVICENET_IPV4=$i\" >> /etc/environment\n ;;\n \"192\")\n echo \"Writing RAX_PRIVATENET_IPV4=$i to /etc/environment\"\n echo \"RAX_PRIVATENET_IPV4=$i\" >> /etc/environment\n ;;\n \"172\")\n echo \"Writing RAX_ETCDNET_IPV4=$i to /etc/environment\"\n echo \"RAX_ETCDNET_IPV4=$i\" >> /etc/environment\n ;;\n *)\n echo \"Writing RAX_PUBLICNET_IPV4=$i to /etc/environment\"\n echo \"RAX_PUBLICNET_IPV4=$i\" >> /etc/environment\n ;;\n esac\ndone"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment