blob: fc3c96a3e0c1b9bbff4f82c11cf0e4bf095788cf [file] [log] [blame]
# Copyright 2017-present Open Networking Foundation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
---
- hosts: {{ instance_name }}
gather_facts: False
connection: ssh
become_user: ubuntu
vars:
cdn_enable: {{ cdn_enable }}
dnsdemux_ip: {{ dnsdemux_ip }}
firewall_enable: {{ firewall_enable }}
url_filter_enable: {{ url_filter_enable }}
c_tags:
{% for c_tag in c_tags %}
- {{ c_tag }}
{% endfor %}
s_tags:
{% for s_tag in s_tags %}
- {{ s_tag }}
{% endfor %}
firewall_rules:
{% for firewall_rule in firewall_rules.split("\n") %}
- {{ firewall_rule }}
{% endfor %}
cdn_prefixes:
{% for prefix in cdn_prefixes %}
- {{ prefix }}
{% endfor %}
bbs_addrs:
{% for bbs_addr in bbs_addrs %}
- {{ bbs_addr }}
{% endfor %}
dns_servers:
{% for dns_server in dns_servers %}
- {{ dns_server }}
{% endfor %}
nat_ip: {{ nat_ip }}
nat_mac: {{ nat_mac }}
lan_ip: {{ lan_ip }}
lan_mac: {{ lan_mac }}
wan_ip: {{ wan_ip }}
wan_mac: {{ wan_mac }}
wan_container_mac: {{ wan_container_mac }}
wan_next_hop: 10.0.1.253 # FIX ME
private_ip: {{ private_ip }}
private_mac: {{ private_mac }}
hpc_client_ip: {{ hpc_client_ip }}
hpc_client_mac: {{ hpc_client_mac }}
keystone_tenant_id: {{ keystone_tenant_id }}
keystone_user_id: {{ keystone_user_id }}
rabbit_user: {{ rabbit_user }}
rabbit_password: {{ rabbit_password }}
rabbit_host: {{ rabbit_host }}
safe_browsing:
{% for mac in safe_browsing_macs %}
- {{ mac }}
{% endfor %}
uplink_speed: {{ uplink_speed }}
downlink_speed: {{ downlink_speed }}
status: {{ status }}
enable_uverse: {{ enable_uverse }}
url_filter_kind: {{ url_filter_kind }}
tasks:
{% if full_setup %}
- name: Docker repository
copy: src=/opt/xos/synchronizers/veg/files/docker.list
dest=/etc/apt/sources.list.d/docker.list
- name: Import the repository key
apt_key: keyserver=keyserver.ubuntu.com id=36A1D7869245C8950F966E92D8576A8BA88D21E9
- name: install Docker
apt: name=lxc-docker state=present update_cache=yes
- name: install python-setuptools
apt: name=python-setuptools state=present
- name: install pip
easy_install: name=pip
- name: install docker-py
pip: name=docker-py version=0.5.3
- name: install Pipework
get_url: url=https://raw.githubusercontent.com/jpetazzo/pipework/master/pipework
dest=/usr/local/bin/pipework
mode=0755
- name: make sure /etc/dnsmasq.d exists
file: path=/etc/dnsmasq.d state=directory owner=root group=root
- name: Disable resolvconf service
shell: service resolvconf stop
shell: echo manual > /etc/init/resolvconf.override
shell: rm -f /etc/resolv.conf
- name: Install resolv.conf
copy: src=/opt/xos/synchronizers/veg/files/vm-resolv.conf
dest=/etc/resolv.conf
- name: Verify if veg_stats_notifier ([] is to avoid capturing the shell process) cron job is already running
shell: pgrep -f [v]veg_stats_notifier | wc -l
register: cron_job_pids_count
# - name: DEBUG
# debug: var=cron_job_pids_count.stdout
# - name: make sure ~/bin exists
# file: path=~/bin state=directory owner=root group=root
# when: cron_job_pids_count.stdout == "0"
- name: Copy cron job to destination
copy: src=/opt/xos/synchronizers/veg/veg_stats_notifier.py
dest=/usr/local/sbin/veg_stats_notifier.py
when: cron_job_pids_count.stdout == "0"
- name: install python-kombu
apt: name=python-kombu state=present
when: cron_job_pids_count.stdout == "0"
- name: Initiate veg_stats_notifier cron job
command: sudo python /usr/local/sbin/veg_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 }} --vegservice_rabbit_exchange='vegservice'
async: 9999999999999999
poll: 0
when: cron_job_pids_count.stdout == "0"
{% endif %}
- name: vEG upstart
template: src=/opt/xos/synchronizers/veg/templates/veg.conf.j2 dest=/etc/init/veg-{{ s_tags[0] }}-{{ c_tags[0] }}.conf
- name: vEG startup script
template: src=/opt/xos/synchronizers/veg/templates/start-veg.sh.j2 dest=/usr/local/sbin/start-veg-{{ s_tags[0] }}-{{ c_tags[0] }}.sh mode=0755
notify:
# - restart veg
- stop veg
- remove container
- start veg
- name: create /etc/veg-{{ s_tags[0] }}-{{ c_tags[0] }}/dnsmasq.d
file: path=/etc/veg-{{ s_tags[0] }}-{{ c_tags[0] }}/dnsmasq.d state=directory owner=root group=root
- name: vEG basic dnsmasq config
copy: src=/opt/xos/synchronizers/veg/files/veg.dnsmasq dest=/etc/veg-{{ s_tags[0] }}-{{ c_tags[0] }}/dnsmasq.d/veg.conf owner=root group=root
notify:
- restart dnsmasq
- name: dnsmasq config
template: src=/opt/xos/synchronizers/veg/templates/dnsmasq_servers.j2 dest=/etc/veg-{{ s_tags[0] }}-{{ c_tags[0] }}/dnsmasq.d/servers.conf owner=root group=root
notify:
- restart dnsmasq
# These are samples, not necessary for correct function of demo
# - name: networking info
# template: src=/opt/xos/synchronizers/veg/templates/vlan_sample.j2 dest=/etc/vlan_sample owner=root group=root
# - name: firewall info
# template: src=/opt/xos/synchronizers/veg/templates/firewall_sample.j2 dest=/etc/firewall_sample owner=root group=root
- name: Make sure vEG service is running
service: name=veg-{{ s_tags[0] }}-{{ c_tags[0] }} state=started
handlers:
# Dnsmasq is automatically restarted in the container
- name: restart dnsmasq
shell: docker exec veg-{{ s_tags[0] }}-{{ c_tags[0] }} killall dnsmasq
- name: restart veg
shell: service veg-{{ s_tags[0] }}-{{ c_tags[0] }} stop; sleep 1; service veg-{{ s_tags[0] }}-{{ c_tags[0] }} start
- name: stop veg
service: name=veg-{{ s_tags[0] }}-{{ c_tags[0] }} state=stopped
- name: remove container
docker: name=veg-{{ s_tags[0] }}-{{ c_tags[0] }} state=absent image=docker-veg
- name: start veg
service: name=veg-{{ s_tags[0] }}-{{ c_tags[0] }} state=started