summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSilvio Rhatto <rhatto@riseup.net>2016-03-21 11:35:18 -0300
committerSilvio Rhatto <rhatto@riseup.net>2016-03-21 11:35:18 -0300
commitbdd58beb8ccf1fc8abf43ba4f940e9c438ec9297 (patch)
tree72e742113d9cf08ca707e19f3e3c54c06decd91f
parent6ebba3b8240d58ae749216ffa6254b9f7d2a2b9d (diff)
downloadhydra-bdd58beb8ccf1fc8abf43ba4f940e9c438ec9297.tar.gz
hydra-bdd58beb8ccf1fc8abf43ba4f940e9c438ec9297.tar.bz2
Do not generate manifest file, only hiera at newnode
-rw-r--r--TODO.md1
-rwxr-xr-xshare/hydra/newnode47
2 files changed, 22 insertions, 26 deletions
diff --git a/TODO.md b/TODO.md
index f6b48ee..2976150 100644
--- a/TODO.md
+++ b/TODO.md
@@ -8,7 +8,6 @@ Hydra
- install: move to /usr/local/share/hydra.
- bootless: properly support `$subdevice` in parted or always use first partition (like `/dev/sdb1`).
- init: add new repositories as superproject's submodules.
-- newnode: do not generate manifest file, only hiera.
- ssh-config: hydra integration.
- init: version control in the superproject?
- deploy:
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
)