summaryrefslogtreecommitdiff
path: root/puppet/bin
diff options
context:
space:
mode:
authorSilvio Rhatto <rhatto@riseup.net>2014-09-18 12:47:46 -0300
committerSilvio Rhatto <rhatto@riseup.net>2014-09-18 12:47:46 -0300
commit84baf3dfea376e4b35156acc682f93bfae7e23eb (patch)
tree570011bbabc460651c61640a9ecb07b2b83b21cf /puppet/bin
parent12bedcb9dc59316fcbb38bf1592ef73dace30d15 (diff)
parent529cd5077e3d76c1d5b612bc146ab174d7143c30 (diff)
downloaddebian-84baf3dfea376e4b35156acc682f93bfae7e23eb.tar.gz
debian-84baf3dfea376e4b35156acc682f93bfae7e23eb.tar.bz2
Merge commit '529cd5077e3d76c1d5b612bc146ab174d7143c30' as 'puppet'
Diffstat (limited to 'puppet/bin')
-rwxr-xr-xpuppet/bin/dependencies28
-rwxr-xr-xpuppet/bin/mrconfig29
-rwxr-xr-xpuppet/bin/provision21
-rwxr-xr-xpuppet/bin/submodules31
-rwxr-xr-xpuppet/bin/subtrees41
-rwxr-xr-xpuppet/bin/symlinks24
6 files changed, 174 insertions, 0 deletions
diff --git a/puppet/bin/dependencies b/puppet/bin/dependencies
new file mode 100755
index 0000000..78ca659
--- /dev/null
+++ b/puppet/bin/dependencies
@@ -0,0 +1,28 @@
+#!/bin/bash
+#
+# Simple shell provisioner for Vagrant instances.
+#
+
+# Install a package, thanks to the Hydra Suite.
+function provision_package {
+ if [ -z "$1" ]; then
+ return
+ fi
+
+ dpkg -s $1 &> /dev/null
+
+ if [ "$?" == "1" ]; then
+ echo "Installing package $1..."
+ DEBIAN_FRONTEND=noninteractive $sudo apt-get install $1 -y
+ fi
+}
+
+# Set sudo config
+if [ "`whoami`" != 'root' ]; then
+ sudo="sudo"
+fi
+
+# Ensure basic packages are installed.
+for package in puppet ruby-hiera-puppet mr whois; do
+ provision_package $package
+done
diff --git a/puppet/bin/mrconfig b/puppet/bin/mrconfig
new file mode 100755
index 0000000..ffb0438
--- /dev/null
+++ b/puppet/bin/mrconfig
@@ -0,0 +1,29 @@
+#!/bin/bash
+#
+# Build a mrconfig for the needed modules.
+#
+
+# Parameters
+GIT="git.sarava.org"
+URL="https://$GIT/?a=project_index"
+CWD="`pwd`"
+WORK="`dirname $0`/.."
+
+# Create a new config
+cd $WORK
+rm -f .mrconfig
+touch .mrconfig
+
+# Fetch repository list and updtate mrconfig
+curl --stderr - $URL | grep "^puppet-" | while read module; do
+ folder="`echo $module | sed -e 's/^puppet-//'`"
+ folder="`basename $folder .git`"
+
+ if [ "$module" != "$bootstrap" ];
+ echo "Processing $folder..."
+ mr config puppet/modules/$folder checkout="git clone git://$GIT/$module $folder"
+ fi
+done
+
+# Teardown
+cd $CWD
diff --git a/puppet/bin/provision b/puppet/bin/provision
new file mode 100755
index 0000000..7fa056b
--- /dev/null
+++ b/puppet/bin/provision
@@ -0,0 +1,21 @@
+#!/bin/bash
+#
+# 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
+
+# Install dependencies
+source /vagrant/puppet/bin/dependencies
+
+# Ensure additional dependencies are installed.
+for package in sqlite3 libsqlite3-ruby libactiverecord-ruby ruby-sqlite3 usbutils; do
+ provision_package $package
+done
+
+# Make sure we have an initial hiera configuration.
+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
+fi
diff --git a/puppet/bin/submodules b/puppet/bin/submodules
new file mode 100755
index 0000000..f79b635
--- /dev/null
+++ b/puppet/bin/submodules
@@ -0,0 +1,31 @@
+#!/bin/bash
+#
+# Setup submodules.
+#
+
+# Parameters
+DIRNAME="`dirname $0`"
+
+# Usage
+function usage {
+ echo "Usage: $1 add-submodules <DIR>"
+ exit $2
+}
+
+# Get module list
+repos="`grep = $DIRNAME/../.mrconfig | cut -d = -f 2 | cut -d ' ' -f 4`"
+
+# Add submodules
+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
+ 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 )
+ fi
+done
+
+# Update all modules
+git submodule update --init
diff --git a/puppet/bin/subtrees b/puppet/bin/subtrees
new file mode 100755
index 0000000..1858a48
--- /dev/null
+++ b/puppet/bin/subtrees
@@ -0,0 +1,41 @@
+#!/bin/bash
+#
+# Setup subtrees.
+#
+
+# Parameters
+DIRNAME="`dirname $0`"
+
+# Usage
+function usage {
+ echo "Usage: $1 add-submodules <DIR>"
+ exit $2
+}
+
+# Check for git-subtree
+if ! which git-subtree &> /dev/null; then
+ echo "fatal: please install git-subtree"
+ exit 1
+fi
+
+# Get module list
+repos="`grep = $DIRNAME/../.mrconfig | cut -d = -f 2 | cut -d ' ' -f 4`"
+
+# Add subtrees
+for repo in $repos; do
+ module="`basename $repo .git | sed -e s/^puppet-//`"
+ if [ ! -d "modules/$module" ]; then
+ echo "Processing puppet module $module..."
+ git remote add $module $repo
+ git subtree add --prefix modules/$module $module master --squash
+ elif [ ! -d "modules/$module/.git" ]; then
+ # The puppet module exists and is a subtree, so update it
+ if ! git remote | grep -qe "^$module$"; then
+ git remote add $module $repo
+ fi
+
+ # Update subtrees
+ git fetch $module master
+ git subtree pull --prefix modules/$module $module master --squash
+ fi
+done
diff --git a/puppet/bin/symlinks b/puppet/bin/symlinks
new file mode 100755
index 0000000..0a221c4
--- /dev/null
+++ b/puppet/bin/symlinks
@@ -0,0 +1,24 @@
+#!/bin/bash
+#
+# Setup symlinks.
+#
+
+# Parameters
+BASENAME="`basename $0`"
+MODULES="$1"
+
+# Check parameters
+if [ -z "$MODULES" ]; then
+ echo "Usage: $BASENAME <submodules-folder>"
+ exit 1
+elif [ ! -e "$MODULES" ]; then
+ echo "Not found: $MODULES"
+fi
+
+# Add module symlinks using absolute folders
+for module in `ls $MODULES`; do
+ if [ "$module" != "bootstrap" ]; then
+ path="`cd $MODULES/$module && pwd`"
+ ( cd modules &> /dev/null && ln -sf $path )
+ fi
+done