Skip to content

Instantly share code, notes, and snippets.

@ghoneycutt
Last active August 29, 2015 14:17
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 ghoneycutt/03102b7f95f09bf45af9 to your computer and use it in GitHub Desktop.
Save ghoneycutt/03102b7f95f09bf45af9 to your computer and use it in GitHub Desktop.
#!/bin/bash
#
# License: GPLv2
#
# Quick and dirty shell script for taking a file with one package per line and
# turning that into valid YAML to use in conjunction with puppet-module-types
# and Hiera.
#
# Given a file, 'package_list' with contents
#
# foo
# bar
# baz
#
# The following output is generated
#
# types::packages:
# 'foo':
# ensure: 'present'
# 'bar':
# ensure: 'present'
# 'baz':
# ensure: 'present'
#
if [ $# -ne 1 ]; then
echo "Must supply one argument - a file with one package per line"
exit 1
fi
echo -e "types::packages:"
for package in $(cat $1)
do
echo -e " '${package}':\n ensure: 'present'"
done
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment