Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@dysinger
Last active August 29, 2015 13:56
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dysinger/9260653 to your computer and use it in GitHub Desktop.
Save dysinger/9260653 to your computer and use it in GitHub Desktop.
Boto w/ GNU-Parallel for Reports & Actions

Using Boto & GNU-Parallel Together

For mass destruction (j/k I mean powerful data gathering)

Useful Prelude of Functions

function ec2 {
    list_instances -f instance-state-name=running -r $1 -t -H Hostname
}

function job {
    parallel --jobs 8 --tag --onall --sshloginfile - ::: $@
}

Using them together (example). NOTE: You need Boto's AWS ACCESS KEY & SECRET env vars setup first. Then you may call the boto function (like 'ec2' above) in your shell.

ec2 us-east-1|job uptime

Let's build a CSV report function

function chef-version {
    job "([[ -f /etc/chef/client.pem ]] && echo -n client,) || \
           (which chef-solo>/dev/null && echo -n solo,)   || \
           echo -n MISSING,; \
         (which chef-solo>/dev/null && chef-solo --version|cut -d' ' -f2) || \
           echo MISSING;" \
      | tr '\t' ','
}

Produce a CSV report of all the versions of chef we have out there.

ec2 us-east-1|chef-version|tee report.csv
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment