Scott Baker | 171d35e | 2016-06-20 17:36:29 -0700 | [diff] [blame] | 1 | --- |
| 2 | - hosts: {{ instance_name }} |
| 3 | #gather_facts: False |
| 4 | connection: ssh |
| 5 | user: ubuntu |
Sapan Bhatia | 77a52f1 | 2017-02-07 11:32:57 -0800 | [diff] [blame] | 6 | become: yes |
Scott Baker | 171d35e | 2016-06-20 17:36:29 -0700 | [diff] [blame] | 7 | vars: |
| 8 | container_name: {{ container_name }} |
Scott Baker | 171d35e | 2016-06-20 17:36:29 -0700 | [diff] [blame] | 9 | 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 Baker | 4efbe56 | 2016-09-30 16:06:19 -0700 | [diff] [blame] | 53 | - name: Run tcpdump for 10 seconds on VM |
Scott Baker | 171d35e | 2016-06-20 17:36:29 -0700 | [diff] [blame] | 54 | 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 | |
Scott Baker | 3a5b8e1 | 2017-03-31 14:22:20 -0700 | [diff] [blame] | 77 | - name: Checking memory utilization |
| 78 | shell: docker exec {{ container_name }} free {{ '-m' if argument== 'mb' else '-h' }} 2>&1 > /tmp/{{ result_fn }} |
| 79 | ignore_errors: yes |
| 80 | register: ctr_memory_result |
| 81 | when: (scope=="container") and (test=="memory") |
| 82 | |
| 83 | - name: Store container health resultcode to file |
| 84 | shell: echo "{{ '{{' }} ctr_memory_result.rc {{ '}}' }}" > /tmp/{{ resultcode_fn }} |
| 85 | when: (scope=="container") and (test=="memory") |
| 86 | |
| 87 | - name: Install iperf into Host vm |
| 88 | shell: apt-get -y install iperf |
| 89 | when: (scope=="container") and (test=="bandwidth") |
| 90 | |
| 91 | - name: Install iperf into Container |
| 92 | shell: docker exec {{ container_name }} apt-get -y install iperf |
| 93 | when: (scope=="container") and (test=="bandwidth") |
| 94 | |
| 95 | - name: Starting the iperf server in Host vm for uplink_upload |
| 96 | shell: iperf -s -u |
| 97 | async: 10 |
| 98 | poll: 0 |
| 99 | when: (scope=="container") and (test=="bandwidth") and (argument=="uplink_upload") |
| 100 | |
| 101 | - name: Starting the iperf client in vsg container for uplink_upload |
| 102 | shell: docker exec {{ container_name }} iperf -c {{ wan_vm_ip }} -u -b 1000M 2>&1 > /tmp/{{ result_fn }} |
| 103 | ignore_errors: yes |
| 104 | register: ctr_bw_upload_result |
| 105 | when: (scope=="container") and (test=="bandwidth") and (argument=="uplink_upload") |
| 106 | |
| 107 | - name: Starting the iperf server in vsg container for uplink_download |
| 108 | shell: docker exec {{ container_name }} iperf -s -u |
| 109 | async: 10 |
| 110 | poll: 0 |
| 111 | when: (scope=="container") and (test=="bandwidth") and (argument=="uplink_download") |
| 112 | |
| 113 | - name: Starting the iperf client in the host vm for uplink_download |
| 114 | shell: iperf -c {{ wan_container_ip }} -u -b 1000M 2>&1 > /tmp/{{ result_fn }} |
| 115 | ignore_errors: yes |
| 116 | register: ctr_bw_download_result |
| 117 | when: (scope=="container") and (test=="bandwidth") and (argument=="uplink_download") |
| 118 | |
| 119 | - name: Uninstall iperf from Container |
| 120 | shell: docker exec {{ container_name }} apt-get -y remove iperf |
| 121 | when: (scope=="container") and (test=="bandwidth") |
| 122 | |
| 123 | - name: Store upload bandwidth resultcode to file |
| 124 | shell: echo "{{ '{{' }} ctr_bw_upload_result.rc {{ '}}' }}" > /tmp/{{ resultcode_fn }} |
| 125 | when: (scope=="container") and (test=="bandwidth") and (argument=="uplink_upload") |
| 126 | |
| 127 | - name: Store download bandwidth resultcode to file |
| 128 | shell: echo "{{ '{{' }} ctr_bw_download_result.rc {{ '}}' }}" > /tmp/{{ resultcode_fn }} |
| 129 | when: (scope=="container") and (test=="bandwidth") and (argument=="uplink_download") |
| 130 | |
Scott Baker | 171d35e | 2016-06-20 17:36:29 -0700 | [diff] [blame] | 131 | - name: Install traceroute into Container |
| 132 | shell: docker exec {{ container_name }} apt-get -y install traceroute |
| 133 | when: (scope=="container") and (test=="traceroute") |
| 134 | |
| 135 | - name: Send traceroute from Container |
| 136 | shell: docker exec {{ container_name }} traceroute {{ argument }} 2>&1 > /tmp/{{ result_fn }} |
| 137 | ignore_errors: yes |
| 138 | register: ctr_traceroute_result |
| 139 | when: (scope=="container") and (test=="traceroute") |
| 140 | |
| 141 | - name: Store ctr traceroute resultcode to file |
| 142 | shell: echo "{{ '{{' }} ctr_traceroute_result.rc {{ '}}' }}" > /tmp/{{ resultcode_fn }} |
| 143 | when: (scope=="container") and (test=="traceroute") |
| 144 | |
| 145 | - name: Copy run_tcpdump.sh to container |
| 146 | command: docker cp /root/run_tcpdump.sh {{ container_name }}:/root/run_tcpdump.sh |
| 147 | when: (scope=="container") and (test=="tcpdump") |
| 148 | |
Scott Baker | 4efbe56 | 2016-09-30 16:06:19 -0700 | [diff] [blame] | 149 | - name: Run tcpdump for 10 seconds from Container |
Scott Baker | 171d35e | 2016-06-20 17:36:29 -0700 | [diff] [blame] | 150 | shell: docker exec {{ container_name }} /root/run_tcpdump.sh {{ argument }} 2>&1 > /tmp/{{ result_fn }} |
| 151 | ignore_errors: yes |
Scott Baker | 4efbe56 | 2016-09-30 16:06:19 -0700 | [diff] [blame] | 152 | register: ctr_tcpdump_result |
Scott Baker | 171d35e | 2016-06-20 17:36:29 -0700 | [diff] [blame] | 153 | when: (scope=="container") and (test=="tcpdump") |
| 154 | |
| 155 | - name: Store ctr tcpdump resultcode to file |
| 156 | shell: echo "{{ '{{' }} ctr_tcpdump_result.rc {{ '}}' }}" > /tmp/{{ resultcode_fn }} |
| 157 | when: (scope=="container") and (test=="tcpdump") |
| 158 | |
| 159 | # ------------------ |
| 160 | # scope == * |
| 161 | # ------------------ |
| 162 | - name: Fetch the result |
| 163 | fetch: src=/tmp/{{ result_fn }} dest=/opt/xos/synchronizers/vtr/result/{{ result_fn }} flat=yes |
| 164 | |
| 165 | - name: Fetch the resultcode |
| 166 | fetch: src=/tmp/{{ resultcode_fn }} dest=/opt/xos/synchronizers/vtr/result/{{ resultcode_fn }} flat=yes |
| 167 | |
| 168 | |
| 169 | |
| 170 | |