diff options
author | Silvio Rhatto <rhatto@riseup.net> | 2017-10-23 19:43:47 -0200 |
---|---|---|
committer | Silvio Rhatto <rhatto@riseup.net> | 2017-10-23 19:43:47 -0200 |
commit | b45c60df8af294fe97b8912a0b9703c76e5de8d6 (patch) | |
tree | 2a3442f2e0b3c7494cc591ac8c8053d84c3c9d84 /puppet/bin | |
parent | c880b15f013c6d761e4632570112f796ffc1dcda (diff) | |
parent | 1bfffe2e0adff6e44ec33726988b64f95ea2f599 (diff) | |
download | debian-b45c60df8af294fe97b8912a0b9703c76e5de8d6.tar.gz debian-b45c60df8af294fe97b8912a0b9703c76e5de8d6.tar.bz2 |
Merge commit '1bfffe2e0adff6e44ec33726988b64f95ea2f599' into develop
Diffstat (limited to 'puppet/bin')
-rwxr-xr-x | puppet/bin/dependencies | 33 | ||||
-rwxr-xr-x | puppet/bin/deploy | 14 | ||||
-rwxr-xr-x | puppet/bin/mrconfig | 7 | ||||
-rwxr-xr-x | puppet/bin/post-receive | 12 | ||||
-rwxr-xr-x | puppet/bin/post-update | 16 | ||||
-rwxr-xr-x | puppet/bin/provision | 11 |
6 files changed, 51 insertions, 42 deletions
diff --git a/puppet/bin/dependencies b/puppet/bin/dependencies index 507145b..4330730 100755 --- a/puppet/bin/dependencies +++ b/puppet/bin/dependencies @@ -3,6 +3,26 @@ # Puppet bootstrap dependencies. # +# Parameters +BASENAME="`basename $0`" +DEPLOY_DEPENDENCIES="rsync puppet-common hiera-eyaml" +DEVELOP_DEPENDENCIES="git mr whois hiera-eyaml" + +# Additional wheezy dependencies if not using puppet-common from wheezy-backports +#if [ "`head -c 1 /etc/debian_version`" == '7' ]; then +# DEPLOY_DEPENDENCIES="$DEPLOY_DEPENDENCIES ruby-hiera-puppet" +#fi + +# Set sudo config +if [ "`whoami`" != 'root' ]; then + SUDO="sudo" + + if ! sudo -n true; then + echo "Please set passwordless sudo." + exit 1 + fi +fi + # Install a package, thanks to the Hydra Suite. function provision_package { if [ -z "$1" ]; then @@ -17,12 +37,9 @@ function provision_package { fi } -# Set sudo config -if [ "`whoami`" != 'root' ]; then - SUDO="sudo" -fi - # Ensure basic packages are installed. -for package in puppet git mr whois; do - provision_package $package -done +if [ "$BASENAME" == "dependencies" ]; then + for package in $DEVELOP_DEPENDENCIES; do + provision_package $package + done +fi diff --git a/puppet/bin/deploy b/puppet/bin/deploy index 5d3361b..22065dc 100755 --- a/puppet/bin/deploy +++ b/puppet/bin/deploy @@ -6,7 +6,6 @@ # Parameters DIRNAME="`dirname $0`" BASEDIR="$DIRNAME/.." -DEPLOY_DEPENDENCIES="puppet ruby-sqlite3 ruby-activerecord ruby-activerecord-deprecated-finders" # Determine hostname if [ ! -z "$1" ]; then @@ -15,10 +14,15 @@ else FQDN="`cat /etc/hostname`" fi -# Check for manifest -PUPPET_MANIFEST="$BASEDIR/puppet/manifests/nodes/$FQDN.pp" +# Set manifest +PUPPET_MANIFEST="$BASEDIR/manifests/nodes/$FQDN.pp" if [ ! -e "$PUPPET_MANIFEST" ]; then - echo "file not found: $PUPPET_MANIFEST" + PUPPET_MANIFEST="$BASEDIR/manifests/nodes/default.pp" +fi + +# Check manifest +if [ ! -e "$PUPPET_MANIFEST" ]; then + echo "No manifest found for $FQDN" exit 1 fi @@ -54,5 +58,5 @@ if [ -d "$BASEDIR/puppet/files/patches/$DIST" ]; then fi # Run puppet apply -PUPPET_OPTS="--confdir=$BASEDIR/puppet --modulepath=$BASEDIR/puppet/modules" +PUPPET_OPTS="--confdir=$BASEDIR --modulepath=$BASEDIR/modules" LC_ALL=C $SUDO puppet apply $PUPPET_OPTS $PUPPET_MANIFEST diff --git a/puppet/bin/mrconfig b/puppet/bin/mrconfig index dc753ac..48815c1 100755 --- a/puppet/bin/mrconfig +++ b/puppet/bin/mrconfig @@ -5,7 +5,7 @@ # Parameters GIT="git.fluxo.info" -URL="https://$GIT/?a=project_index" +URL="https://$GIT/projects.list" CWD="`pwd`" WORK="`dirname $0`/.." @@ -15,13 +15,12 @@ rm -f .mrconfig touch .mrconfig # Fetch repository list and updtate mrconfig -curl --stderr - $URL | grep "^puppet-" | cut -d ' ' -f 1 | while read module; do +curl --stderr - $URL | grep "^puppet-" | cut -d ' ' -f 1 | sed -e 's/\.git$//' | while read module; do folder="`echo $module | sed -e 's/^puppet-//'`" - folder="`basename $folder .git`" if [ "$folder" != "bootstrap" ]; then echo "Processing $folder..." - mr config puppet/modules/$folder checkout="git clone git://$GIT/$module $folder" + mr config puppet/modules/$folder checkout="git clone https://$GIT/$module $folder" fi done diff --git a/puppet/bin/post-receive b/puppet/bin/post-receive index 996189d..e6baa07 100755 --- a/puppet/bin/post-receive +++ b/puppet/bin/post-receive @@ -3,5 +3,15 @@ cd .. unset GIT_DIR -git checkout -f +if [ -d ".git/annex" ]; then + git annex sync +else + #git reset HEAD + git checkout -f +fi + +git submodule sync --recursive git submodule update --init --recursive + +cd - +exec git update-server-info diff --git a/puppet/bin/post-update b/puppet/bin/post-update deleted file mode 100755 index 48a6a16..0000000 --- a/puppet/bin/post-update +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/sh - -cd .. -unset GIT_DIR - -if [ -d ".git/annex" ]; then - git annex sync -else - git reset HEAD - git checkout -f -fi - -git submodule update --init --recursive - -cd - -exec git update-server-info diff --git a/puppet/bin/provision b/puppet/bin/provision index 16f102f..99cb862 100755 --- a/puppet/bin/provision +++ b/puppet/bin/provision @@ -13,23 +13,18 @@ source $DIRNAME/dependencies $SUDO apt-get update && DEBIAN_FRONTEND=noninteractive $SUDO apt-get dist-upgrade -y && $SUDO apt-get autoremove -y && $SUDO apt-get clean # Ensure additional dependencies are installed. -for package in usbutils; do - provision_package $package -done - -# Storeconfigs support -for package in ruby-sqlite3 ruby-activerecord ruby-activerecord-deprecated-finders; do +for package in $DEPLOY_DEPENDENCIES; do provision_package $package done # Link hiera configuration if needed. if [ ! -h "/etc/puppet/hiera.yaml" ]; then $SUDO rm -f /etc/puppet/hiera.yaml - $SUDO ln -s $DIRNAME/../hiera/hiera.yaml /etc/puppet/hiera.yaml + $SUDO ln -s $DIRNAME/../config/hiera.yaml /etc/puppet/hiera.yaml fi # Link puppet configuration if needed. -if [ ! -h "/etc/puppet/puppet.conf" ]; then +if [ ! -h "/etc/puppet/puppet.conf" ] && [ -e "$DIRNAME/../puppet.conf" ]; then $SUDO rm -f /etc/puppet/puppet.conf $SUDO ln -s $DIRNAME/../puppet.conf /etc/puppet/puppet.conf fi |