blob: 585f68a44f172d321648759ed226eb4de5c9d940 [file] [log] [blame]
Sapan Bhatia4d6cd132016-01-15 10:43:19 -05001---
2- hosts: {{ instance_name }}
3 gather_facts: False
4 connection: ssh
5 user: ubuntu
6 sudo: yes
7 vars:
8 cdn_enable: {{ cdn_enable }}
9 dnsdemux_ip: {{ dnsdemux_ip }}
10 firewall_enable: {{ firewall_enable }}
11 url_filter_enable: {{ url_filter_enable }}
12 vlan_ids:
13 {% for vlan_id in vlan_ids %}
14 - {{ vlan_id }}
15 {% endfor %}
16 c_tags:
17 {% for c_tag in c_tags %}
18 - {{ c_tag }}
19 {% endfor %}
20 s_tags:
21 {% for s_tag in s_tags %}
22 - {{ s_tag }}
23 {% endfor %}
24 firewall_rules:
25 {% for firewall_rule in firewall_rules.split("\n") %}
26 - {{ firewall_rule }}
27 {% endfor %}
28 cdn_prefixes:
29 {% for prefix in cdn_prefixes %}
30 - {{ prefix }}
31 {% endfor %}
32 bbs_addrs:
33 {% for bbs_addr in bbs_addrs %}
34 - {{ bbs_addr }}
35 {% endfor %}
Scott Bakerd9fba162016-02-23 16:01:09 -080036 dns_servers:
37 {% for dns_server in dns_servers %}
38 - {{ dns_server }}
39 {% endfor %}
Sapan Bhatia4d6cd132016-01-15 10:43:19 -050040 nat_ip: {{ nat_ip }}
41 nat_mac: {{ nat_mac }}
42 lan_ip: {{ lan_ip }}
43 lan_mac: {{ lan_mac }}
44 wan_ip: {{ wan_ip }}
45 wan_mac: {{ wan_mac }}
46 wan_container_mac: {{ wan_container_mac }}
47 wan_next_hop: 10.0.1.253 # FIX ME
48 private_ip: {{ private_ip }}
49 private_mac: {{ private_mac }}
50 hpc_client_ip: {{ hpc_client_ip }}
51 hpc_client_mac: {{ hpc_client_mac }}
52 keystone_tenant_id: {{ keystone_tenant_id }}
53 keystone_user_id: {{ keystone_user_id }}
54 rabbit_user: {{ rabbit_user }}
55 rabbit_password: {{ rabbit_password }}
56 rabbit_host: {{ rabbit_host }}
57 safe_browsing:
58 {% for mac in safe_browsing_macs %}
59 - {{ mac }}
60 {% endfor %}
61
62 tasks:
63{% if full_setup %}
64 - name: Docker repository
Srikanth Vavilapalli562ba492016-01-25 20:06:43 -050065 copy: src=/opt/xos/synchronizers/vcpe/files/docker.list
Sapan Bhatia4d6cd132016-01-15 10:43:19 -050066 dest=/etc/apt/sources.list.d/docker.list
67
68 - name: Import the repository key
69 apt_key: keyserver=keyserver.ubuntu.com id=36A1D7869245C8950F966E92D8576A8BA88D21E9
70
71 - name: install Docker
72 apt: name=lxc-docker state=present update_cache=yes
73
74 - name: install python-setuptools
75 apt: name=python-setuptools state=present
76
77 - name: install pip
78 easy_install: name=pip
79
80 - name: install docker-py
81 pip: name=docker-py version=0.5.3
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: make sure /etc/dnsmasq.d exists
89 file: path=/etc/dnsmasq.d state=directory owner=root group=root
90
91 - name: Disable resolvconf service
92 shell: service resolvconf stop
93 shell: echo manual > /etc/init/resolvconf.override
94 shell: rm -f /etc/resolv.conf
95
96 - name: Install resolv.conf
Srikanth Vavilapalli562ba492016-01-25 20:06:43 -050097 copy: src=/opt/xos/synchronizers/vcpe/files/vm-resolv.conf
Sapan Bhatia4d6cd132016-01-15 10:43:19 -050098 dest=/etc/resolv.conf
99
100 - name: Verify if vcpe_stats_notifier ([] is to avoid capturing the shell process) cron job is already running
101 shell: pgrep -f [v]cpe_stats_notifier | wc -l
102 register: cron_job_pids_count
103
104# - name: DEBUG
105# debug: var=cron_job_pids_count.stdout
106
Srikanth Vavilapallia17b0e72016-02-03 16:37:31 -0500107# - name: make sure ~/bin exists
108# file: path=~/bin state=directory owner=root group=root
109# when: cron_job_pids_count.stdout == "0"
Sapan Bhatia4d6cd132016-01-15 10:43:19 -0500110
111 - name: Copy cron job to destination
Srikanth Vavilapalli562ba492016-01-25 20:06:43 -0500112 copy: src=/opt/xos/synchronizers/vcpe/vcpe_stats_notifier.py
Srikanth Vavilapallia17b0e72016-02-03 16:37:31 -0500113 dest=/usr/local/sbin/vcpe_stats_notifier.py
Sapan Bhatia4d6cd132016-01-15 10:43:19 -0500114 when: cron_job_pids_count.stdout == "0"
115
116 - name: install python-kombu
117 apt: name=python-kombu state=present
118 when: cron_job_pids_count.stdout == "0"
119
120 - name: Initiate vcpe_stats_notifier cron job
Srikanth Vavilapallia17b0e72016-02-03 16:37:31 -0500121 command: sudo python /usr/local/sbin/vcpe_stats_notifier.py --keystone_tenant_id={{ keystone_tenant_id }} --keystone_user_id={{ keystone_user_id }} --rabbit_user={{ rabbit_user }} --rabbit_password={{ rabbit_password }} --rabbit_host={{ rabbit_host }} --vcpeservice_rabbit_exchange='vcpeservice'
Sapan Bhatia4d6cd132016-01-15 10:43:19 -0500122 async: 9999999999999999
123 poll: 0
124 when: cron_job_pids_count.stdout == "0"
125{% endif %}
126
127 - name: vCPE upstart
Srikanth Vavilapalli562ba492016-01-25 20:06:43 -0500128 template: src=/opt/xos/synchronizers/vcpe/templates/vcpe.conf.j2 dest=/etc/init/vcpe-{{ s_tags[0] }}-{{ c_tags[0] }}.conf
Sapan Bhatia4d6cd132016-01-15 10:43:19 -0500129
130 - name: vCPE startup script
Srikanth Vavilapalli562ba492016-01-25 20:06:43 -0500131 template: src=/opt/xos/synchronizers/vcpe/templates/start-vcpe.sh.j2 dest=/usr/local/sbin/start-vcpe-{{ s_tags[0] }}-{{ c_tags[0] }}.sh mode=0755
Sapan Bhatia4d6cd132016-01-15 10:43:19 -0500132 notify:
133# - restart vcpe
134 - stop vcpe
135 - remove container
136 - start vcpe
137
138 - name: create /etc/vcpe-{{ s_tags[0] }}-{{ c_tags[0] }}/dnsmasq.d
139 file: path=/etc/vcpe-{{ s_tags[0] }}-{{ c_tags[0] }}/dnsmasq.d state=directory owner=root group=root
140
141 - name: vCPE basic dnsmasq config
Srikanth Vavilapalli562ba492016-01-25 20:06:43 -0500142 copy: src=/opt/xos/synchronizers/vcpe/files/vcpe.dnsmasq dest=/etc/vcpe-{{ s_tags[0] }}-{{ c_tags[0] }}/dnsmasq.d/vcpe.conf owner=root group=root
Sapan Bhatia4d6cd132016-01-15 10:43:19 -0500143 notify:
144 - restart dnsmasq
145
146 - name: dnsmasq config
Srikanth Vavilapalli562ba492016-01-25 20:06:43 -0500147 template: src=/opt/xos/synchronizers/vcpe/templates/dnsmasq_servers.j2 dest=/etc/vcpe-{{ s_tags[0] }}-{{ c_tags[0] }}/dnsmasq.d/servers.conf owner=root group=root
Sapan Bhatia4d6cd132016-01-15 10:43:19 -0500148 notify:
149 - restart dnsmasq
150
151# These are samples, not necessary for correct function of demo
152
153# - name: networking info
Srikanth Vavilapalli562ba492016-01-25 20:06:43 -0500154# template: src=/opt/xos/synchronizers/vcpe/templates/vlan_sample.j2 dest=/etc/vlan_sample owner=root group=root
Sapan Bhatia4d6cd132016-01-15 10:43:19 -0500155
156# - name: firewall info
Srikanth Vavilapalli562ba492016-01-25 20:06:43 -0500157# template: src=/opt/xos/synchronizers/vcpe/templates/firewall_sample.j2 dest=/etc/firewall_sample owner=root group=root
Sapan Bhatia4d6cd132016-01-15 10:43:19 -0500158
159 - name: Make sure vCPE service is running
160 service: name=vcpe-{{ s_tags[0] }}-{{ c_tags[0] }} state=started
161
162 handlers:
163 # Dnsmasq is automatically restarted in the container
164 - name: restart dnsmasq
165 shell: docker exec vcpe-{{ s_tags[0] }}-{{ c_tags[0] }} killall dnsmasq
166
167 - name: restart vcpe
168 shell: service vcpe-{{ s_tags[0] }}-{{ c_tags[0] }} stop; sleep 1; service vcpe-{{ s_tags[0] }}-{{ c_tags[0] }} start
169
170 - name: stop vcpe
171 service: name=vcpe-{{ s_tags[0] }}-{{ c_tags[0] }} state=stopped
172
173 - name: remove container
174 docker: name=vcpe-{{ s_tags[0] }}-{{ c_tags[0] }} state=absent image=docker-vcpe
175
176 - name: start vcpe
177 service: name=vcpe-{{ s_tags[0] }}-{{ c_tags[0] }} state=started
178