blob: b3661842a3d7ac85dd1650514469f3a9a9600b6b [file] [log] [blame]
Scott Baker31acc652016-06-23 15:47:56 -07001---
2- hosts: {{ instance_name }}
Srikanth Vavilapalli666a2362016-11-29 21:23:05 -06003# gather_facts: False
Scott Baker31acc652016-06-23 15:47:56 -07004 connection: ssh
5 user: ubuntu
6 sudo: yes
7 vars:
8 unique_id: {{ unique_id }}
9 auth_url: {{ auth_url }}
10 admin_user: {{ admin_user }}
11 admin_password: {{ admin_password }}
12 admin_tenant: {{ admin_tenant }}
13 shared_lan_ip: {{ private_ip }}
14 shared_lan_mac: {{ private_mac }}
15 headnode_flat_lan_ip: {{ rabbit_host }}
16 ceilometer_client_acess_ip: {{ ceilometer_ip }}
17 ceilometer_client_acess_mac: {{ ceilometer_mac }}
18 ceilometer_host_port: {{ ceilometer_port }}
19 ceilometer_pub_sub_url: {{ ceilometer_pub_sub_url }}
20 allowed_tenant_ids:
21 {% for allowed_tenant_id in allowed_tenant_ids %}
22 - {{ allowed_tenant_id }}
23 {% endfor %}
24
25 tasks:
26{% if delete %}
27 - name: Remove tenant
28# FIXME: Adding dummy template action to avoid "action attribute missing in task" error
Srikanth Vavilapallid84b7b72016-06-28 00:19:07 +000029 template: src=/opt/xos/synchronizers/monitoring/templates/ceilometer_proxy_config.j2 dest=/usr/local/share/monitoring-channel-{{ unique_id }}_ceilometer_proxy_config mode=0777
Scott Baker31acc652016-06-23 15:47:56 -070030 notify:
31 - stop monitoring-channel
32 - remove container
33{% else %}
34{% if full_setup %}
Srikanth Vavilapalli666a2362016-11-29 21:23:05 -060035 - name: Add hostname to /etc/hosts
36 lineinfile: dest=/etc/hosts
37 regexp='^127\.0\.0\.1'
38 line="127.0.0.1 localhost {{ '{{' }} ansible_hostname {{ '}}' }}"
39 owner=root group=root mode=0644
40
41 - name: Add user to docker group
42 user: name=ubuntu group=docker append=yes
43
Scott Baker31acc652016-06-23 15:47:56 -070044# - name: Docker repository
Srikanth Vavilapallid84b7b72016-06-28 00:19:07 +000045# copy: src=/opt/xos/synchronizers/monitoring/files/docker.list
Scott Baker31acc652016-06-23 15:47:56 -070046# dest=/etc/apt/sources.list.d/docker.list
47#
48# - name: Import the repository key
49# apt_key: keyserver=keyserver.ubuntu.com id=36A1D7869245C8950F966E92D8576A8BA88D21E9
50#
51# - name: install Docker
52# apt: name=lxc-docker state=present update_cache=yes
53#
54# - name: install python-setuptools
55# apt: name=python-setuptools state=present
56#
57# - name: install pip
58# easy_install: name=pip
59#
60# - name: install docker-py
61# pip: name=docker-py version=0.5.3
62#
63# - name: install Pipework
64# get_url: url=https://raw.githubusercontent.com/jpetazzo/pipework/master/pipework
65# dest=/usr/local/bin/pipework
66# mode=0755
67#
68# - name: Disable resolvconf service
69# shell: service resolvconf stop
70# shell: echo manual > /etc/init/resolvconf.override
71# shell: rm -f /etc/resolv.conf
72#
73# - name: Install resolv.conf
74# copy: src=/opt/xos/synchronizers/monitoring_channel/files/vm-resolv.conf
75# dest=/etc/resolv.conf
76{% endif %}
77
Scott Baker31acc652016-06-23 15:47:56 -070078 - name: ceilometer proxy config
Srikanth Vavilapallid84b7b72016-06-28 00:19:07 +000079 template: src=/opt/xos/synchronizers/monitoring/templates/ceilometer_proxy_config.j2 dest=/usr/local/share/monitoring-channel-{{ unique_id }}_ceilometer_proxy_config mode=0777
Scott Baker31acc652016-06-23 15:47:56 -070080 notify:
81 - copy ceilo-config-file
82 - restart monitoring-channel container
Srikanth Vavilapalli666a2362016-11-29 21:23:05 -060083 - set monitoring-channel-mtu
Scott Baker31acc652016-06-23 15:47:56 -070084
85 - name: Monitoring channel upstart
Srikanth Vavilapallid84b7b72016-06-28 00:19:07 +000086 template: src=/opt/xos/synchronizers/monitoring/templates/monitoring-channel.conf.j2 dest=/etc/init/monitoring-channel-{{ unique_id }}.conf
Scott Baker31acc652016-06-23 15:47:56 -070087
88 - name: Monitoring channel startup script
Srikanth Vavilapallid84b7b72016-06-28 00:19:07 +000089 template: src=/opt/xos/synchronizers/monitoring/templates/start-monitoring-channel.sh.j2 dest=/usr/local/sbin/start-monitoring-channel-{{ unique_id }}.sh mode=0755
Scott Baker31acc652016-06-23 15:47:56 -070090 notify:
91# - restart monitoring-channel
92 - stop monitoring-channel
93 - remove container
94 - start monitoring-channel
95
96# - name: Start monitoring-channel container
97# docker:
98# docker_api_version: "1.18"
99# name: monitoring-channel-{{ unique_id }}
100# # was: reloaded
101# state: running
102# image: srikanthvavila/monitoring-channel
103# expose:
104# - 8000
105# ports:
106# - "{{ ceilometer_port }}:8000"
107# volumes:
108# - /usr/local/share/monitoring-channel-{{ unique_id }}_ceilometer_proxy_config:/usr/local/share/ceilometer_proxy_config
109#
110# - name: Get Docker IP
111# #TODO: copy dockerip.sh to monitoring service synchronizer
112# script: /opt/xos/synchronizers/onos/scripts/dockerip.sh monitoring-channel-{{ unique_id }}
113# register: dockerip
114#
115# - name: Wait for Monitoring channel to come up
116# wait_for:
117# host={{ '{{' }} dockerip.stdout {{ '}}' }}
118# port={{ '{{' }} item {{ '}}' }}
119# state=present
120# with_items:
121# - {{ ceilometer_port }}
Scott Baker31acc652016-06-23 15:47:56 -0700122
123 - name: Make sure Monitoring channel service is running
124 service: name=monitoring-channel-{{ unique_id }} state=started
125{% endif %}
126
127 handlers:
128 - name: copy ceilo-config-file
129 shell: docker cp /usr/local/share/monitoring-channel-{{ unique_id }}_ceilometer_proxy_config monitoring-channel-{{ unique_id }}:/usr/local/share/ceilometer_proxy_config
130
131 - name: restart monitoring-channel container
132 shell: docker restart monitoring-channel-{{ unique_id }}
133
134 - name: restart monitoring-channel
135 shell: service monitoring-channel-{{ unique_id }} stop; sleep 1; service monitoring-channel-{{ unique_id }} start
136
137 - name: stop monitoring-channel
138 service: name=monitoring-channel-{{ unique_id }} state=stopped
139
140 - name: remove container
141 docker: name=monitoring-channel-{{ unique_id }} state=absent image=monitoring-channel
142
143 - name: start monitoring-channel
144 service: name=monitoring-channel-{{ unique_id }} state=started
Srikanth Vavilapalli666a2362016-11-29 21:23:05 -0600145
146 - name: set monitoring-channel-mtu
147 shell: docker exec monitoring-channel-{{ unique_id }} sudo ifconfig eth0 mtu 1450 up