Hi,
as I hard some problems finding out how to run RancherOS images in OpenStack that auto-start Rancher agents without a public IP - as I want to build a VPC-ish setup for security reasons - here is how I got it to work:
#cloud-config
write_files:
- path: /etc/rc.local
permissions: "0755"
owner: root
content: |
#!/bin/bash
# Workaround until fixed: https://github.com/rancher/os/issues/900
/sbin/ip link set mtu 1450 dev eth0
# Wait until Docker is running
wait-for-docker
docker run --rm --privileged -e CATTLE_AGENT_IP=$(ip route get 1 | awk '{print $NF;exit}') -v /var/run/docker.sock:/var/run/docker.sock -v /var/lib/rancher:/var/lib/rancher $rancher_agent_image $rancher_registration_url
Because I have to use a dynamic CATTLE_AGENT_IP I could not use the somewhat nicer service approach:
#cloud-config
services:
rancher-agent1:
image: $rancher_agent_image
command: $rancher_registration_url
privileged: true
volumes:
- /var/run/docker.sock:/var/run/docker.sock
environment:
CATTLE_AGENT_IP: ???
as I’m pretty sure it’s not possible to execute shell commands in this definition.