Created
March 22, 2017 11:17
-
-
Save btotr/22d9b239ab6b50b608be58285422cd24 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ansible-playbook -i inventory tcpdump.yml --extra-vars "target=stitchers" | |
- hosts: '{{ target }}' | |
become: yes | |
become_method: sudo | |
vars: | |
cap_file: packet_capture_{{ ansible_hostname }}_{{ ansible_date_time['epoch'] }}.cap | |
tasks: | |
- name: start tcpdump | |
command: /usr/sbin/tcpdump -i any -s 0 -w /tmp/{{ cap_file }} | |
async: 60 | |
poll: 0 | |
- pause: minutes=1 prompt="pause for 60 seconds or press Ctrl + c then c to continue" | |
- name: kill tcpdump | |
command: /usr/bin/pkill tcpdump | |
- name: compress capture file | |
command: gzip {{ cap_file }} chdir=/tmp | |
- name: copy logs to local boxes webroot | |
fetch: src=/tmp/{{ cap_file }}.gz dest=/tmp/ flat=yes | |
- name: remove files from server | |
file: path=/tmp/{{ cap_file }}.gz state=absent |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment