Matteo Scandolo | eb0d11c | 2017-08-08 13:05:26 -0700 | [diff] [blame] | 1 | |
| 2 | # Copyright 2017-present Open Networking Foundation |
| 3 | # |
| 4 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | # you may not use this file except in compliance with the License. |
| 6 | # You may obtain a copy of the License at |
| 7 | # |
| 8 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | # |
| 10 | # Unless required by applicable law or agreed to in writing, software |
| 11 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | # See the License for the specific language governing permissions and |
| 14 | # limitations under the License. |
| 15 | |
| 16 | |
Scott Baker | 31acc65 | 2016-06-23 15:47:56 -0700 | [diff] [blame] | 17 | --- |
| 18 | - hosts: {{ instance_name }} |
| 19 | gather_facts: False |
| 20 | connection: ssh |
| 21 | user: ubuntu |
Sapan Bhatia | 22c5dca | 2017-02-07 11:32:56 -0800 | [diff] [blame] | 22 | become: yes |
Scott Baker | 31acc65 | 2016-06-23 15:47:56 -0700 | [diff] [blame] | 23 | vars: |
| 24 | sflow_port: {{ sflow_port }} |
| 25 | sflow_api_port: {{ sflow_api_port }} |
| 26 | |
| 27 | tasks: |
| 28 | |
| 29 | - name: Fix /etc/hosts |
| 30 | lineinfile: |
| 31 | dest=/etc/hosts |
| 32 | regexp="127.0.0.1 localhost" |
| 33 | line="127.0.0.1 localhost {{ instance_hostname }}" |
| 34 | |
| 35 | - name: Add repo key |
| 36 | apt_key: |
| 37 | keyserver=hkp://pgp.mit.edu:80 |
| 38 | id=58118E89F3A912897C070ADBF76221572C52609D |
| 39 | |
| 40 | - name: Install Docker repo |
| 41 | apt_repository: |
| 42 | repo="deb https://apt.dockerproject.org/repo ubuntu-trusty main" |
| 43 | state=present |
| 44 | |
| 45 | - name: Install Docker |
| 46 | apt: |
| 47 | name={{ '{{' }} item {{ '}}' }} |
| 48 | state=latest |
| 49 | update_cache=yes |
| 50 | with_items: |
| 51 | - docker-engine |
| 52 | - python-pip |
| 53 | - python-httplib2 |
| 54 | |
| 55 | - name: Install docker-py |
| 56 | pip: |
| 57 | name=docker-py |
| 58 | state=latest |
| 59 | |
| 60 | - name: sflow pub-sub config |
Srikanth Vavilapalli | d84b7b7 | 2016-06-28 00:19:07 +0000 | [diff] [blame] | 61 | template: src=/opt/xos/synchronizers/monitoring/templates/sflow_pub_sub/sflow_pub_sub_config.j2 dest=/usr/local/share/sflow_pub_sub.conf mode=0777 |
Scott Baker | 31acc65 | 2016-06-23 15:47:56 -0700 | [diff] [blame] | 62 | |
| 63 | - name: Start SFLOW pub-sub container |
| 64 | docker: |
| 65 | docker_api_version: "1.18" |
| 66 | name: {{ sflow_container }} |
| 67 | # was: reloaded |
| 68 | state: running |
| 69 | image: srikanthvavila/sflowpubsub |
| 70 | expose: |
| 71 | - {{ sflow_api_port }} |
| 72 | - {{ sflow_port }}/udp |
| 73 | ports: |
| 74 | - "{{ sflow_port }}:{{ sflow_port }}/udp" |
| 75 | - "{{ sflow_api_port }}:{{ sflow_api_port }}" |
| 76 | volumes: |
| 77 | - /usr/local/share/sflow_pub_sub.conf:/usr/local/share/sflow_pub_sub/sflow_pub_sub.conf |
| 78 | |
| 79 | - name: Get Docker IP |
| 80 | #TODO: copy dockerip.sh to monitoring service synchronizer |
| 81 | script: /opt/xos/synchronizers/onos/scripts/dockerip.sh {{ sflow_container }} |
| 82 | register: dockerip |
| 83 | |
| 84 | - name: Wait for SFlow service to come up |
| 85 | wait_for: |
| 86 | host={{ '{{' }} dockerip.stdout {{ '}}' }} |
| 87 | port={{ '{{' }} item {{ '}}' }} |
| 88 | state=present |
| 89 | with_items: |
| 90 | - {{ sflow_api_port }} |