aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSilvio Rhatto <rhatto@riseup.net>2018-05-27 10:00:01 -0300
committerSilvio Rhatto <rhatto@riseup.net>2018-05-27 10:00:01 -0300
commit77226079874216a22563cff089fcc4b2211bf30d (patch)
tree59c525125fb53ba97d7dab1bf731106f2371675c
parent62ebbcf86b038fd01891a154c203f58ad434d89e (diff)
downloadhydra-77226079874216a22563cff089fcc4b2211bf30d.tar.gz
hydra-77226079874216a22563cff089fcc4b2211bf30d.tar.bz2
Ansible support at init and newnode
-rw-r--r--lib/hydra/misc1
-rwxr-xr-xshare/hydra/init7
-rwxr-xr-xshare/hydra/newnode24
-rw-r--r--share/puppet/nodo.example.org.yaml (renamed from share/config/puppet/nodo.example.org.yaml)0
-rw-r--r--share/puppet/secrets/nodo.example.org.yaml (renamed from share/config/puppet/secrets/nodo.example.org.yaml)0
5 files changed, 26 insertions, 6 deletions
diff --git a/lib/hydra/misc b/lib/hydra/misc
index 77c2988..2c5789b 100644
--- a/lib/hydra/misc
+++ b/lib/hydra/misc
@@ -176,6 +176,7 @@ function hydra_hiera_query {
local param="$2"
# Build basic query command
+ # There might be weird hiera errors, so that's why we're doing a "2> /dev/null" redirection
hiera="hiera --config $HYDRA_FOLDER/puppet/hiera.yaml"
hiera_params="settings::confdir=$HYDRA_FOLDER/puppet ::clientcert=$node"
role="`$hiera nodo::role $hiera_params 2> /dev/null`"
diff --git a/share/hydra/init b/share/hydra/init
index 80dd449..3cf3074 100755
--- a/share/hydra/init
+++ b/share/hydra/init
@@ -107,12 +107,17 @@ else
# Create puppet repository
if [ ! -d "$BASEDIR/puppet" ]; then
echo "Cloning initial puppet repository..."
- git clone git://git.fluxo.info/puppet-bootstrap.git $BASEDIR/puppet
+ git clone https://git.fluxo.info/puppet-bootstrap $BASEDIR/puppet
# Config puppet
echo "Configuring puppet repository..."
hydra_bootstrap_config $BASEDIR/puppet
fi
+
+ # Create ansible repository
+ mkdir -p $BASEDIR/ansible
+ cp -r $APP_BASE/share/ansible $BASEDIR/ansible
+ hydra_git_init $BASEDIR/ansible
fi
# Reparse basedir to force absolute folder
diff --git a/share/hydra/newnode b/share/hydra/newnode
index 96861f6..78cd6cb 100755
--- a/share/hydra/newnode
+++ b/share/hydra/newnode
@@ -51,10 +51,12 @@ if [ ! -z "$ROLE" ]; then
fi
# Set YAML template
-if [ -e "$HYDRA_FOLDER/config/puppet/nodo.example.org.yaml" ]; then
+if [ -e "$HYDRA_FOLDER/puppet/nodo.example.org.yaml" ]; then
+ YAML="$HYDRA_FOLDER/puppet/nodo.example.org.yaml"
+elif [ -e "$HYDRA_FOLDER/config/puppet/nodo.example.org.yaml" ]; then
YAML="$HYDRA_FOLDER/config/puppet/nodo.example.org.yaml"
else
- YAML="$APP_BASE/share/config/puppet/nodo.example.org.yaml"
+ YAML="$APP_BASE/share/puppet/nodo.example.org.yaml"
fi
# Copy YAML template
@@ -67,10 +69,12 @@ if [ ! -z "$ROLE" ]; then
fi
# Set secret YAML template
-if [ -e "$HYDRA_FOLDER/config/puppet/secrets/nodo.example.org.yaml" ]; then
+if [ -e "$HYDRA_FOLDER/puppet/secrets/nodo.example.org.yaml" ]; then
+ YAML="$HYDRA_FOLDER/puppet/secrets/nodo.example.org.yaml"
+elif [ -e "$HYDRA_FOLDER/config/puppet/secrets/nodo.example.org.yaml" ]; then
YAML="$HYDRA_FOLDER/config/puppet/secrets/nodo.example.org.yaml"
else
- YAML="$APP_BASE/share/config/puppet/secrets/nodo.example.org.yaml"
+ YAML="$APP_BASE/share/puppet/secrets/nodo.example.org.yaml"
fi
# Setup secret YAML template
@@ -90,12 +94,19 @@ echo "" >> $HYDRA_FOLDER/puppet/config/secrets/node/$NODE.yaml
keyringer $HYDRA decrypt nodes/$NODE/gpg/key.passwd | \
hydra fluxo eyaml $NODE encrypt --stdin -o block -q -l nodo::subsystem::backup::password >> $HYDRA_FOLDER/puppet/config/secrets/node/$NODE.yaml
-echo "" >> $HYDRA_FOLDER/puppet/config/secrets/node/$NODE.yam
+echo "" >> $HYDRA_FOLDER/puppet/config/secrets/node/$NODE.yaml
# Add Borg passphrase into secret node config
keyringer $HYDRA decrypt nodes/$NODE/borg/key.passwd | \
hydra fluxo eyaml $NODE encrypt --stdin -o block -q -l nodo::subsystem::backup::borg::password >> $HYDRA_FOLDER/puppet/config/secrets/node/$NODE.yaml
+# Ansible config
+if [ -e "$HYDRA_FOLDER/ansible/inventories/production/hosts" ]; then
+ echo "$NODE" >> $HYDRA_FOLDER/ansible/inventories/production/hosts
+elif [ -e "$HYDRA_FOLDER/ansible/inventories/hosts" ]; then
+ echo "$NODE" >> $HYDRA_FOLDER/ansible/inventories/hosts
+fi
+
# Add to git
(
cd $HYDRA_FOLDER/puppet
@@ -105,4 +116,7 @@ hydra fluxo eyaml $NODE encrypt --stdin -o block -q -l nodo::subsystem::backup::
#if [ -e 'manifests/site.pp' ]; then
# git add manifests/site.pp
#fi
+
+ cd $HYDRA_FOLDER/ansible
+ git add .
)
diff --git a/share/config/puppet/nodo.example.org.yaml b/share/puppet/nodo.example.org.yaml
index 65aee56..65aee56 100644
--- a/share/config/puppet/nodo.example.org.yaml
+++ b/share/puppet/nodo.example.org.yaml
diff --git a/share/config/puppet/secrets/nodo.example.org.yaml b/share/puppet/secrets/nodo.example.org.yaml
index b2242bd..b2242bd 100644
--- a/share/config/puppet/secrets/nodo.example.org.yaml
+++ b/share/puppet/secrets/nodo.example.org.yaml