]> gitweb.fluxo.info Git - hydra.git/commitdiff
Newnode: check if node was given by fqdn or just hostname
authorSilvio Rhatto <rhatto@riseup.net>
Mon, 19 Oct 2015 20:06:08 +0000 (18:06 -0200)
committerSilvio Rhatto <rhatto@riseup.net>
Mon, 19 Oct 2015 20:06:08 +0000 (18:06 -0200)
share/hydra/newnode

index b375b8aad9dfdf62ec0327279c2da943d5879b7d..3f614c38c66a67b168554435472da9f0fe698220 100755 (executable)
@@ -41,9 +41,14 @@ 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.$DOMAIN.pp\"" >> $NODES
+  echo "import \"nodes/$NODE.pp\"" >> $NODES
 fi
 
 # Set YAML template
@@ -62,24 +67,24 @@ fi
 
 # Copy YAML template
 mkdir -p $HYDRA_FOLDER/puppet/hiera/node
-cp $YAML $HYDRA_FOLDER/puppet/hiera/node/$NODE.$DOMAIN.yaml
+cp $YAML $HYDRA_FOLDER/puppet/hiera/node/$NODE.yaml
 
 # Setup secret YAML template
 mkdir -p $HYDRA_FOLDER/puppet/hiera/secrets/node
-echo "---" > $HYDRA_FOLDER/puppet/hiera/secrets/node/$NODE.$DOMAIN.yaml
+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.$DOMAIN.pp
+cp $PP $HYDRA_FOLDER/puppet/manifests/nodes/$NODE.pp
 
 # Edit the template
-sed -i -e "s/nodename/$NODE/g"      $HYDRA_FOLDER/puppet/manifests/nodes/$NODE.$DOMAIN.pp
-sed -i -e "s/example.org/$DOMAIN/g" $HYDRA_FOLDER/puppet/manifests/nodes/$NODE.$DOMAIN.pp
+sed -i -e "s/nodename/$NODE/g"      $HYDRA_FOLDER/puppet/manifests/nodes/$NODE.pp
+sed -i -e "s/example.org/$DOMAIN/g" $HYDRA_FOLDER/puppet/manifests/nodes/$NODE.pp
 
 # Add to git
 (
   cd $HYDRA_FOLDER/puppet
-  git add manifests/nodes/$NODE.pp hiera/node/$NODE.$DOMAIN.yaml hiera/secrets/node/$NODE.$DOMAIN.yaml
+  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