Script: Puppet module create template

Adjust to your needs ;)

#!/bin/bash

# Create puppet module layout

if [[ -z "$1" ]];then
  echo "$0 modulename"
  exit 1
fi


if [[ -d $1 ]]; then
  echo "Dir already exists"
  exit 1
fi

# Actual work
M=$1

mkdir -p \
  $M \
  $M/files \
  $M/manifests \
  $M/templates 

# Files
cat < $M/manifests/init.pp
# \$Id$ 
class $M {
  require $M::params

  include $M::install
  include $M::config
  include $M::service
  include $M::monitor
}
EOF

# Init files
for file in params config install service monitor ; do 
  echo "class $M::$file {" > $M/manifests/${file}.pp
done

# Requirements
cat <> $M/manifests/config.pp
  require $M::install

EOF
cat <> $M/manifests/service.pp
  require $M::config
  
EOF
cat <> $M/manifests/monitor.pp
  require $M::service
  
EOF

# End files
for file in params config install service monitor ; do 
  echo "}" >> $M/manifests/${file}.pp
done

tree $M