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`"
# 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
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
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
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
#if [ -e 'manifests/site.pp' ]; then
# git add manifests/site.pp
#fi
+
+ cd $HYDRA_FOLDER/ansible
+ git add .
)