Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature cloud config file #2

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
67 changes: 64 additions & 3 deletions coreos-on-do.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,14 @@ cd $(dirname $0)
stage1()
{
cd /root

PUBLIC=$(ip addr show dev eth0 | grep 'inet.*eth0' | awk '{print $2}')
cat > cloud-config.yaml << EOF
#cloud-config

ssh_authorized_keys:
- $(cat /root/.ssh/authorized_keys | head -1)

write_files:
- path: /etc/systemd/network/do.network
permissions: 0644
Expand All @@ -18,13 +23,69 @@ write_files:
Name=ens3

[Network]
Address=$(ip addr show dev eth0 | grep 'inet.*eth0' | awk '{print $2}')
Address=$PUBLIC
Gateway=$(route | grep default | awk '{print $2}')
DNS=8.8.4.4
DNS=8.8.8.8
EOF

ssh_authorized_keys:
- $(cat /root/.ssh/authorized_keys | head -1)
PRIVATE=$(ip addr show dev eth1 | grep 'inet.*eth1' | awk '{print $2}')
if [[ -n "$PRIVATE" ]]; then
cat >> cloud-config.yaml << EOF

- path: /etc/systemd/network/private.network
permissions: 0644
content: |
[Match]
Name=ens4v1

[Network]
Address=${PRIVATE}
EOF
fi

if [[ -n "$DISCOVERY" ]]; then
cat >> cloud-config.yaml << EOF

coreos:
etcd:
EOF

if [[ -n "$HOSTNAME" ]]; then
cat >> cloud-config.yaml << EOF
name: ${HOSTNAME}
EOF
fi

if [ -z "$PRIVATE" -o -n "$CROSS_CLOUD" ]; then
PEER_ADDR=$(echo $PUBLIC | sed 's/\/[0-9]\+$//')
else
PEER_ADDR=$(echo $PRIVATE | sed 's/\/[0-9]\+$//')
fi

cat >> cloud-config.yaml << EOF
# generate a new token for each unique cluster from https://discovery.etcd.io/new
discovery: ${DISCOVERY}
addr: $(echo $PUBLIC | sed 's/\/[0-9]\+$//'):4001
peer-addr: ${PEER_ADDR}:7001

fleet:
public-ip: $(echo $PUBLIC | sed 's/\/[0-9]\+$//')
EOF

if [[ -n "$METADATA" ]]; then
cat >> cloud-config.yaml << EOF
metadata: ${METADATA}
EOF
fi

cat >> cloud-config.yaml << EOF

units:
- name: etcd.service
command: start
- name: fleet.service
command: start
EOF

wget http://alpha.release.core-os.net/amd64-usr/current/coreos_production_pxe.vmlinuz
Expand Down