Skip to content

Instantly share code, notes, and snippets.

@bergerx bergerx/main.yml
Created Jul 5, 2016

Embed
What would you like to do?
A sample for managing containers on ubuntu using ansible
- name: prepare calico-node upstart service file
template: src=roles/docker/templates/upstart-docker-instance.j2.j2 dest="/etc/init/{{ item.service_name }}.conf"
tags:
- service
- calico
with_items:
- service_name: calico-node
docker_name: calico-node
docker_run: >
/usr/bin/docker run --rm \
--name=calico-node \
--net=host \
--privileged \
--name=calico-node \
-e HOSTNAME={{ ansible_hostname }} \
-e CALICO_NETWORKING=true \
-e ETCD_AUTHORITY={{ host_ip }}:2379 \
-e ETCD_SCHEME=http \
-e IP={{ host_ip }} \
-v /var/log/calico:/var/log/calico \
-v /lib/modules:/lib/modules \
-v /var/run/calico:/var/run/calico \
calico/node:v0.18.0
description "{{ item.service_name }} container"
start on started docker
respawn
pre-start script
# node containers fail to auto-start on docker service restart without this
FILE=/var/run/docker.sock
while [ ! -S $FILE ] ; do
inotifywait -t 2 -e create $(dirname $FILE)
done
docker rm -f {{ item.docker_name }} &>/dev/null || :
end script
script
exec {{ item.docker_run }}
end script
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.