#cloud-config
---
coreos:
  update:
    reboot-strategy: off
  etcd2:
    name: "etcdserver"
    listen-client-urls: http://0.0.0.0:2379
    advertise-client-urls: http://$private_ipv4:2379
    initial-cluster: etcdserver=http://$private_ipv4:2380
    initial-advertise-peer-urls: http://$private_ipv4:2380
    listen-client-urls: http://0.0.0.0:2379,http://0.0.0.0:4001
    listen-peer-urls: http://0.0.0.0:2380
  units:
    - name: "etcd2.service"
      command: "start"
    - name: calico-download.service
      runtime: true
      command: start
      content: |
        [Unit]
        Description=Download calico
        After=network-online.target
        Requires=network-online.target

        [Service]
        User=root
        ExecStartPre=/usr/bin/mkdir -p /opt/bin
        ExecStartPre=/usr/bin/mkdir -p /etc/rkt/net.d
        ExecStartPre=/usr/bin/wget -N -O /opt/bin/calicoctl https://github.com/projectcalico/calico-containers/releases/download/v0.22.0/calicoctl
        ExecStartPre=/usr/bin/wget -N -P /etc/rkt/net.d https://github.com/projectcalico/calico-cni/releases/download/v1.4.2/calico
        ExecStartPre=/usr/bin/wget -N -P /etc/rkt/net.d https://github.com/projectcalico/calico-cni/releases/download/v1.4.2/calico-ipam
        ExecStartPre=/usr/bin/chmod a+w -R /etc/rkt/net.d
        ExecStartPre=/usr/bin/chmod +x /etc/rkt/net.d/calico
        ExecStartPre=/usr/bin/chmod +x /etc/rkt/net.d/calico-ipam
        ExecStartPre=/usr/bin/chmod +x /opt/bin/calicoctl
        ExecStartPre=/usr/bin/rkt --insecure-options=image fetch docker://busybox
        ExecStartPre=/usr/bin/rkt --insecure-options=image fetch docker://calico/node:v0.22.0
        ExecStart=/usr/bin/true
        RemainAfterExit=yes
        Type=oneshot

        [Install]
        WantedBy=multi-user.target
