summaryrefslogtreecommitdiff
path: root/puppet/bin
diff options
context:
space:
mode:
authorSilvio Rhatto <rhatto@riseup.net>2015-11-06 11:01:26 -0200
committerSilvio Rhatto <rhatto@riseup.net>2015-11-06 11:01:26 -0200
commit8748f432cdb01090767001523496f096345a492b (patch)
treecba4fd0d8d4501424c7fb5e84ba37dc2cdd7fca4 /puppet/bin
parent506b62a99e35c69354e8bc977780e41117f1e6ca (diff)
parent5512c493e13998d4c83d7eab3d89e5a1c0836566 (diff)
downloaddebian-8748f432cdb01090767001523496f096345a492b.tar.gz
debian-8748f432cdb01090767001523496f096345a492b.tar.bz2
Merge commit '5512c493e13998d4c83d7eab3d89e5a1c0836566' into develop
Conflicts: puppet/puppet.conf
Diffstat (limited to 'puppet/bin')
-rwxr-xr-xpuppet/bin/dependencies8
-rwxr-xr-xpuppet/bin/deploy58
-rwxr-xr-xpuppet/bin/mrconfig8
-rwxr-xr-xpuppet/bin/post-receive7
-rwxr-xr-xpuppet/bin/post-update16
-rwxr-xr-xpuppet/bin/provision30
-rwxr-xr-xpuppet/bin/submodules2
7 files changed, 109 insertions, 20 deletions
diff --git a/puppet/bin/dependencies b/puppet/bin/dependencies
index 78ca659..507145b 100755
--- a/puppet/bin/dependencies
+++ b/puppet/bin/dependencies
@@ -1,6 +1,6 @@
#!/bin/bash
#
-# Simple shell provisioner for Vagrant instances.
+# Puppet bootstrap dependencies.
#
# Install a package, thanks to the Hydra Suite.
@@ -13,16 +13,16 @@ function provision_package {
if [ "$?" == "1" ]; then
echo "Installing package $1..."
- DEBIAN_FRONTEND=noninteractive $sudo apt-get install $1 -y
+ DEBIAN_FRONTEND=noninteractive $SUDO apt-get install $1 -y
fi
}
# Set sudo config
if [ "`whoami`" != 'root' ]; then
- sudo="sudo"
+ SUDO="sudo"
fi
# Ensure basic packages are installed.
-for package in puppet ruby-hiera-puppet mr whois; do
+for package in puppet git mr whois; do
provision_package $package
done
diff --git a/puppet/bin/deploy b/puppet/bin/deploy
new file mode 100755
index 0000000..5d3361b
--- /dev/null
+++ b/puppet/bin/deploy
@@ -0,0 +1,58 @@
+#!/bin/bash
+#
+# Deploy configuration using puppet.
+#
+
+# Parameters
+DIRNAME="`dirname $0`"
+BASEDIR="$DIRNAME/.."
+DEPLOY_DEPENDENCIES="puppet ruby-sqlite3 ruby-activerecord ruby-activerecord-deprecated-finders"
+
+# Determine hostname
+if [ ! -z "$1" ]; then
+ FQDN="$1"
+else
+ FQDN="`cat /etc/hostname`"
+fi
+
+# Check for manifest
+PUPPET_MANIFEST="$BASEDIR/puppet/manifests/nodes/$FQDN.pp"
+if [ ! -e "$PUPPET_MANIFEST" ]; then
+ echo "file not found: $PUPPET_MANIFEST"
+ exit 1
+fi
+
+# Install dependencies
+source $DIRNAME/dependencies
+
+# Ensure additional dependencies are installed.
+for package in $DEPLOY_DEPENDENCIES; do
+ provision_package $package
+done
+
+# Parameters that needs dependencies installed
+DIST="`facter lsbdistcodename`"
+
+# Apply patches
+if [ -d "$BASEDIR/puppet/files/patches/$DIST" ]; then
+ (
+ # Patches should be generated relativelly to the root folder
+ cd /
+
+ # Only apply if needed
+ # Thanks https://unix.stackexchange.com/questions/55780/check-if-a-file-or-folder-has-been-patched-already
+ for patch in `ls $BASEDIR/puppet/files/patches/$DIST`; do
+ patch -p0 -N --dry-run --silent < $BASEDIR/puppet/files/patches/$DIST/$patch &> /dev/null
+ # If the patch has not been applied then the $? which is the exit status
+ # for last command would have a success status code = 0
+ if [ "$?" == "0" ]; then
+ # Apply the patch
+ patch -p0 -N < $BASEDIR/puppet/files/patches/$DIST/$patch
+ fi
+ done
+ )
+fi
+
+# Run puppet apply
+PUPPET_OPTS="--confdir=$BASEDIR/puppet --modulepath=$BASEDIR/puppet/modules"
+LC_ALL=C $SUDO puppet apply $PUPPET_OPTS $PUPPET_MANIFEST
diff --git a/puppet/bin/mrconfig b/puppet/bin/mrconfig
index f525db3..dc753ac 100755
--- a/puppet/bin/mrconfig
+++ b/puppet/bin/mrconfig
@@ -1,10 +1,10 @@
#!/bin/bash
#
# Build a mrconfig for the needed modules.
-#
+#
# Parameters
-GIT="git.sarava.org"
+GIT="git.fluxo.info"
URL="https://$GIT/?a=project_index"
CWD="`pwd`"
WORK="`dirname $0`/.."
@@ -18,8 +18,8 @@ touch .mrconfig
curl --stderr - $URL | grep "^puppet-" | cut -d ' ' -f 1 | while read module; do
folder="`echo $module | sed -e 's/^puppet-//'`"
folder="`basename $folder .git`"
-
- if [ "$module" != "$bootstrap" ]; then
+
+ if [ "$folder" != "bootstrap" ]; then
echo "Processing $folder..."
mr config puppet/modules/$folder checkout="git clone git://$GIT/$module $folder"
fi
diff --git a/puppet/bin/post-receive b/puppet/bin/post-receive
new file mode 100755
index 0000000..996189d
--- /dev/null
+++ b/puppet/bin/post-receive
@@ -0,0 +1,7 @@
+#!/bin/sh
+
+cd ..
+unset GIT_DIR
+
+git checkout -f
+git submodule update --init --recursive
diff --git a/puppet/bin/post-update b/puppet/bin/post-update
new file mode 100755
index 0000000..48a6a16
--- /dev/null
+++ b/puppet/bin/post-update
@@ -0,0 +1,16 @@
+#!/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 e200e51..16f102f 100755
--- a/puppet/bin/provision
+++ b/puppet/bin/provision
@@ -3,25 +3,33 @@
# Simple shell provisioner for Vagrant instances.
#
-# Ensure the system is updated.
-sudo apt-get update && DEBIAN_FRONTEND=noninteractive sudo apt-get dist-upgrade -y && sudo apt-get autoremove -y && sudo apt-get clean
+# Parameters
+DIRNAME="`dirname $0`"
+
+# Load dependencies
+source $DIRNAME/dependencies
-# Install dependencies
-source /vagrant/puppet/bin/dependencies
+# Ensure the system is updated.
+$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 sqlite3 libsqlite3-ruby libactiverecord-ruby ruby-sqlite3 usbutils; do
+for package in usbutils; do
+ provision_package $package
+done
+
+# Storeconfigs support
+for package in ruby-sqlite3 ruby-activerecord ruby-activerecord-deprecated-finders; do
provision_package $package
done
-# Link hiera configuration.
+# Link hiera configuration if needed.
if [ ! -h "/etc/puppet/hiera.yaml" ]; then
- sudo rm -f /etc/puppet/hiera.yaml
- sudo ln -s /vagrant/puppet/hiera/hiera.yaml /etc/puppet/hiera.yaml
+ $SUDO rm -f /etc/puppet/hiera.yaml
+ $SUDO ln -s $DIRNAME/../hiera/hiera.yaml /etc/puppet/hiera.yaml
fi
-# Link puppet configuration.
+# Link puppet configuration if needed.
if [ ! -h "/etc/puppet/puppet.conf" ]; then
- sudo rm -f /etc/puppet/puppet.conf
- sudo ln -s /vagrant/puppet/puppet.conf /etc/puppet/puppet.conf
+ $SUDO rm -f /etc/puppet/puppet.conf
+ $SUDO ln -s $DIRNAME/../puppet.conf /etc/puppet/puppet.conf
fi
diff --git a/puppet/bin/submodules b/puppet/bin/submodules
index f79b635..3abc46d 100755
--- a/puppet/bin/submodules
+++ b/puppet/bin/submodules
@@ -20,7 +20,7 @@ for repo in $repos; do
module="`basename $repo .git | sed -e s/^puppet-//`"
if [ ! -d "modules/$module" ]; then
echo "Processing puppet module $module..."
- git submodule add $repo modules/$module
+ git submodule add -f $repo modules/$module
elif [ -e "modules/$module/.git" ]; then
# The puppet module exists and is a git submodule, so update it
( cd module/$module && git pull origin master )