summaryrefslogtreecommitdiff
path: root/share
diff options
context:
space:
mode:
Diffstat (limited to 'share')
-rwxr-xr-xshare/hydra/newnode47
1 files changed, 22 insertions, 25 deletions
diff --git a/share/hydra/newnode b/share/hydra/newnode
index e78b9bb..76d4a54 100755
--- a/share/hydra/newnode
+++ b/share/hydra/newnode
@@ -23,7 +23,13 @@ hydra_config_load
# Parameters
BASENAME="`basename $0`"
NODE="$1"
-NODES="$HYDRA_FOLDER/puppet/manifests/site.pp"
+DOMAIN="`cat $HYDRA_FOLDER/config/domain` 2> /dev/null"
+#NODES="$HYDRA_FOLDER/puppet/manifests/site.pp"
+
+# Check if node was given by fqdn or just hostname
+if ! echo $NODE | grep -q '\.'; then
+ NODE="$NODE.$DOMAIN"
+fi
# Check configuration and parameters
if [ -z "$NODE" ]; then
@@ -32,24 +38,15 @@ if [ -z "$NODE" ]; then
elif [ ! -e "$HYDRA_FOLDER/config/domain" ]; then
echo "fatal: please configure your domain at $HYDRA_FOLDER/config/domain"
exit 1
-#elif grep -qe "^import \"nodes/$NODE.pp\"$" $NODES &> /dev/null; then
-elif [ -e "$HYDRA_FOLDER/puppet/manifest/nodes/$NODE.pp" ]; then
+elif [ -e "$HYDRA_FOLDER/puppet/hiera/node/$NODE.yaml" ]; then
echo "fatal: node $NODE already defined"
exit 1
fi
-# Domain
-DOMAIN="`cat $HYDRA_FOLDER/config/domain`"
-
-# Check if node was given by fqdn or just hostname
-if ! echo $NODE | grep -q '\.'; then
- NODE="$NODE.$DOMAIN"
-fi
-
# Create node
-if [ -e "$NODES" ]; then
- echo "import \"nodes/$NODE.pp\"" >> $NODES
-fi
+#if [ -e "$NODES" ]; then
+# #echo "import \"nodes/$NODE.pp\"" >> $NODES
+#fi
# Set YAML template
if [ -e "$HYDRA_FOLDER/config/templates/node/nodo.example.org.yaml" ]; then
@@ -59,11 +56,11 @@ else
fi
# Set node template
-if [ -e "$HYDRA_FOLDER/config/templates/node/nodo.pp" ]; then
- PP="$HYDRA_FOLDER/config/templates/node/nodo.example.org.pp"
-else
- PP="$APP_BASE/share/config/templates/node/nodo.example.org.pp"
-fi
+#if [ -e "$HYDRA_FOLDER/config/templates/node/nodo.pp" ]; then
+# PP="$HYDRA_FOLDER/config/templates/node/nodo.example.org.pp"
+#else
+# PP="$APP_BASE/share/config/templates/node/nodo.example.org.pp"
+#fi
# Copy YAML template
mkdir -p $HYDRA_FOLDER/puppet/hiera/node
@@ -74,18 +71,18 @@ mkdir -p $HYDRA_FOLDER/puppet/hiera/secrets/node
echo "---" > $HYDRA_FOLDER/puppet/hiera/secrets/node/$NODE.yaml
# Copy node template
-mkdir -p $HYDRA_FOLDER/puppet/manifests/nodes
-cp $PP $HYDRA_FOLDER/puppet/manifests/nodes/$NODE.pp
+#mkdir -p $HYDRA_FOLDER/puppet/manifests/nodes
+#cp $PP $HYDRA_FOLDER/puppet/manifests/nodes/$NODE.pp
# Edit the template
-sed -i -e "s/nodename.example.org/$NODE/g" $HYDRA_FOLDER/puppet/manifests/nodes/$NODE.pp
+#sed -i -e "s/nodename.example.org/$NODE/g" $HYDRA_FOLDER/puppet/manifests/nodes/$NODE.pp
# Add to git
(
cd $HYDRA_FOLDER/puppet
git add manifests/nodes/$NODE.pp hiera/node/$NODE.yaml hiera/secrets/node/$NODE.yaml
- if [ -e 'manifests/site.pp' ]; then
- git add manifests/site.pp
- fi
+ #if [ -e 'manifests/site.pp' ]; then
+ # git add manifests/site.pp
+ #fi
)