blob: 35d9032b2db21d0b5be77272a89725de8b0b16dd [file] [log] [blame]
Scott Baker5a963142016-03-06 16:50:25 -08001---
2- hosts: {{ instance_name }}
3 #gather_facts: False
4 connection: ssh
5 user: ubuntu
6 sudo: yes
7 vars:
8 container_name: {{ container_name }}
9 wan_container_ip: {{ wan_container_ip }}
10 wan_container_netbits: {{ wan_container_netbits }}
11 wan_container_mac: {{ wan_container_mac }}
12 wan_container_gateway_ip: {{ wan_container_gateway_ip }}
13 wan_vm_ip: {{ wan_vm_ip }}
14 wan_vm_mac: {{ wan_vm_mac }}
15
Scott Bakerb9a4dd52016-03-07 14:58:20 -080016 scope: {{ scope }}
Scott Baker5a963142016-03-06 16:50:25 -080017 test: {{ test }}
18 argument: {{ argument }}
Scott Baker40272242016-03-08 15:31:36 -080019 result_fn: {{ result_fn }}
20 resultcode_fn: {{ resultcode_fn }}
Scott Baker5a963142016-03-06 16:50:25 -080021
22
23 tasks:
Scott Baker6b919f02016-03-07 14:26:00 -080024 - name: Remove any old result file
Scott Baker5a963142016-03-06 16:50:25 -080025 shell: rm -f /tmp/{{ result_fn }}
Scott Baker5a963142016-03-06 16:50:25 -080026
Scott Baker6b919f02016-03-07 14:26:00 -080027 - name: Copy run_tcpdump.sh to VM
28 copy: src=/opt/xos/synchronizers/vtr/files/run_tcpdump.sh dest=/root/run_tcpdump.sh mode=0755
29 when: (test=="tcpdump")
30
31
32# -----------------
33# scope == VM
34# -----------------
35
36 - name: Send the pings from VM
37 shell: ping -c 10 {{ argument }} 2>&1 > /tmp/{{ result_fn }}
38 ignore_errors: yes
Scott Baker40272242016-03-08 15:31:36 -080039 register: vm_ping_result
40 when: (scope=="vm") and (test=="ping")
41
42 - name: Store VM ping resultcode to file
43 shell: echo "{{ '{{' }} vm_ping_result.rc {{ '}}' }}" > /tmp/{{ resultcode_fn }}
Scott Baker6b919f02016-03-07 14:26:00 -080044 when: (scope=="vm") and (test=="ping")
45
46 - name: Install traceroute
47 apt: name=traceroute state=present
48 when: (scope=="vm") and (test=="traceroute")
49
50 - name: Send traceroute from VM
51 shell: traceroute {{ argument }} 2>&1 > /tmp/{{ result_fn }}
52 ignore_errors: yes
Scott Baker40272242016-03-08 15:31:36 -080053 register: vm_traceroute_result
54 when: (scope=="vm") and (test=="traceroute")
55
56 - name: Store VM traceroute resultcode to file
57 shell: echo "{{ '{{' }} vm_traceroute_result.rc {{ '}}' }}" > /tmp/{{ resultcode_fn }}
Scott Baker6b919f02016-03-07 14:26:00 -080058 when: (scope=="vm") and (test=="traceroute")
59
60 - name: Run tcpdump for 30 seconds on VM
61 shell: /root/run_tcpdump.sh {{ argument }} 2>&1 > /tmp/{{ result_fn }}
62 ignore_errors: yes
Scott Baker40272242016-03-08 15:31:36 -080063 register: vm_tcpdump_result
64 when: (scope=="vm") and (test=="tcpdump")
65
66 - name: Store VM tcpdump resultcode to file
67 shell: echo "{{ '{{' }} vm_tcpdump_result.rc {{ '}}' }}" > /tmp/{{ resultcode_fn }}
Scott Baker6b919f02016-03-07 14:26:00 -080068 when: (scope=="vm") and (test=="tcpdump")
69
70# ------------------
71# scope == container
72# ------------------
73
74 - name: Send the pings from Container
75 shell: docker exec {{ container_name }} ping -c 10 {{ argument }} 2>&1 > /tmp/{{ result_fn }}
76 ignore_errors: yes
Scott Baker40272242016-03-08 15:31:36 -080077 register: ctr_ping_result
78 when: (scope=="container") and (test=="ping")
79
80 - name: Store ctr ping resultcode to file
81 shell: echo "{{ '{{' }} ctr_ping_result.rc {{ '}}' }}" > /tmp/{{ resultcode_fn }}
Scott Baker6b919f02016-03-07 14:26:00 -080082 when: (scope=="container") and (test=="ping")
83
84 - name: Install traceroute into Container
85 shell: docker exec {{ container_name }} apt-get -y install traceroute
86 when: (scope=="container") and (test=="traceroute")
87
88 - name: Send traceroute from Container
89 shell: docker exec {{ container_name }} traceroute {{ argument }} 2>&1 > /tmp/{{ result_fn }}
90 ignore_errors: yes
Scott Baker40272242016-03-08 15:31:36 -080091 register: ctr_traceroute_result
92 when: (scope=="container") and (test=="traceroute")
93
94 - name: Store ctr traceroute resultcode to file
95 shell: echo "{{ '{{' }} ctr_traceroute_result.rc {{ '}}' }}" > /tmp/{{ resultcode_fn }}
Scott Baker6b919f02016-03-07 14:26:00 -080096 when: (scope=="container") and (test=="traceroute")
97
98 - name: Copy run_tcpdump.sh to container
99 command: docker cp /root/run_tcpdump.sh {{ container_name }}:/root/run_tcpdump.sh
100 when: (scope=="container") and (test=="tcpdump")
101
102 - name: Run tcpdump for 30 seconds from Container
103 shell: docker exec {{ container_name }} /root/run_tcpdump.sh {{ argument }} 2>&1 > /tmp/{{ result_fn }}
104 ignore_errors: yes
Scott Baker40272242016-03-08 15:31:36 -0800105 register: diagresult
106 when: (scope=="container") and (test=="tcpdump")
107
108 - name: Store ctr tcpdump resultcode to file
109 shell: echo "{{ '{{' }} ctr_tcpdump_result.rc {{ '}}' }}" > /tmp/{{ resultcode_fn }}
Scott Baker6b919f02016-03-07 14:26:00 -0800110 when: (scope=="container") and (test=="tcpdump")
111
112# ------------------
113# scope == *
114# ------------------
Scott Baker6b919f02016-03-07 14:26:00 -0800115 - name: Fetch the result
Scott Baker5a963142016-03-06 16:50:25 -0800116 fetch: src=/tmp/{{ result_fn }} dest=/opt/xos/synchronizers/vtr/result/{{ result_fn }} flat=yes
Scott Baker6b919f02016-03-07 14:26:00 -0800117
Scott Baker40272242016-03-08 15:31:36 -0800118 - name: Fetch the resultcode
119 fetch: src=/tmp/{{ resultcode_fn }} dest=/opt/xos/synchronizers/vtr/result/{{ resultcode_fn }} flat=yes
120
Scott Baker6b919f02016-03-07 14:26:00 -0800121
122
Scott Baker5a963142016-03-06 16:50:25 -0800123