blob: 4ae4eb2dfc9bc5faef64cd8012be1b288775023f [file] [log] [blame]
Scott Bakerb63ea792016-08-11 10:24:48 -07001---
2- hosts: {{ instance_name }}
3 gather_facts: False
4 connection: ssh
5 user: {{ username }}
6 sudo: yes
7
8 vars:
9 container_name: {{ container_name }}
10 docker_image: {{ docker_image }}
11 network_method: {{ network_method }}
12 ports:
13 {% for port in ports %}
14 - device: {{ port.device }}
15 xos_network_id: {{ port.xos_network_id }}
16 mac: {{ port.mac|default("") }}
17 ip: {{ port.ip }}
18 snoop_instance_mac: {{ port.snoop_instance_mac }}
19 snoop_instance_id: {{ port.snoop_instance_id }}
20 parent_mac: {{ port.parent_mac|default("") }}
21 s_tag: {{ port.s_tag|default("") }}
22 c_tag: {{ port.c_tag|default("") }}
23 next_hop: {{ port.next_hop|default("") }}
24 bridge: {{ port.bridge }}
25 {% endfor %}
26 volumes:
27 {% for volume in volumes %}
28 - {{ volume }}
29 {% endfor %}
30
31 tasks:
32
33# - name: Fix /etc/hosts
34# lineinfile:
35# dest=/etc/hosts
36# regexp="127.0.0.1 localhost"
37# line="127.0.0.1 localhost {{ instance_hostname }}"
38
39 - name: Add repo key
40 apt_key:
41 keyserver=hkp://pgp.mit.edu:80
42 id=58118E89F3A912897C070ADBF76221572C52609D
43
44 - name: Install Docker repo
45 apt_repository:
46 repo="deb https://apt.dockerproject.org/repo ubuntu-trusty main"
47 state=present
48
49 - name: Install Docker
50 apt:
51 name={{ '{{' }} item {{ '}}' }}
52 state=latest
53 update_cache=yes
54 with_items:
55# XXX docker 1.10 is not working on cloudlab
56# - docker-engine
57 - python-pip
58 - python-httplib2
59
60 - name: Install Docker 1.9.1
61 apt:
62 name={{ '{{' }} item {{ '}}' }}
63 update_cache=yes
64 with_items:
65 - docker-engine=1.9.1-0~trusty
66
67 # Something is installing a requests library that is incompative with pip, and
68 # will cause this recipe to fail next time it tries to run pip. Only the one
69 # in /usr/local/lib is bad. There's still a good one in /usr/lib
70 - name: check if bad requests library installed
71 stat: path=/usr/local/lib/python2.7/dist-packages/requests
72 register: bad_requests
73
74 - name: remove bad request library
75 shell: mv /usr/local/lib/python2.7/dist-packages/requests /usr/local/lib/python2.7/dist-packages/requests-bad
76 when: bad_requests.stat.exists == True
77
78 - name: Install docker-py
79 pip:
80 name=docker-py
81 state=latest
82
83 - name: install Pipework
84 get_url: url=https://raw.githubusercontent.com/jpetazzo/pipework/master/pipework
85 dest=/usr/local/bin/pipework
86 mode=0755
87
88# - name: Start Container
89# docker:
90# docker_api_version: "1.18"
91# name: {{ container_name }}
92# # was: reloaded
93# state: running
94# image: {{ docker_image }}
95
96 - name: check if systemd is installed
97 stat: path=/usr/bin/systemctl
98 register: systemctl
99
100 - name: container upstart
101 template: src=/opt/xos/synchronizers/openstack/templates/container.conf.j2 dest=/etc/init/container-{{ container_name }}.conf
102
103 - name: container systemd
104 template: src=/opt/xos/synchronizers/openstack/templates/container.service.j2 dest=/lib/systemd/system/container-{{ container_name }}.service
105
106 - name: container startup script
107 template: src=/opt/xos/synchronizers/openstack/templates/start-container.sh.j2 dest=/usr/local/sbin/start-container-{{ container_name }}.sh mode=0755
108
109 - name: container teardown script
110 template: src=/opt/xos/synchronizers/openstack/templates/stop-container.sh.j2 dest=/usr/local/sbin/stop-container-{{ container_name }}.sh mode=0755
111
112 - name: restart systemd
113 shell: systemctl daemon-reload
114 when: systemctl.stat.exists == True
115
116{% if ports %}
117 - name: make sure bridges are setup
118 shell: ifconfig {{ '{{' }} item.bridge {{ '}}' }}
119 with_items: "ports"
120{% endif %}
121
122 - name: Make sure container is running
123 service: name=container-{{ container_name }} state=started
124