Skip to content

Instantly share code, notes, and snippets.

@juanino
Created September 4, 2017 14:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save juanino/e8043be04cec2dadbbb5202bf9a6e29a to your computer and use it in GitHub Desktop.
Save juanino/e8043be04cec2dadbbb5202bf9a6e29a to your computer and use it in GitHub Desktop.
check ansible yml file for package existence in raspian (or any apt system for that matter)
# problem: you have a bunch of files in some ansible playbook but some don't exist
# solution: apt-cache show each of them and check return code $?
cat pi-base.yml | grep "\- " | grep -v name\: | grep -v hosts\: | sed 's/.*- //g' | awk {'print "echo -n " $1 " ; apt-cache show " $1 " 1>/dev/null ;echo \" \" $?" '} | sh | tee /tmp/output
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment