]> gitweb.fluxo.info Git - hydra.git/commitdiff
New actions
authorSilvio Rhatto <rhatto@riseup.net>
Sun, 9 Mar 2014 00:22:48 +0000 (21:22 -0300)
committerSilvio Rhatto <rhatto@riseup.net>
Sun, 9 Mar 2014 00:22:48 +0000 (21:22 -0300)
TODO.md
share/config/templates/node/node.example.org.yaml [new file with mode: 0644]
share/config/templates/node/node.pp [new file with mode: 0644]
share/hydra/folder [new file with mode: 0755]
share/hydra/newnode [new file with mode: 0755]
share/hydractl/puppet-initialize [new file with mode: 0755]
share/hydractl/puppet-reset-agent
share/hydractl/puppet-setup-stored [new file with mode: 0755]

diff --git a/TODO.md b/TODO.md
index 0f16ed9c710f9632e485f72cdcd4886061a5e014..0d4933affe37586d758262a9ee63abe8d67f1a68 100644 (file)
--- a/TODO.md
+++ b/TODO.md
@@ -5,10 +5,9 @@ Hydra
 -----
 
   - bootless: properly support `$subdevice` in parted or always use first device (like `/dev/sdb1`).
-  - puppet-setup-stored: configure storeconfigs database.
 
 Hydractl
 --------
 
   - provision: config parser using a custom function with `include` directive, avoiding `source`.
-  - backup-restore-site: fix parameters
+  - puppet-setup-stored: configure storeconfigs database.
diff --git a/share/config/templates/node/node.example.org.yaml b/share/config/templates/node/node.example.org.yaml
new file mode 100644 (file)
index 0000000..56d0213
--- /dev/null
@@ -0,0 +1,2 @@
+---
+nodo::role: 'vserver'
diff --git a/share/config/templates/node/node.pp b/share/config/templates/node/node.pp
new file mode 100644 (file)
index 0000000..976316b
--- /dev/null
@@ -0,0 +1,3 @@
+node 'node.example.org' {
+  include nodo
+}
diff --git a/share/hydra/folder b/share/hydra/folder
new file mode 100755 (executable)
index 0000000..20f0bbe
--- /dev/null
@@ -0,0 +1,23 @@
+#!/bin/bash
+#
+# Display hydra folder.
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public
+# License along with this program.  If not, see
+# <http://www.gnu.org/licenses/>.
+
+# Load
+source $APP_BASE/lib/hydra/functions || exit 1
+
+# Display folder
+echo $HYDRA_FOLDER
diff --git a/share/hydra/newnode b/share/hydra/newnode
new file mode 100755 (executable)
index 0000000..e6da2ad
--- /dev/null
@@ -0,0 +1,79 @@
+#!/bin/bash
+#
+# Create new node configuration.
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public
+# License along with this program.  If not, see
+# <http://www.gnu.org/licenses/>.
+
+# Load.
+source $APP_BASE/lib/hydra/functions || exit 1
+hydra_config_load
+
+# Parameters
+BASENAME="`basename $0`"
+NODE="$1"
+NODES="$HYDRA_FOLDER/puppet/manifests/nodes.pp"
+
+# Check configuration and parameters
+if [ -z "$NODE" ]; then
+  echo "usage: hydra $BASENAME <node>"
+  exit 1
+elif [ ! -e "$HYDRA_FOLDER/config/domain" ]; then
+  echo "fatal: please configure your domain at $HYDRA_FOLDER/config/domain"
+  exit 1
+elif [ ! -f "$NODES" ]; then
+  echo "fatal: nodes.pp not found"
+  exit 1
+elif grep -qe "^import \"nodes/$NODE.pp\"$" $NODES &> /dev/null; then
+  echo "fatal: node $NODE already defined"
+  exit 1
+fi
+
+# Domain
+DOMAIN="`cat $HYDRA_FOLDER/config/domain`"
+
+# Create node
+echo "import \"nodes/$NODE.pp\"" >> $NODES
+
+# Set YAML template
+if [ -e "$HYDRA_FOLDER/config/templates/node/node.example.org.yaml" ]; then
+  YAML="$HYDRA_FOLDER/config/templates/node/node.example.org.yaml"
+else
+  YAML="$APP_BASE/share/config/templates/node/node.example.org.yaml"
+fi
+
+# Set node template
+if [ -e "$HYDRA_FOLDER/config/templates/node/node.pp" ]; then
+  PP="$HYDRA_FOLDER/config/templates/node/node.pp"
+else
+  PP="$APP_BASE/share/config/templates/node/node.pp"
+fi
+
+# Copy YAML template
+mkdir -p $HYDRA_FOLDER/puppet/hiera/production/domain/$DOMAIN/node
+cp $YAML $HYDRA_FOLDER/puppet/hiera/production/domain/$DOMAIN/node/$NODE.$DOMAIN.yaml
+
+# Copy node template
+mkdir -p $HYDRA_FOLDER/puppet/manifests/nodes
+cp $PP $HYDRA_FOLDER/puppet/manifests/nodes/$NODE.pp
+
+# Edit the template
+sed -i -e "s/node/$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/site.pp manifests/nodes/$NODE.pp hiera/production/domain/$DOMAIN/node/$NODE.$DOMAIN.yaml
+)
diff --git a/share/hydractl/puppet-initialize b/share/hydractl/puppet-initialize
new file mode 100755 (executable)
index 0000000..3833e96
--- /dev/null
@@ -0,0 +1,20 @@
+#!/bin/bash
+#
+# Make puppet agent first connection with the master node.
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public
+# License along with this program.  If not, see
+# <http://www.gnu.org/licenses/>.
+
+puppet agent --server puppet.`facter domain` --pluginsync true --waitforcert 60 --digest-sha1 --test \
+             --ca_port 8141 --vardir /var/lib/puppet --ssldir /var/lib/puppet/ssl $*
index 1aff2d8244a30e5362e910f9ba6d77ceb02bdaa9..2c7b7244bc45a922c48fe8466f7cbf4ff91b6565 100755 (executable)
@@ -18,5 +18,4 @@
 
 /etc/init.d/puppet stop
 rm -rf /var/lib/puppet/ssl
-puppet agent --server puppet.`facter domain` --waitforcert 60 --test --ca_port 8141 \
-             --vardir /var/lib/puppet --ssldir /var/lib/puppet/ssl
+hydractl puppet-initialize
diff --git a/share/hydractl/puppet-setup-stored b/share/hydractl/puppet-setup-stored
new file mode 100755 (executable)
index 0000000..8e04261
--- /dev/null
@@ -0,0 +1,24 @@
+#!/bin/bash
+#
+# Setup puppet stored configs.
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public
+# License along with this program.  If not, see
+# <http://www.gnu.org/licenses/>.
+
+# Load.
+source $APP_BASE/lib/hydra/functions || exit 1
+hydra_config_load
+
+# TODO
+echo "TODO!"