-
-
Save jjbubudi/c9312a47699cc5b3b22b to your computer and use it in GitHub Desktop.
CoreOS cloud_config for Rackspace Public Cloud
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: | |
fleet: | |
public-ip: $public_ipv4 | |
metadata: region=dfw,provider=rackspace | |
etcd: | |
discovery: https://discovery.etcd.io/youridhere | |
# multi-region and multi-cloud deployments need to use $public_ipv4 | |
# We'll actually fill this in using fixup_etc.sh (see below) | |
# addr: $rax_privatenet_ipv4:4001 | |
# peer-addr: $rax_privatenet_ipv4:7001 | |
update: | |
reboot-strategy: etcd-lock | |
group: beta | |
units: | |
- name: etcd.service | |
command: start | |
- name: fleet.service | |
command: start | |
- name: rax_ip_env.service | |
command: start | |
content: | | |
[Unit] | |
Description=Configure /etc/environment variables for Rackspace networks on etcd | |
After=network-online.target | |
Requires=ntpd.service network-online.target | |
[Service] | |
Type=oneshot | |
RemainAfterExit=yes | |
ExecStart=/root/bin/rax_ips.sh | |
ExecStart=/root/bin/fixup_etc.sh | |
- name: rackspace-monitoring-agent-token.service | |
command: start | |
runtime: yes | |
content: | | |
[Unit] | |
Description=Rackspace Monitoring Agent Token Creation | |
[Service] | |
Type=oneshot | |
RemainAfterExit=yes | |
ExecStart=/usr/bin/mkdir -p /opt/rackspace-monitoring-agent/logs | |
ExecStart=/bin/bash -c 'echo "monitoring_token YOUR_TOKEN_HERE" > /opt/rackspace-monitoring-agent/rackspace-monitoring-agent.cfg' | |
- name: rackspace-monitoring-agent-id.service | |
command: start | |
runtime: yes | |
content: | | |
[Unit] | |
Description=Rackspace Monitoring Agent Id Creation | |
[Service] | |
After=rackspace-monitoring-agent-token.service | |
Requires=rackspace-monitoring-agent-token.service | |
Type=oneshot | |
RemainAfterExit=yes | |
ExecStart=/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] | |
Description=Rackspace Monitoring Agent | |
[Service] | |
After=rackspace-monitoring-agent-token.service rackspace-monitoring-agent-id.service | |
Requires=rackspace-monitoring-agent-token.service rackspace-monitoring-agent-id.service | |
ExecStart=/usr/bin/docker run \ | |
-v /proc:/proc \ | |
-v /dev:/dev \ | |
-v /dev/pts:/dev/pts \ | |
-v /sys:/sys \ | |
-v /opt/rackspace-monitoring-agent/rackspace-monitoring-agent.cfg:/etc/rackspace-monitoring-agent.cfg \ | |
-v /opt/rackspace-monitoring-agent/logs:/var/log \ | |
rackerlabs/maas-agent-docker | |
Restart=always | |
RestartSec=30s | |
write_files: | |
- path: /root/.dockercfg | |
owner: root:root | |
permissions: 0644 | |
content: | | |
{ | |
"quay.io": { | |
"auth": "OURAUTHKEY", | |
"email": "OURAUTHEMAIL" | |
} | |
} | |
- path: /home/core/.dockercfg | |
owner: core:core | |
permissions: 0644 | |
content: | | |
{ | |
"quay.io": { | |
"auth": "OURAUTHKEY=", | |
"email": "OURAUTHEMAIL" | |
} | |
} | |
- path: /root/bin/fixup_etc.sh | |
permissions: 0755 | |
content: | | |
#!/bin/bash -e | |
source /etc/environment | |
mkdir -p /etc/systemd/system/etcd.service.d | |
cat > /etc/systemd/system/etcd.service.d/50-speakit.conf <<EOF | |
[Service] | |
Environment="ETCD_ADDR=${RAX_PRIVATENET_IPV4}:4001" | |
Environment="ETCD_PEER_ADDR=${RAX_PRIVATENET_IPV4}:7001" | |
EOF | |
systemctl daemon-reload | |
systemctl restart etcd.service | |
- path: /root/bin/rax_ips.sh | |
permissions: 0755 | |
content: | | |
#!/bin/bash | |
for i in `ip a | grep -- 'inet ' | awk '{print $2}' | grep -v '^127.' | cut -d'/' -f1`; do | |
case `echo $i | cut -d. -f1` in | |
"10") | |
echo "Writing RAX_SERVICENET_IPV4=$i to /etc/environment" | |
echo "RAX_SERVICENET_IPV4=$i" >> /etc/environment | |
;; | |
"192") | |
echo "Writing RAX_PRIVATENET_IPV4=$i to /etc/environment" | |
echo "RAX_PRIVATENET_IPV4=$i" >> /etc/environment | |
;; | |
"172") | |
echo "Writing RAX_ETCDNET_IPV4=$i to /etc/environment" | |
echo "RAX_ETCDNET_IPV4=$i" >> /etc/environment | |
;; | |
*) | |
echo "Writing RAX_PUBLICNET_IPV4=$i to /etc/environment" | |
echo "RAX_PUBLICNET_IPV4=$i" >> /etc/environment | |
;; | |
esac | |
done | |
- path: /home/core/bin/docker-enter | |
permissions: 0755 | |
content: | | |
#!/bin/sh | |
if [ -e $(dirname "$0")/nsenter ]; then | |
# with boot2docker, nsenter is not in the PATH but it is in the same folder | |
NSENTER=$(dirname "$0")/nsenter | |
else | |
NSENTER=nsenter | |
fi | |
if [ -z "$1" ]; then | |
echo "Usage: `basename "$0"` CONTAINER [COMMAND [ARG]...]" | |
echo "" | |
echo "Enters the Docker CONTAINER and executes the specified COMMAND." | |
echo "If COMMAND is not specified, runs an interactive shell in CONTAINER." | |
else | |
PID=$(docker inspect --format "{{.State.Pid}}" "$1") | |
if [ -z "$PID" ]; then | |
exit 1 | |
fi | |
shift | |
OPTS="--target $PID --mount --uts --ipc --net --pid --" | |
if [ "$(id -u)" -ne "0" ]; then | |
which sudo > /dev/null | |
if [ "$?" -eq "0" ]; then | |
LAZY_SUDO="sudo " | |
else | |
echo "Warning: Cannot find sudo; Invoking nsenter as the user $USER." >&2 | |
fi | |
fi | |
if [ -z "$1" ]; then | |
# No command given. | |
# Use su to clear all host environment variables except for TERM, | |
# initialize the environment variables HOME, SHELL, USER, LOGNAME, PATH, | |
# and start a login shell. | |
$LAZY_SUDO "$NSENTER" $OPTS su - root | |
else | |
# Use env to clear all host environment variables. | |
$LAZY_SUDO "$NSENTER" $OPTS env --ignore-environment -- "$@" | |
fi | |
fi | |
users: | |
- name: core | |
groups: | |
- sudo | |
- docker | |
ssh-authorized-keys: | |
- ssh-rsa asdfasdfasdfasdfasdf |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment