Skip to content

Instantly share code, notes, and snippets.

@brodkin
Forked from skippy/cloud-config.yml
Created February 11, 2015 06:42
Show Gist options
  • Save brodkin/b4fbcdc172cf8ddd06cf to your computer and use it in GitHub Desktop.
Save brodkin/b4fbcdc172cf8ddd06cf to your computer and use it in GitHub Desktop.
#cloud-config
coreos:
etcd:
discovery: https://discovery.etcd.io/stuff
addr: $private_ipv4:4001
peer-addr: $private_ipv4:7001
units:
- name: fleet-metadata.service
command: start
content: |-
[Unit]
Description=Fleet metadata updater
Before=fleet.service
Requires=fleet.service
[Service]
Type=oneshot
RemainAfterExit=no
EnvironmentFile=/etc/environment
ExecStart=/usr/bin/bash -c '\
echo "Writing EC2 metadata to fleet metadata."; \
mkdir /run/systemd/system/fleet.service.d; \
conf_file=/run/systemd/system/fleet.service.d/21-metadata.conf; \
instance_id=$(curl -s http://169.254.169.254/latest/meta-data/instance-id); \
az=$(curl -s http://169.254.169.254/latest/meta-data/placement/availability-zone); \
region=$${az::-1}; \
sgs=$(curl -s http://169.254.169.254/latest/meta-data/security-groups/ | sed "s/^/sg_/" | sed "s/$/=1/" | tr "\\n", ","); \
echo "[Service]" > $conf_file; \
echo "Environment=\'FLEET_METADATA=instance_id=$${instance_id},az=$${az},region=$${region},$${sgs}\'" >> $conf_file; \
systemctl daemon-reload; \
'
- name: etcd.service
command: start
- name: fleet.service
command: start
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment