Skip to content

Instantly share code, notes, and snippets.

View lextoumbourou's full-sized avatar

Lex Toumbourou lextoumbourou

View GitHub Profile
@lextoumbourou
lextoumbourou / auto_nested_dict.py
Created December 7, 2014 02:31
Super simple auto nested dict in Python
from collections import defaultdict
def auto_nested_dict():
return defaultdict(auto_nested_dict)
if __name __ == '__main__':
d = auto_nested_dict()
d['wats']['up']['world'] = 'Here I am!'
(ENV)> ls -1 /var/www/ | grep packet_capture
packet_capture_server1_1376450197.cap.gz
packet_capture_server2_1376450500.cap.gz
packet_capture_server3_1376451234.cap.gz
(ENV)> ansible-playbook parallel-tcpdump.yml -i hosts
- name: remove files from server
file: path=/tmp/${cap_file}.gz state=absent
- name: compress capture file
command: gzip ${cap_file} chdir=/tmp
- name: copy logs to local boxes webroot
fetch: src=/tmp/${cap_file}.gz dest=/var/www/ flat=yes
- name: kill tcpdump
command: /usr/bin/pkill tcpdump
ignore_errors: yes
- pause: minutes=1 prompt="pause for 60 seconds or press Ctrl + c then c to continue"
tasks:
- name: start tcpdump
command: /usr/sbin/tcpdump -i eth0 -s 0 -w /tmp/${cap_file}
async: 60
poll: 0
- hosts: all
sudo: yes
vars:
cap_file: packet_capture_{{ ansible_hostname }}_{{ ansible_date_time['epoch'] }}.cap