blob: 886916e94dea1bec9f98938e0a6cfa7dcde8cd3a [file] [log] [blame]
Scott Baker171d35e2016-06-20 17:36:29 -07001---
2- hosts: {{ instance_name }}
3 #gather_facts: False
4 connection: ssh
5 user: ubuntu
Sapan Bhatia77a52f12017-02-07 11:32:57 -08006 become: yes
Scott Baker171d35e2016-06-20 17:36:29 -07007 vars:
8 container_name: {{ container_name }}
Scott Baker171d35e2016-06-20 17:36:29 -07009 scope: {{ scope }}
10 test: {{ test }}
11 argument: {{ argument }}
12 result_fn: {{ result_fn }}
13 resultcode_fn: {{ resultcode_fn }}
14
15
16 tasks:
17 - name: Remove any old result file
18 shell: rm -f /tmp/{{ result_fn }}
19
20 - name: Copy run_tcpdump.sh to VM
21 copy: src=/opt/xos/synchronizers/vtr/files/run_tcpdump.sh dest=/root/run_tcpdump.sh mode=0755
22 when: (test=="tcpdump")
23
24
25# -----------------
26# scope == VM
27# -----------------
28
29 - name: Send the pings from VM
30 shell: ping -c 10 {{ argument }} 2>&1 > /tmp/{{ result_fn }}
31 ignore_errors: yes
32 register: vm_ping_result
33 when: (scope=="vm") and (test=="ping")
34
35 - name: Store VM ping resultcode to file
36 shell: echo "{{ '{{' }} vm_ping_result.rc {{ '}}' }}" > /tmp/{{ resultcode_fn }}
37 when: (scope=="vm") and (test=="ping")
38
39 - name: Install traceroute
40 apt: name=traceroute state=present
41 when: (scope=="vm") and (test=="traceroute")
42
43 - name: Send traceroute from VM
44 shell: traceroute {{ argument }} 2>&1 > /tmp/{{ result_fn }}
45 ignore_errors: yes
46 register: vm_traceroute_result
47 when: (scope=="vm") and (test=="traceroute")
48
49 - name: Store VM traceroute resultcode to file
50 shell: echo "{{ '{{' }} vm_traceroute_result.rc {{ '}}' }}" > /tmp/{{ resultcode_fn }}
51 when: (scope=="vm") and (test=="traceroute")
52
Scott Baker4efbe562016-09-30 16:06:19 -070053 - name: Run tcpdump for 10 seconds on VM
Scott Baker171d35e2016-06-20 17:36:29 -070054 shell: /root/run_tcpdump.sh {{ argument }} 2>&1 > /tmp/{{ result_fn }}
55 ignore_errors: yes
56 register: vm_tcpdump_result
57 when: (scope=="vm") and (test=="tcpdump")
58
59 - name: Store VM tcpdump resultcode to file
60 shell: echo "{{ '{{' }} vm_tcpdump_result.rc {{ '}}' }}" > /tmp/{{ resultcode_fn }}
61 when: (scope=="vm") and (test=="tcpdump")
62
63# ------------------
64# scope == container
65# ------------------
66
67 - name: Send the pings from Container
68 shell: docker exec {{ container_name }} ping -c 10 {{ argument }} 2>&1 > /tmp/{{ result_fn }}
69 ignore_errors: yes
70 register: ctr_ping_result
71 when: (scope=="container") and (test=="ping")
72
73 - name: Store ctr ping resultcode to file
74 shell: echo "{{ '{{' }} ctr_ping_result.rc {{ '}}' }}" > /tmp/{{ resultcode_fn }}
75 when: (scope=="container") and (test=="ping")
76
77 - name: Install traceroute into Container
78 shell: docker exec {{ container_name }} apt-get -y install traceroute
79 when: (scope=="container") and (test=="traceroute")
80
81 - name: Send traceroute from Container
82 shell: docker exec {{ container_name }} traceroute {{ argument }} 2>&1 > /tmp/{{ result_fn }}
83 ignore_errors: yes
84 register: ctr_traceroute_result
85 when: (scope=="container") and (test=="traceroute")
86
87 - name: Store ctr traceroute resultcode to file
88 shell: echo "{{ '{{' }} ctr_traceroute_result.rc {{ '}}' }}" > /tmp/{{ resultcode_fn }}
89 when: (scope=="container") and (test=="traceroute")
90
91 - name: Copy run_tcpdump.sh to container
92 command: docker cp /root/run_tcpdump.sh {{ container_name }}:/root/run_tcpdump.sh
93 when: (scope=="container") and (test=="tcpdump")
94
Scott Baker4efbe562016-09-30 16:06:19 -070095 - name: Run tcpdump for 10 seconds from Container
Scott Baker171d35e2016-06-20 17:36:29 -070096 shell: docker exec {{ container_name }} /root/run_tcpdump.sh {{ argument }} 2>&1 > /tmp/{{ result_fn }}
97 ignore_errors: yes
Scott Baker4efbe562016-09-30 16:06:19 -070098 register: ctr_tcpdump_result
Scott Baker171d35e2016-06-20 17:36:29 -070099 when: (scope=="container") and (test=="tcpdump")
100
101 - name: Store ctr tcpdump resultcode to file
102 shell: echo "{{ '{{' }} ctr_tcpdump_result.rc {{ '}}' }}" > /tmp/{{ resultcode_fn }}
103 when: (scope=="container") and (test=="tcpdump")
104
105# ------------------
106# scope == *
107# ------------------
108 - name: Fetch the result
109 fetch: src=/tmp/{{ result_fn }} dest=/opt/xos/synchronizers/vtr/result/{{ result_fn }} flat=yes
110
111 - name: Fetch the resultcode
112 fetch: src=/tmp/{{ resultcode_fn }} dest=/opt/xos/synchronizers/vtr/result/{{ resultcode_fn }} flat=yes
113
114
115
116