#cloud-config
---
coreos:
  update:
    reboot-strategy: 'off'
  etcd2:
    proxy: on
    listen-client-urls: http://127.0.0.1:2379
    initial-cluster: etcdserver=http://172.18.18.101: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/mkdir -p /var/run/calico
        ExecStartPre=/usr/bin/mkdir -p /var/log/calico
        ExecStartPre=/usr/bin/wget -N -O /opt/bin/calicoctl https://github.com/projectcalico/calicoctl/releases/download/v1.0.2/calicoctl
        ExecStartPre=/usr/bin/wget -N -P /etc/rkt/net.d https://github.com/projectcalico/calico-cni/releases/download/v1.5.6/calico
        ExecStartPre=/usr/bin/wget -N -P /etc/rkt/net.d https://github.com/projectcalico/calico-cni/releases/download/v1.5.6/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 quay.io/calico/node:v1.0.2
        ExecStart=/usr/bin/true
        RemainAfterExit=yes
        Type=oneshot

        [Install]
        WantedBy=multi-user.target
