Skip to content

Instantly share code, notes, and snippets.

@bergerx
Created July 5, 2016 12:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bergerx/5aa6f6805a62864556984317c9cd901c to your computer and use it in GitHub Desktop.
Save bergerx/5aa6f6805a62864556984317c9cd901c to your computer and use it in GitHub Desktop.
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