]> gitweb.fluxo.info Git - hydra.git/commitdiff
Ansible support at init and newnode
authorSilvio Rhatto <rhatto@riseup.net>
Sun, 27 May 2018 13:00:01 +0000 (10:00 -0300)
committerSilvio Rhatto <rhatto@riseup.net>
Sun, 27 May 2018 13:00:01 +0000 (10:00 -0300)
lib/hydra/misc
share/hydra/init
share/hydra/newnode
share/puppet/nodo.example.org.yaml [moved from share/config/puppet/nodo.example.org.yaml with 100% similarity]
share/puppet/secrets/nodo.example.org.yaml [moved from share/config/puppet/secrets/nodo.example.org.yaml with 100% similarity]

index 77c2988b438179d35c23687b8f291c19108e21d4..2c5789bf613a750cb35b2f012501f4ab48f96e40 100644 (file)
@@ -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`"
index 80dd449ea84abb172158132e351a959fb031a47a..3cf3074e1ebe7f35d6a42f56c7dd63ade3b84a60 100755 (executable)
@@ -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
index 96861f6767c2d53822997f573416a7cb56933311..78cd6cb6d804f87d23a24d1c259b0200e1529eba 100755 (executable)
@@ -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 .
 )