Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save charlesmarshall/6c346a6035c750db0f7c to your computer and use it in GitHub Desktop.
Save charlesmarshall/6c346a6035c750db0f7c to your computer and use it in GitHub Desktop.
CoreOS Cloud-Init with host announcement service
#cloud-config
ssh_authorized_keys:
- ssh-rsa AAAAB3NzaC1yc2EAAAADAQAB ...snip... QAyapHGwoBvkq7nNp
coreos:
etcd:
# via https://discovery.etcd.io/new
discovery: https://discovery.etcd.io/7028e012ca66ef0121b64c19c40a425a
addr: $private_ipv4:4001
peer-addr: $private_ipv4:7001
units:
- name: etcd.service
command: start
- name: fleet.service
command: start
runtime: no
content: |
[Unit]
Description=fleet
[Service]
Environment=FLEET_PUBLIC_IP=$private_ipv4
ExecStart=/usr/bin/fleet
- name: host.service
command: start
runtime: no
content: |
[Unit]
Description=Host announcer
After=etcd.service
Requires=etcd.service
[Service]
Environment=COREOS_PRIVATE_IPV4=$private_ipv4
ExecStart=/bin/bash -c "while true; do echo setting host %b to $COREOS_PRIVATE_IPV4; etcdctl set /hosts/%m $COREOS_PRIVATE_IPV4 --ttl 60; sleep 45; done"
ExecStop=/usr/bin/etcdctl rm /hosts/%m
[X-Fleet]
X-Conflicts=host.service
write_files:
- content: |
ssh-rsa AAAAB3NzaC1yc2EAAAADAQAB ...snip... QAyapHGwoBvkq7nNp
path: /home/core/.ssh/shared.pub
permissions: '0600'
owner: core:core
- content: |
-----BEGIN RSA PRIVATE KEY-----
MIIEowIBAAKCAQEAsjvCcWeXSpB2EvTvxsyMHoA55BDcU/oP0Kr1QvgXGmw/PT/R
8Nq/Hy8WBW8vlJGqlkClZqvJn7vE014G3a4otmJT087nA+ftfYc0g04GzBFzt05Q
... snip ...
dWtYdrxBBuKUDmSqdHkGPJS/KErmVm2OWqPgiOMgae2s7QSrySX6VKRH/grV0DLh
UYrPiHUruKX6rgEVjhzS55dKiN4XRk0N+CWYXq3mgmO5zV3rb4/u
-----END RSA PRIVATE KEY-----
path: /home/core/.ssh/shared
permissions: '0600'
owner: core:core
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment