From ffdba1bfcc271d005cb47840bddd6ea20b753879 Mon Sep 17 00:00:00 2001 From: Silvio Rhatto Date: Sun, 20 Mar 2016 14:42:46 -0300 Subject: Updates default ORIGIN --- TODO.md | 1 - share/hydra/install | 2 +- share/hydractl/install | 2 +- 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/TODO.md b/TODO.md index 184101d..46c49ac 100644 --- a/TODO.md +++ b/TODO.md @@ -10,7 +10,6 @@ Hydra - check, install and test puppet pre-commit via git-hooks on all repositories using module-commit. - bootless: properly support `$subdevice` in parted or always use first partition (like `/dev/sdb1`). - ssh-config: hydra integration. -- install: automatically set ORIGIN through config parameter. - init: version control in the superproject? - deploy: - install keys? diff --git a/share/hydra/install b/share/hydra/install index a639db3..8b93ae7 100755 --- a/share/hydra/install +++ b/share/hydra/install @@ -30,7 +30,7 @@ fi # Validation if [ -z "$ORIGIN" ]; then - ORIGIN="git://git.sarava.org/hydra.git" + ORIGIN="git://git.fluxo.info/hydra.git" fi # Deploy diff --git a/share/hydractl/install b/share/hydractl/install index 7eb6830..0f43b4f 100755 --- a/share/hydractl/install +++ b/share/hydractl/install @@ -22,7 +22,7 @@ hydra_config_load # Validation if [ -z "$ORIGIN" ]; then - ORIGIN="git://git.sarava.org/hydra.git" + ORIGIN="git://git.fluxo.info/hydra.git" fi # Set sudo config -- cgit v1.2.3 From 1c3054ae1923d6a748e300768d29cba8f9cdd6c2 Mon Sep 17 00:00:00 2001 From: Silvio Rhatto Date: Sun, 20 Mar 2016 14:48:16 -0300 Subject: Removes puppet-clean-stored puppet-reset-agent puppet-reset-master puppet-setup-stored puppet-trigger puppet-update puppet-initialize puppet-finger puppet-install puppet-reset-stored --- share/hydractl/puppet-clean-stored | 91 -------------------------------------- share/hydractl/puppet-finger | 74 ------------------------------- share/hydractl/puppet-initialize | 20 --------- share/hydractl/puppet-install | 20 --------- share/hydractl/puppet-reset-agent | 21 --------- share/hydractl/puppet-reset-master | 52 ---------------------- share/hydractl/puppet-reset-stored | 23 ---------- share/hydractl/puppet-setup-stored | 24 ---------- share/hydractl/puppet-trigger | 23 ---------- share/hydractl/puppet-update | 28 ------------ 10 files changed, 376 deletions(-) delete mode 100755 share/hydractl/puppet-clean-stored delete mode 100755 share/hydractl/puppet-finger delete mode 100755 share/hydractl/puppet-initialize delete mode 100755 share/hydractl/puppet-install delete mode 100755 share/hydractl/puppet-reset-agent delete mode 100755 share/hydractl/puppet-reset-master delete mode 100755 share/hydractl/puppet-reset-stored delete mode 100755 share/hydractl/puppet-setup-stored delete mode 100755 share/hydractl/puppet-trigger delete mode 100755 share/hydractl/puppet-update diff --git a/share/hydractl/puppet-clean-stored b/share/hydractl/puppet-clean-stored deleted file mode 100755 index dcbefa8..0000000 --- a/share/hydractl/puppet-clean-stored +++ /dev/null @@ -1,91 +0,0 @@ -#!/usr/bin/env ruby - -# Script to clean up stored configs for (a) given host(s) -# -# Credits: -# Script was taken from http://reductivelabs.com/trac/puppet/attachment/wiki/UsingStoredConfiguration/kill_node_in_storedconfigs_db.rb (link no longer valid), -# which haven been initially posted by James Turnbull -# duritong adapted and improved the script a bit. - -require 'getoptlong' -config = '/etc/puppet/puppet.conf' - -def printusage(error_code) - puts "Usage: #{$0} [ list of hostnames as stored in hosts table ]" - puts "\n Options:" - puts "--config " - exit(error_code) -end - - - opts = GetoptLong.new( - - [ "--config", "-c", GetoptLong::REQUIRED_ARGUMENT ], - [ "--help", "-h", GetoptLong::NO_ARGUMENT ], - [ "--usage", "-u", GetoptLong::NO_ARGUMENT ], - - [ "--version", "-v", GetoptLong::NO_ARGUMENT ] -) - -begin - opts.each do |opt, arg| - case opt - when "--config" - config = arg - - when "--help" - printusage(0) - - when "--usage" - printusage(0) - - when "--version" - puts "#{Puppet.version}" - exit - end - end -rescue GetoptLong::InvalidOption => detail - $stderr.puts "Try '#{$0} --help'" - exit(1) -end - -printusage(1) unless ARGV.size > 0 - -require 'puppet/rails' -Puppet[:config] = config -Puppet.parse_config -pm_conf = Puppet.settings.instance_variable_get(:@values)[:master] - -adapter = pm_conf[:dbadapter] -args = {:adapter => adapter, :log_level => pm_conf[:rails_loglevel]} - -case adapter - when "sqlite3" - args[:dbfile] = pm_conf[:dblocation] - when "mysql", "postgresql" - args[:host] = pm_conf[:dbserver] unless pm_conf[:dbserver].to_s.empty? - args[:username] = pm_conf[:dbuser] unless pm_conf[:dbuser].to_s.empty? - args[:password] = pm_conf[:dbpassword] unless pm_conf[:dbpassword].to_s.empty? - args[:database] = pm_conf[:dbname] unless pm_conf[:dbname].to_s.empty? - args[:port] = pm_conf[:dbport] unless pm_conf[:dbport].to_s.empty? - socket = pm_conf[:dbsocket] - args[:socket] = socket unless socket.to_s.empty? - else - raise ArgumentError, "Invalid db adapter #{adapter}" -end - -args[:database] = "puppet" unless not args[:database].to_s.empty? - -ActiveRecord::Base.establish_connection(args) - -ARGV.each { |hostname| - if @host = Puppet::Rails::Host.find_by_name(hostname.strip) - print "Killing #{hostname}..." - $stdout.flush - @host.destroy - puts "done." - else - puts "Can't find host #{hostname}." - end -} -exit 0 diff --git a/share/hydractl/puppet-finger b/share/hydractl/puppet-finger deleted file mode 100755 index af83cc9..0000000 --- a/share/hydractl/puppet-finger +++ /dev/null @@ -1,74 +0,0 @@ -#!/bin/bash -# -# Check puppet fingerprints, hydractl perspective. -# -# 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 -# . - -# Load -source $APP_BASE/lib/hydra/functions || exit 1 -hydra_config_load - -# Command line arguments -BASENAME="`basename $0`" - -# Execute openssl -function puppet_openssl { - if [ -z "$1" ]; then - return - fi - - openssl x509 -text -noout -fingerprint -in $1 | grep "^SHA1 Fingerprint=" | \ - sed -e 's/^SHA1 Fingerprint=//' -} - -# Print a fingerprint with correct padding. -function print_fingerprint { - if [ -z "$2" ]; then - return - fi - - len="`echo $1 | wc -c`" - offset="$((85 - $len))" - printf "$1: %${offset}s\n" "$2" -} - -# Master: -# -# openssl x509 -text -noout -fingerprint -in /var/lib/puppetmaster/ssl/ca/signed/fqdn.pem -# openssl x509 -text -noout -fingerprint -in /var/lib/puppetmaster/ssl/certs/ca.pem -# -if [ -d "/var/lib/puppetmaster/ssl" ]; then - if [ -d "/var/lib/puppetmaster/ssl/ca/signed" ]; then - for file in `ls /var/lib/puppetmaster/ssl/ca/signed`; do - fp="`puppet_openssl /var/lib/puppetmaster/ssl/ca/signed/$file`" - print_fingerprint `basename $file .pem` $fp - done - fi - - if [ -f "/var/lib/puppetmaster/ssl/certs/ca.pem" ]; then - print_fingerprint ca `puppet_openssl /var/lib/puppetmaster/ssl/certs/ca.pem` - fi -fi - -# Node: -# -# openssl x509 -text -noout -fingerprint -in /var/lib/puppet/ssl/certs/fqdn.pem -# openssl x509 -text -noout -fingerprint -in /var/lib/puppet/ssl/certs/ca.pem -# -if [ -d "/var/lib/puppet/ssl" ]; then - fqdn="`facter fqdn`" - print_fingerprint $fqdn `puppet_openssl /var/lib/puppet/ssl/certs/$fqdn.pem` - print_fingerprint ca `puppet_openssl /var/lib/puppet/ssl/certs/ca.pem` -fi diff --git a/share/hydractl/puppet-initialize b/share/hydractl/puppet-initialize deleted file mode 100755 index 26b0165..0000000 --- a/share/hydractl/puppet-initialize +++ /dev/null @@ -1,20 +0,0 @@ -#!/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 -# . - -puppet agent --server puppet.`facter domain` --pluginsync true --waitforcert 60 --test \ - --vardir /var/lib/puppet --ssldir /var/lib/puppet/ssl $* diff --git a/share/hydractl/puppet-install b/share/hydractl/puppet-install deleted file mode 100755 index 63027b0..0000000 --- a/share/hydractl/puppet-install +++ /dev/null @@ -1,20 +0,0 @@ -#!/bin/bash -# -# Install puppet and puppetmaster. -# -# 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 -# . - -apt-get update -apt-get install puppet puppetmaster diff --git a/share/hydractl/puppet-reset-agent b/share/hydractl/puppet-reset-agent deleted file mode 100755 index 2c7b724..0000000 --- a/share/hydractl/puppet-reset-agent +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/bash -# -# Reset puppet SSL setup and register again. -# -# 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 -# . - -/etc/init.d/puppet stop -rm -rf /var/lib/puppet/ssl -hydractl puppet-initialize diff --git a/share/hydractl/puppet-reset-master b/share/hydractl/puppet-reset-master deleted file mode 100755 index 99dd7ae..0000000 --- a/share/hydractl/puppet-reset-master +++ /dev/null @@ -1,52 +0,0 @@ -#!/bin/bash -# -# Reset puppet master and start over again. -# -# 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 -# . - -# Stop agent -/etc/init.d/puppet stop - -# Stop master -if [ -e "/etc/init.d/puppetmaster" ]; then - /etc/init.d/puppetmaster stop - /etc/init.d/nginx stop -else - /etc/init.d/apache2 stop -fi - -# Reset configuration -hydractl puppet-reset-stored -rm -rf /var/lib/puppetmaster/ssl - -# Generate new certificate -# See http://blkperl.github.io/replace-puppet-ca.html -# http://docs.puppetlabs.com/puppet/latest/reference/ssl_regenerate_certificates.html -puppet cert --generate puppet.`facter domain` -hydractl puppet-finger - -# Get fresh config -rm -rf /etc/puppet/ && git clone /var/git/repositories/puppet.git/ /etc/puppet -( cd /etc/puppet/ && git submodule update --init ) -chown -R puppet.puppet /etc/puppet/ - -# Start master -if [ -e "/etc/init.d/puppetmaster" ]; then - /etc/init.d/puppetmaster start - sleep 5 - /etc/init.d/nginx start -else - /etc/init.d/apache2 start -fi diff --git a/share/hydractl/puppet-reset-stored b/share/hydractl/puppet-reset-stored deleted file mode 100755 index ec7cea7..0000000 --- a/share/hydractl/puppet-reset-stored +++ /dev/null @@ -1,23 +0,0 @@ -#!/bin/bash -# -# Reset 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 -# . - -# Load. -source $APP_BASE/lib/hydra/functions || exit 1 -hydra_config_load - -hydra_truncate_database puppet diff --git a/share/hydractl/puppet-setup-stored b/share/hydractl/puppet-setup-stored deleted file mode 100755 index 8e04261..0000000 --- a/share/hydractl/puppet-setup-stored +++ /dev/null @@ -1,24 +0,0 @@ -#!/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 -# . - -# Load. -source $APP_BASE/lib/hydra/functions || exit 1 -hydra_config_load - -# TODO -echo "TODO!" diff --git a/share/hydractl/puppet-trigger b/share/hydractl/puppet-trigger deleted file mode 100755 index 1f964db..0000000 --- a/share/hydractl/puppet-trigger +++ /dev/null @@ -1,23 +0,0 @@ -#!/bin/bash -# -# Triggers puppet agend execution. -# -# 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 -# . - -if [ -e '/var/run/puppet/agent.pid' ]; then - kill -USR1 `cat /var/run/puppet/agent.pid` -elif [ -e '/var/run/puppet/puppetd.pid' ]; then - kill -USR1 `cat /var/run/puppet/puppetd.pid` -fi diff --git a/share/hydractl/puppet-update b/share/hydractl/puppet-update deleted file mode 100755 index 0e9e8fe..0000000 --- a/share/hydractl/puppet-update +++ /dev/null @@ -1,28 +0,0 @@ -#!/bin/bash -# -# Update puppet repository. -# -# 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 -# . - -if [ -x '/usr/local/sbin/update-puppet-conf.sh' ]; then - /usr/local/sbin/update-puppet-conf.sh - - # Avoid reparsing of puppet config by just fixing perms if needed. - chown --from=root:root -R puppet.puppet /etc/puppet/* - chown --from=root:root -R puppet.puppet /etc/puppet/.git -else - echo "Could not find /usr/local/sbin/update-puppet-conf.sh" - exit 1 -fi -- cgit v1.2.3 From 41edaeba8733cd1b777bb5c4ccd5c81ef2a53a2e Mon Sep 17 00:00:00 2001 From: Silvio Rhatto Date: Sun, 20 Mar 2016 14:51:02 -0300 Subject: Removes puppet-enable and puppet-disable --- share/hydractl/puppet-disable | 1 - share/hydractl/puppet-enable | 38 -------------------------------------- share/hydractl/system-upgrade | 15 +++++---------- 3 files changed, 5 insertions(+), 49 deletions(-) delete mode 120000 share/hydractl/puppet-disable delete mode 100755 share/hydractl/puppet-enable diff --git a/share/hydractl/puppet-disable b/share/hydractl/puppet-disable deleted file mode 120000 index d68c04b..0000000 --- a/share/hydractl/puppet-disable +++ /dev/null @@ -1 +0,0 @@ -puppet-enable \ No newline at end of file diff --git a/share/hydractl/puppet-enable b/share/hydractl/puppet-enable deleted file mode 100755 index 8579081..0000000 --- a/share/hydractl/puppet-enable +++ /dev/null @@ -1,38 +0,0 @@ -#!/bin/bash -# -# Disable puppet agent. -# -# 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 -# . - -# Load -source $APP_BASE/lib/hydra/functions || exit 1 -hydra_config_load - -# Command line arguments -BASENAME="`basename $0`" - -# Set sudo config -if [ "`whoami`" != 'root' ]; then - sudo="sudo" -fi - -# Business -if [ "$BASENAME" == "puppet-enable" ]; then - $sudo sed -i -e 's/START=no/START=yes/' /etc/default/puppet - $sudo service puppet start -else - $sudo sed -i -e 's/START=yes/START=no/' /etc/default/puppet - $sudo service puppet stop -fi diff --git a/share/hydractl/system-upgrade b/share/hydractl/system-upgrade index 2ad06e6..b9a6b96 100755 --- a/share/hydractl/system-upgrade +++ b/share/hydractl/system-upgrade @@ -81,8 +81,11 @@ function hydra_system_upgrade_env { # Prepare the environment for a system upgrade function hydra_system_upgrade_prepare { # Ensure puppet is stopped during the process - echo "Disabling puppet during the upgrade..." - hydractl puppet-disable + if [ -e "/etc/default/puppet" ]; then + echo "Disabling puppet agent..." + sed -i -e 's/START=yes/START=no/' /etc/default/puppet + service puppet stop + fi # Configure apt for the next debian release echo "" @@ -151,14 +154,6 @@ function hydra_system_upgrade_custom { fi hydractl trac-upgrade - hydra_system_upgrade_stage puppet -} - -# Enable puppet again -function hydra_system_upgrade_puppet { - echo "" - echo "Starting puppet again..." - hydractl puppet-enable } # Initialize -- cgit v1.2.3 From c86bf5cae3dc05c3b607e02532b1137ce17803d3 Mon Sep 17 00:00:00 2001 From: Silvio Rhatto Date: Sun, 20 Mar 2016 14:57:28 -0300 Subject: Jessie customizations and script reordering --- share/hydractl/system-upgrade | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/share/hydractl/system-upgrade b/share/hydractl/system-upgrade index b9a6b96..f0c42b1 100755 --- a/share/hydractl/system-upgrade +++ b/share/hydractl/system-upgrade @@ -130,13 +130,6 @@ function hydra_system_upgrade_upgrade { exit 1 fi - hydra_system_upgrade_stage cleanup -} - -# Cleanup procedures -function hydra_system_upgrade_cleanup { - apt-get autoremove -y - apt-get clean hydra_system_upgrade_stage custom } @@ -153,7 +146,28 @@ function hydra_system_upgrade_custom { fi fi + if [ "$nextrelease" == "jessie" ]; then + # We're using a masterless puppet setup, so no agent + apt-get install puppet-common + apt-get purge puppet + + # Purge old monitoring infrastructure + apt-get purge 'munin*' 'nagios*' + rm -rf /etc/nagios* /etc/munin* /etc/munin* /usr/share/munin* + + # Cleanup old scripts + rm -f /usr/local/sbin/check-puppetd.sh + rm -f remove /etc/cron.d/puppetd + fi + hydractl trac-upgrade + hydra_system_upgrade_stage cleanup +} + +# Cleanup procedures +function hydra_system_upgrade_cleanup { + apt-get autoremove --purge -y + apt-get clean } # Initialize -- cgit v1.2.3 From df6002f9dbb325bd0691cc338a14261caa758ada Mon Sep 17 00:00:00 2001 From: Silvio Rhatto Date: Sun, 20 Mar 2016 15:04:41 -0300 Subject: Removes puppet-finger puppet-trigger bootstrap and requirements --- share/hydra/puppet-finger | 26 -------------------------- share/hydra/puppet-trigger | 32 -------------------------------- share/hydractl/bootstrap | 36 ------------------------------------ share/hydractl/requirements | 24 ------------------------ 4 files changed, 118 deletions(-) delete mode 100755 share/hydra/puppet-finger delete mode 100755 share/hydra/puppet-trigger delete mode 100755 share/hydractl/bootstrap delete mode 100755 share/hydractl/requirements diff --git a/share/hydra/puppet-finger b/share/hydra/puppet-finger deleted file mode 100755 index a96800b..0000000 --- a/share/hydra/puppet-finger +++ /dev/null @@ -1,26 +0,0 @@ -#!/bin/bash -# -# Check puppet fingerprints, hydra perspective. -# -# 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 -# . - -# Load -source $APP_BASE/lib/hydra/functions || exit 1 -hydra_config_load - -# Command line arguments -BASENAME="`basename $0`" - -hydra $HYDRA mass hydractl puppet-finger diff --git a/share/hydra/puppet-trigger b/share/hydra/puppet-trigger deleted file mode 100755 index eba1996..0000000 --- a/share/hydra/puppet-trigger +++ /dev/null @@ -1,32 +0,0 @@ -#!/bin/bash -# -# Execute commands in a single remote 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 -# . - -# Load -source $APP_BASE/lib/hydra/functions || exit 1 -hydra_config_load - -# Parameters -NODO="$1" - -# Connect -if [ ! -z "$NODO" ]; then - $HYDRA_CONNECT $NODO sudo hydractl puppet-trigger -else - echo "No node given." - exit 1 -fi diff --git a/share/hydractl/bootstrap b/share/hydractl/bootstrap deleted file mode 100755 index 0d60b50..0000000 --- a/share/hydractl/bootstrap +++ /dev/null @@ -1,36 +0,0 @@ -#!/bin/bash -# -# Bootstrap a new hydra using the current host as a starting point. -# -# 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 -# . - -STAGE="$1" - -if [ "$STAGE" == "repository" ]; then - hydractl puppet-install - - if [ ! -d "/etc/puppet/.git" ]; then - rm -rf /etc/puppet && git clone git://git.sarava.org/puppet-bootstrap /etc/puppet - hydra_bootstrap_config /etc/puppet - chown -R puppet. /etc/puppet - fi -fi - -if [ -e "/etc/puppet/manifests/$stage.pp" ]; then - ( - cd /etc/puppet - make apply stage=$stage - ) -fi diff --git a/share/hydractl/requirements b/share/hydractl/requirements deleted file mode 100755 index ccebab8..0000000 --- a/share/hydractl/requirements +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/bash -# -# Get all needed requirements. -# -# 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 -# . - -REQUIREMENTS="lsb-release facter" - -# Check for requirements. -for req in "$REQUIREMENTS"; do - hydra_install_package $req -done -- cgit v1.2.3 From 808e553a01074fc1f41f6f29fe07cfcb196e03f6 Mon Sep 17 00:00:00 2001 From: Silvio Rhatto Date: Sun, 20 Mar 2016 15:05:44 -0300 Subject: Renames system-upgrade to dist-upgrade, keep alias --- share/hydractl/dist-upgrade | 190 +++++++++++++++++++++++++++++++++++++++++ share/hydractl/system-upgrade | 191 +----------------------------------------- 2 files changed, 191 insertions(+), 190 deletions(-) create mode 100755 share/hydractl/dist-upgrade mode change 100755 => 120000 share/hydractl/system-upgrade diff --git a/share/hydractl/dist-upgrade b/share/hydractl/dist-upgrade new file mode 100755 index 0000000..f0c42b1 --- /dev/null +++ b/share/hydractl/dist-upgrade @@ -0,0 +1,190 @@ +#!/bin/bash +# +# Do a system upgrade, from a version to the next. +# +# 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 +# . + +# Load +source $APP_BASE/lib/hydra/functions || exit 1 +hydra_config_load + +# Parameters +TMP="/tmp" +STATE="$TMP/system-upgrade" +ENV="$TMP/system-upgrade-env" + +# Command line arguments +BASENAME="`basename $0`" +NEXTRELEASE="$1" + +# Proceed to the next upgrade stage +function hydra_system_upgrade_stage { + STAGE="$1" + echo $STAGE > $STATE + hydra_system_upgrade_$STAGE +} + +# Set and check upgrade environment +function hydra_system_upgrade_env { + # Set initial state + hydra_system_upgrade_stage env + + # Available releases + #release="`facter lsbdistcodename`" # this doesn't work on squeeze + release="`facter 2> /dev/null | grep lsbdistcodename | sed -e 's/lsbdistcodename => //'`" + nextrelease="`hydra_next_debian_release $release`" + + # Is a virtual machine? + virtual="`facter 2> /dev/null | grep virtual | grep -v '^is_virtual' | sed -e 's/virtual => //'`" + + # Save environment + echo "release=$release" > $ENV + echo "nextrelease=$nextrelease" >> $ENV + echo "nextrelease=$nextrelease" >> $ENV + echo "virtual=$virtual" >> $ENV + + # Check release + if [ "$?" != "0" ]; then + echo "Unsupported release" + exit 1 + fi + + # Check optional parameter + if [ ! -z "$NEXTRELEASE" ]; then + if [ "$NEXTRELEASE" == "$release" ]; then + echo "System is already upgraded to $NEXTRELEASE" + exit 1 + fi + + if [ "$NEXTRELEASE" != "$nextrelease" ]; then + echo "Cannot upgrade: next release for this system is $nextrelease" + exit 1 + fi + fi + + # Set next state + hydra_system_upgrade_stage prepare +} + +# Prepare the environment for a system upgrade +function hydra_system_upgrade_prepare { + # Ensure puppet is stopped during the process + if [ -e "/etc/default/puppet" ]; then + echo "Disabling puppet agent..." + sed -i -e 's/START=yes/START=no/' /etc/default/puppet + service puppet stop + fi + + # Configure apt for the next debian release + echo "" + echo "Updating apt configuration..." + sed -i -e "s/$release/$nextrelease/g" /etc/apt/sources.list + sed -i -e "s/$release/$nextrelease/g" /etc/apt/preferences + sed -i -e 's|^deb http://backports.debian.org/debian-backports|#deb http://backports.debian.org/debian-backports|' /etc/apt/sources.list + + # These will be generated by puppet and can be safely removed + rm -f /etc/apt/sources.list.d/* + rm -f /etc/apt/preferences.d/* + + # These might lead in upgrade errors + if [ "$virtual" == "vserver" ] && [ "$nextrelease" == "wheezy" ]; then + apt-get remove makedev -y + apt-get remove colord -y + fi + + # Set next state + hydra_system_upgrade_stage download +} + +# Update package listing and download new packages +function hydra_system_upgrade_download { + echo "" + echo "Updating package listing..." + apt-get update + echo "" + echo "Downloading packages..." + apt-get dist-upgrade -d -y + hydra_system_upgrade_stage upgrade +} + +# Proceed with the actual upgrade +function hydra_system_upgrade_upgrade { + echo "" + echo "Upgrading the system..." + DEBIAN_FRONTEND=noninteractive apt-get dist-upgrade + + if [ "$?" != "0" ]; then + echo "Upgrade failed. Please fix it manually and run this command again." + exit 1 + fi + + hydra_system_upgrade_stage custom +} + +# Custom upgrade procedures +function hydra_system_upgrade_custom { + if [ "$nextrelease" == "wheezy" ]; then + # Old suhosin config + rm -f /etc/php5/conf.d/suhosin.ini + + # This has to be manually installed again + if [ -f "/etc/php5/cli/conf.d/uploadprogress.ini" ]; then + pecl uninstall uploadprogress + pecl install uploadprogress + fi + fi + + if [ "$nextrelease" == "jessie" ]; then + # We're using a masterless puppet setup, so no agent + apt-get install puppet-common + apt-get purge puppet + + # Purge old monitoring infrastructure + apt-get purge 'munin*' 'nagios*' + rm -rf /etc/nagios* /etc/munin* /etc/munin* /usr/share/munin* + + # Cleanup old scripts + rm -f /usr/local/sbin/check-puppetd.sh + rm -f remove /etc/cron.d/puppetd + fi + + hydractl trac-upgrade + hydra_system_upgrade_stage cleanup +} + +# Cleanup procedures +function hydra_system_upgrade_cleanup { + apt-get autoremove --purge -y + apt-get clean +} + +# Initialize +if [ ! -e "$STATE" ]; then + hydra_system_upgrade_env +else + # Resume from the previous state + STAGE="`cat $STATE`" + + # Restore environment + if [ -e "$ENV" ]; then + source $ENV + fi + + hydra_system_upgrade_$STAGE +fi + +# Teardown +rm -f $STATE +rm -f $ENV diff --git a/share/hydractl/system-upgrade b/share/hydractl/system-upgrade deleted file mode 100755 index f0c42b1..0000000 --- a/share/hydractl/system-upgrade +++ /dev/null @@ -1,190 +0,0 @@ -#!/bin/bash -# -# Do a system upgrade, from a version to the next. -# -# 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 -# . - -# Load -source $APP_BASE/lib/hydra/functions || exit 1 -hydra_config_load - -# Parameters -TMP="/tmp" -STATE="$TMP/system-upgrade" -ENV="$TMP/system-upgrade-env" - -# Command line arguments -BASENAME="`basename $0`" -NEXTRELEASE="$1" - -# Proceed to the next upgrade stage -function hydra_system_upgrade_stage { - STAGE="$1" - echo $STAGE > $STATE - hydra_system_upgrade_$STAGE -} - -# Set and check upgrade environment -function hydra_system_upgrade_env { - # Set initial state - hydra_system_upgrade_stage env - - # Available releases - #release="`facter lsbdistcodename`" # this doesn't work on squeeze - release="`facter 2> /dev/null | grep lsbdistcodename | sed -e 's/lsbdistcodename => //'`" - nextrelease="`hydra_next_debian_release $release`" - - # Is a virtual machine? - virtual="`facter 2> /dev/null | grep virtual | grep -v '^is_virtual' | sed -e 's/virtual => //'`" - - # Save environment - echo "release=$release" > $ENV - echo "nextrelease=$nextrelease" >> $ENV - echo "nextrelease=$nextrelease" >> $ENV - echo "virtual=$virtual" >> $ENV - - # Check release - if [ "$?" != "0" ]; then - echo "Unsupported release" - exit 1 - fi - - # Check optional parameter - if [ ! -z "$NEXTRELEASE" ]; then - if [ "$NEXTRELEASE" == "$release" ]; then - echo "System is already upgraded to $NEXTRELEASE" - exit 1 - fi - - if [ "$NEXTRELEASE" != "$nextrelease" ]; then - echo "Cannot upgrade: next release for this system is $nextrelease" - exit 1 - fi - fi - - # Set next state - hydra_system_upgrade_stage prepare -} - -# Prepare the environment for a system upgrade -function hydra_system_upgrade_prepare { - # Ensure puppet is stopped during the process - if [ -e "/etc/default/puppet" ]; then - echo "Disabling puppet agent..." - sed -i -e 's/START=yes/START=no/' /etc/default/puppet - service puppet stop - fi - - # Configure apt for the next debian release - echo "" - echo "Updating apt configuration..." - sed -i -e "s/$release/$nextrelease/g" /etc/apt/sources.list - sed -i -e "s/$release/$nextrelease/g" /etc/apt/preferences - sed -i -e 's|^deb http://backports.debian.org/debian-backports|#deb http://backports.debian.org/debian-backports|' /etc/apt/sources.list - - # These will be generated by puppet and can be safely removed - rm -f /etc/apt/sources.list.d/* - rm -f /etc/apt/preferences.d/* - - # These might lead in upgrade errors - if [ "$virtual" == "vserver" ] && [ "$nextrelease" == "wheezy" ]; then - apt-get remove makedev -y - apt-get remove colord -y - fi - - # Set next state - hydra_system_upgrade_stage download -} - -# Update package listing and download new packages -function hydra_system_upgrade_download { - echo "" - echo "Updating package listing..." - apt-get update - echo "" - echo "Downloading packages..." - apt-get dist-upgrade -d -y - hydra_system_upgrade_stage upgrade -} - -# Proceed with the actual upgrade -function hydra_system_upgrade_upgrade { - echo "" - echo "Upgrading the system..." - DEBIAN_FRONTEND=noninteractive apt-get dist-upgrade - - if [ "$?" != "0" ]; then - echo "Upgrade failed. Please fix it manually and run this command again." - exit 1 - fi - - hydra_system_upgrade_stage custom -} - -# Custom upgrade procedures -function hydra_system_upgrade_custom { - if [ "$nextrelease" == "wheezy" ]; then - # Old suhosin config - rm -f /etc/php5/conf.d/suhosin.ini - - # This has to be manually installed again - if [ -f "/etc/php5/cli/conf.d/uploadprogress.ini" ]; then - pecl uninstall uploadprogress - pecl install uploadprogress - fi - fi - - if [ "$nextrelease" == "jessie" ]; then - # We're using a masterless puppet setup, so no agent - apt-get install puppet-common - apt-get purge puppet - - # Purge old monitoring infrastructure - apt-get purge 'munin*' 'nagios*' - rm -rf /etc/nagios* /etc/munin* /etc/munin* /usr/share/munin* - - # Cleanup old scripts - rm -f /usr/local/sbin/check-puppetd.sh - rm -f remove /etc/cron.d/puppetd - fi - - hydractl trac-upgrade - hydra_system_upgrade_stage cleanup -} - -# Cleanup procedures -function hydra_system_upgrade_cleanup { - apt-get autoremove --purge -y - apt-get clean -} - -# Initialize -if [ ! -e "$STATE" ]; then - hydra_system_upgrade_env -else - # Resume from the previous state - STAGE="`cat $STATE`" - - # Restore environment - if [ -e "$ENV" ]; then - source $ENV - fi - - hydra_system_upgrade_$STAGE -fi - -# Teardown -rm -f $STATE -rm -f $ENV diff --git a/share/hydractl/system-upgrade b/share/hydractl/system-upgrade new file mode 120000 index 0000000..bb7a06e --- /dev/null +++ b/share/hydractl/system-upgrade @@ -0,0 +1 @@ +dist-upgrade \ No newline at end of file -- cgit v1.2.3 From f3b527b2875e94b6e8165032f984cdd24e1f239e Mon Sep 17 00:00:00 2001 From: Silvio Rhatto Date: Sun, 20 Mar 2016 15:10:11 -0300 Subject: Updates whereis --- share/hydra/whereis | 25 ++++++------------------- 1 file changed, 6 insertions(+), 19 deletions(-) diff --git a/share/hydra/whereis b/share/hydra/whereis index 687b280..515218b 100755 --- a/share/hydra/whereis +++ b/share/hydra/whereis @@ -38,31 +38,18 @@ echo "-------------------------------------------------------------------------- echo "" # Is it a node? -if [ -e "$PUPPET/manifests/nodes/$LAYER.pp" ]; then - echo "Defined as a node at $PUPPET/manifests/nodes/$LAYER.pp" - - if [ -e "$PUPPET/hiera/production/domain/$DOMAIN/node/$LAYER.$DOMAIN.yaml" ]; then - echo "Configuration:" - echo "" - grep "nodo::role:" $PUPPET/hiera/production/domain/$DOMAIN/node/$LAYER.$DOMAIN.yaml - grep "nodo::location:" $PUPPET/hiera/production/domain/$DOMAIN/node/$LAYER.$DOMAIN.yaml - fi -fi - -# Is it a website? -if [ -e "$PUPPET/modules/site_websites" ] && \ - grep -R -e "apache::site" "$PUPPET/modules/site_websites/manifests/" | grep -q "$LAYER" ; then - MANIFEST="$(cd $PUPPET && grep -R -e "apache::site" "modules/site_websites/manifests/" | grep "$LAYER" | cut -d : -f 1)" - - echo "Defined as a website on $MANIFEST:" +if [ -e "$PUPPET/hiera/node/$LAYER.$DOMAIN.yaml" ]; then + echo "Defined as a node at hiera/node/$LAYER.$DOMAIN.yaml" + echo "Configuration:" echo "" - sed -n -e "/apache::site { \"$LAYER\":/,/ }/ p" $PUPPET/$MANIFEST + grep "nodo::role:" $PUPPET/hiera/node/$LAYER.$DOMAIN.yaml + grep "nodo::location:" $PUPPET/hiera/node/$LAYER.$DOMAIN.yaml fi # DNS config if [ -e "$HYDRA_FOLDER/dns/$DOMAIN.conf" ]; then echo "" - echo "DNS configuration at $HYDRA_FOLDER/dns/$DOMAIN.conf" + echo "DNS configuration at dns/$DOMAIN.conf" echo "----------------------------------------------------------------------------------" echo "" -- cgit v1.2.3 From 07833ecb8d2c416b2f1bb2a6b7c1b69835e04164 Mon Sep 17 00:00:00 2001 From: Silvio Rhatto Date: Sun, 20 Mar 2016 15:11:26 -0300 Subject: Removes empty script --- share/hydra/inventory | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 share/hydra/inventory diff --git a/share/hydra/inventory b/share/hydra/inventory deleted file mode 100644 index e69de29..0000000 -- cgit v1.2.3 From fbc59ab9b723fd651c07d2869a509e38405d18bf Mon Sep 17 00:00:00 2001 From: Silvio Rhatto Date: Sun, 20 Mar 2016 15:12:18 -0300 Subject: Removes list-sites --- share/hydra/list-sites | 38 -------------------------------------- 1 file changed, 38 deletions(-) delete mode 100755 share/hydra/list-sites diff --git a/share/hydra/list-sites b/share/hydra/list-sites deleted file mode 100755 index 3778e8b..0000000 --- a/share/hydra/list-sites +++ /dev/null @@ -1,38 +0,0 @@ -#!/bin/bash -# -# 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 -# . - -# Load. -source $APP_BASE/lib/hydra/functions || exit 1 -hydra_config_load - -# Parameters -BASENAME="`basename $0`" -LAYER="$1" -DOMAIN="`hydra $HYDRA config domain`" - -# Checks -if [ -z "$LAYER" ]; then - echo "usage: $BASENAME " - exit 1 -elif [ -z "$DOMAIN" ]; then - echo "Please set 'domain' at $HYDRA hydra config." - exit 1 -fi - -# This is crude but we're in a hurry! -if [ -e "$PUPPET/manifests/classes/websites.pp" ]; then - cat $PUPPET/manifests/classes/websites.pp | perl -pe 's/[,:]\n$//;' | grep $LAYER | grep apache::site | cut -d '"' -f 2 -fi -- cgit v1.2.3 From 8b8e21a3a4abedd96f5c4f41a99c746bf4b0ee91 Mon Sep 17 00:00:00 2001 From: Silvio Rhatto Date: Sun, 20 Mar 2016 16:24:20 -0300 Subject: Updates git user --- share/hydra/sync | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/hydra/sync b/share/hydra/sync index fc71b73..3406014 100755 --- a/share/hydra/sync +++ b/share/hydra/sync @@ -35,7 +35,7 @@ function hydra_sync { echo "Please set domain configuration" exit 1 fi - url="gitolite@admin.`cat $HYDRA_FOLDER/config/domain`:$repository" + url="git@admin.`cat $HYDRA_FOLDER/config/domain`:$repository" fi git clone $url $HYDRA_FOLDER/$repository -- cgit v1.2.3 From 8addf3ea71f50050a791e618bd4511860264c0de Mon Sep 17 00:00:00 2001 From: Silvio Rhatto Date: Sun, 20 Mar 2016 16:24:27 -0300 Subject: Mass cleanup --- share/hydra/mass | 4 +--- share/hydra/mass-update | 1 - 2 files changed, 1 insertion(+), 4 deletions(-) delete mode 120000 share/hydra/mass-update diff --git a/share/hydra/mass b/share/hydra/mass index 3b1ed2d..a716bae 100755 --- a/share/hydra/mass +++ b/share/hydra/mass @@ -61,9 +61,7 @@ BASEDIR="/tmp" set_nodes # Validation -if [ "$BASENAME" == "mass-update" ]; then - COMMAND="aptitude update" -elif [ "$BASENAME" == "mass-upgrade" ]; then +if [ "$BASENAME" == "mass-upgrade" ]; then COMMAND="DEBIAN_FRONTEND=noninteractive hydractl upgrade clean" elif [ "$BASENAME" == "mass-web" ]; then set_nodes web diff --git a/share/hydra/mass-update b/share/hydra/mass-update deleted file mode 120000 index 698f7d4..0000000 --- a/share/hydra/mass-update +++ /dev/null @@ -1 +0,0 @@ -mass \ No newline at end of file -- cgit v1.2.3