Revisión e4037eb7
Añadido por Rafael J García hace casi 3 años
ubuntu/jammy/all/linex-ubuntu-puppet/debian/changelog | ||
---|---|---|
linex-ubuntu-puppet (1.6) linex; urgency=high
|
||
|
||
* Eliminadas dependencias de puppet-linex, puppet-linex-common y facter-linex.
|
||
|
||
-- Rafael J. García Perdigón <rafael.garciap@juntaex.es> Wed, 11 May 2022 10:18:01 +0200
|
||
|
||
linex-ubuntu-puppet (1.5.1) linex; urgency=medium
|
||
|
||
* Se cambia el parámetro TimeoutStartSec=600 del servicio sincpuppet
|
||
|
||
-- ismael <ismael.campos@educarex.es> Mon, 12 Apr 2021 12:43:30 +0200
|
||
|
||
linex-ubuntu-puppet (1.5.0) linex; urgency=medium
|
||
|
||
* Se limita a tres veces el paso del catálogo por problema encontrado con servidores puppet v6.
|
||
|
||
-- ismael <ismael.campos@educarex.es> Tue, 20 Nov 2020 12:46:40 +0100
|
||
|
||
linex-ubuntu-puppet (1.4.9) linex; urgency=medium
|
||
|
||
* Se quita el lanzamiento de sinc_puppet dentro de postinst porque da problemas.
|
||
|
||
-- ismael <ismael.campos@educarex.es> Tue, 19 Nov 2020 12:46:40 +0100
|
||
|
||
linex-ubuntu-puppet (1.4.8) linex; urgency=medium
|
||
|
||
* Bug detectado en sinc_puppet
|
||
|
||
-- ismael <ismael.campos@educarex.es> Tue, 18 Nov 2020 09:47:40 +0100
|
||
|
||
linex-ubuntu-puppet (1.4.7) linex; urgency=medium
|
||
|
||
* Se actualiza sinc_puppet con nuevas funcionalidades:
|
||
Se añaden nuevas funcionalidades implementadas por Esteban Navas.
|
||
Se modifica solveapterrors para que contemple más problemas con la paquetería.
|
||
Se añade al fichero de configuración la línea certificate_revocation=false para compatibilidad con servidores en versión 6 de puppet.
|
||
Se añade la funcionalidad de traer ca.pem del servidor si el servidor está en version 6 de puppet.
|
||
Se afina la función dosync
|
||
* Se elimina basura encontrada en los ficheros.
|
||
|
||
-- ismael <ismael.campos@educarex.es> Tue, 17 Nov 2020 09:47:40 +0100
|
||
|
||
linex-ubuntu-puppet (1.4.6) linex; urgency=medium
|
||
|
||
* Se añade servicio systemd al sistema.
|
||
* Se elimina anterior servicio de init.d.
|
||
* Se elimina inicio al levantar red utilizando if-up-d.
|
||
* Se actualiza script sinc_puppet con algunas aportaciones del compañero Esteban M. Navas a fecha de 22/06/2018
|
||
|
||
-- ismael <ismael.campos@educarex.es> Thu, 12 Jul 2018 12:34:33 +0200
|
||
|
||
linex-ubuntu-puppet (1.4.5) linex; urgency=medium
|
||
|
||
* Añadido a postinst "gem install xmlrpc" necesario para utilizar alguna sintaxis de puppet (p.ej. package)
|
||
|
||
-- ismael <ismael.campos@educarex.es> Tue, 08 May 2018 12:35:06 +0200
|
||
|
||
linex-ubuntu-puppet (1.4.4) linex; urgency=medium
|
||
|
||
* Añadidas las dependencias a los paquetes puppet-linex y puppet-common-linex
|
||
|
||
-- elisa <isabel.aparicio@educarex.es> Tue, 08 May 2018 12:35:06 +0200
|
||
|
||
linex-ubuntu-puppet (1.4.3+nmu1) linex; urgency=medium
|
||
|
||
* Añadidas las dependencias de los paquetes lockfile-progs y uuid-
|
||
runtime
|
||
|
||
-- root <root@educarex.es> Tue, 08 May 2018 12:35:06 +0200
|
||
|
||
linex-ubuntu-puppet (1.4.2) linex; urgency=medium
|
||
|
||
* Se añade a sinc_puppet: export PATH para correcto funcionamiento cuando levanta la interfaz Network-Manager
|
||
|
||
-- ismael <ismael.campos@juntaex.es> Thu, 16 Feb 2017 15:33:44 +0100
|
||
|
||
linex-ubuntu-puppet (1.4.1) linex; urgency=medium
|
||
|
||
* Unificar versión con willy
|
||
|
||
-- Ismael Campos <ismael.campos@juntaex.es> Fri, 03 Feb 2017 13:48:30 +0100
|
||
|
||
linex-ubuntu-puppet (1.4) linex; urgency=medium
|
||
|
||
* Se modifica ejecutable sinc_puppet y sincpuppet.default con la versión de linex-ubuntu-puppet 2.5 de Esteban.
|
||
* Se pasa a generar certificados con uuid en lugar de nombre de hosts y se resuelven problemas con certificados.
|
||
|
||
-- Ismael Campos <ismael.campos@juntaex.es> Fri, 03 Feb 2017 10:10:01 +0100
|
||
|
||
linex-ubuntu-puppet (1.3) linex; urgency=medium
|
||
|
||
* Modificado escuela2.0 por ubuntu 16.04 (Eli).
|
||
* Añadida desactivación de servicio puppet para systemctl
|
||
* Cambiado script sinc_puppet por el de Esteban versión 1.8
|
||
|
||
-- Rafael J. García Perdigón <rafael.garciap@gobex.es> Mon, 04 Jul 2016 14:39:37 +0200
|
||
|
||
linex-ubuntu-puppet (1.2) linex; urgency=medium
|
||
|
||
* Cambio del nombre del paquete de de linex-workstation-puppet a linex-ubuntu-puppet.
|
||
Cambiado el fichero escuela2.0.
|
||
Añadido el fichero de puppet.conf
|
||
Añadidos Divert a los ficheros de configuracion.
|
||
* Bloqueada la sincronización de plugins.
|
||
|
||
-- Rafael J. García Perdigón <rafael.garciap@gobex.es> Mon, 25 Jan 2016 12:15:40 +0100
|
||
|
||
linex-ubuntu-puppet (1.0) linex; urgency=low
|
||
|
||
* Initial Release. Metapackage to install puppet for linex workstations.
|
||
|
||
-- Rafael J. García Perdigón <rafael.garciap@gobex.es> Fri, 19 Sep 2014 10:10:03 +0200
|
ubuntu/jammy/all/linex-ubuntu-puppet/debian/compat | ||
---|---|---|
8
|
ubuntu/jammy/all/linex-ubuntu-puppet/debian/conffiles | ||
---|---|---|
/usr/share/linex-ubuntu-puppet/escuela2.0
|
||
/usr/share/linex-ubuntu-puppet/puppet.conf
|
||
/usr/share/linex-ubuntu-puppet/sincpuppet.default
|
ubuntu/jammy/all/linex-ubuntu-puppet/debian/control | ||
---|---|---|
Source: linex-ubuntu-puppet
|
||
Section: admin
|
||
Priority: optional
|
||
Maintainer: Rafael Jesús García Perdigón <rafael.garciap@gobex.es>
|
||
Build-Depends: debhelper (>= 8.0.0)
|
||
Standards-Version: 3.9.4
|
||
|
||
Package: linex-ubuntu-puppet
|
||
Architecture: all
|
||
Depends: puppet, puppet-common, pkgsync, lockfile-progs, uuid-runtime, facter, curl
|
||
Conflicts:puppet-linex, puppet-linex-common,facter-linex
|
||
Description: Configuración del cliente puppet
|
||
Instalación de las dependencias del cliente de puppet,
|
||
junto con la configuración necesaria para dicho cliente
|
||
en el entorno de un centro educativo.
|
ubuntu/jammy/all/linex-ubuntu-puppet/debian/copyright | ||
---|---|---|
Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
|
||
Upstream-Name: lingobex-desktop-theme
|
||
|
||
Files: *
|
||
Copyright: 2014 Gobierno de Extremadura
|
||
License: GPL-3.0+
|
||
|
||
Files: debian/*
|
||
Copyright: 2014 Gobierno de Extremadura
|
||
License: GPL-3.0+
|
||
|
||
License: GPL-3.0+
|
||
This program is free software: you can redistribute it and/or modify
|
||
it under the terms of the GNU General Public License as published by
|
||
the Free Software Foundation, either version 3 of the License, or
|
||
(at your option) any later version.
|
||
.
|
||
This package 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 General Public License for more details.
|
||
.
|
||
You should have received a copy of the GNU General Public License
|
||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||
.
|
||
On Debian systems, the complete text of the GNU General
|
||
Public License version 3 can be found in "/usr/share/common-licenses/GPL-3".
|
||
|
ubuntu/jammy/all/linex-ubuntu-puppet/debian/format | ||
---|---|---|
9.0 (native)
|
ubuntu/jammy/all/linex-ubuntu-puppet/debian/install | ||
---|---|---|
usr
|
ubuntu/jammy/all/linex-ubuntu-puppet/debian/linex-ubuntu-puppet.links | ||
---|---|---|
/usr/share/linex-ubuntu-puppet/escuela2.0 /etc/escuela2.0
|
||
/usr/share/linex-ubuntu-puppet/puppet.conf /etc/puppet/puppet.conf
|
||
/usr/share/linex-ubuntu-puppet/leefichero.rb /usr/lib/ruby/vendor_ruby/facter/leefichero.rb
|
||
/usr/share/linex-ubuntu-puppet/sinc_puppet /usr/sbin/sinc_puppet
|
||
/usr/share/linex-ubuntu-puppet/sincpuppet.default /etc/default/sincpuppet
|
||
/usr/share/linex-ubuntu-puppet/sincpuppet.service /lib/systemd/system/sincpuppet.service
|
ubuntu/jammy/all/linex-ubuntu-puppet/debian/postinst | ||
---|---|---|
#!/bin/bash
|
||
set -e
|
||
|
||
mkdir -p /etc/pkgsync
|
||
touch /etc/pkgsync/mayhave
|
||
touch /etc/pkgsync/maynothave
|
||
|
||
|
||
invoke-rc.d puppet stop
|
||
update-rc.d -f puppet remove
|
||
update-rc.d -f sincpuppet remove
|
||
|
||
gem install xmlrpc
|
||
|
||
pidof systemd 2>&1>/dev/null
|
||
|
||
[ -d "/var/lib/puppet/ssl" ] && find /var/lib/puppet/ssl -name $(puppet agent --configprint certname).pem -delete
|
||
curl -k https://$(puppet agent --configprint server):8140/puppet-ca/v1/certificate/ca > $(puppet agent --configprint localcacert)
|
||
|
||
if [ $? -eq "0" ]; then
|
||
systemctl disable puppet.service
|
||
systemctl enable sincpuppet.service
|
||
fi
|
||
|
||
exit 0
|
||
|
ubuntu/jammy/all/linex-ubuntu-puppet/debian/postrm | ||
---|---|---|
#!/bin/bash
|
||
|
||
set -e
|
||
|
||
PKG="linex-ubuntu-puppet"
|
||
SHAREDIR="/usr/share/linex-ubuntu-puppet"
|
||
|
||
remove_divert() {
|
||
diverter=$(dpkg-divert --listpackage $1)
|
||
if [ "$diverter" = "linex-ubuntu-puppet" ]; then
|
||
dpkg-divert --package linex-ubuntu-puppet --rename --remove $1
|
||
fi
|
||
}
|
||
|
||
|
||
if [ "$1" = remove ]; then
|
||
remove_divert /etc/puppet/puppet.conf
|
||
|
||
fi
|
||
|
||
if [ "$1" = purge ]; then
|
||
update-rc.d sincpuppet remove
|
||
fi
|
||
exit 0
|
||
|
ubuntu/jammy/all/linex-ubuntu-puppet/debian/preinst | ||
---|---|---|
#!/bin/bash
|
||
set -e
|
||
|
||
PKG="linex-ubuntu-puppet"
|
||
SHAREDIR="/usr/share/linex-ubuntu-puppet"
|
||
|
||
divert() {
|
||
diverted_file=$1
|
||
|
||
dpkg-divert --package "$PKG" --add --rename \
|
||
--divert "${diverted_file}-pre-$PKG" $diverted_file
|
||
}
|
||
|
||
divert /etc/puppet/puppet.conf
|
||
|
||
exit 0
|
||
|
ubuntu/jammy/all/linex-ubuntu-puppet/debian/rules | ||
---|---|---|
#!/usr/bin/make -f
|
||
# -*- makefile -*-
|
||
# Sample debian/rules that uses debhelper.
|
||
# This file was originally written by Joey Hess and Craig Small.
|
||
# As a special exception, when this file is copied by dh-make into a
|
||
# dh-make output file, you may use that output file without restriction.
|
||
# This special exception was added by Craig Small in version 0.37 of dh-make.
|
||
|
||
# Uncomment this to turn on verbose mode.
|
||
#export DH_VERBOSE=1
|
||
|
||
%:
|
||
dh $@
|
ubuntu/jammy/all/linex-ubuntu-puppet/usr/share/linex-ubuntu-puppet/escuela2.0 | ||
---|---|---|
SISTEMA=ubuntu1804
|
ubuntu/jammy/all/linex-ubuntu-puppet/usr/share/linex-ubuntu-puppet/leefichero.rb | ||
---|---|---|
# Archivo /usr/lib/ruby/vendor_ruby/facter/leefichero.rb
|
||
# Se utiliza para leer fichero /etc/escuela2.0 y anadir variables a facter
|
||
|
||
if File.exists?("/etc/escuela2.0")
|
||
File.open("/etc/escuela2.0").each do |line|
|
||
var = nil
|
||
value = nil
|
||
|
||
var = $1 and val = $2 if line =~ /^(.+)=(.+)$/
|
||
|
||
if var != nil && val != nil
|
||
Facter.add(var) do
|
||
setcode { val }
|
||
end
|
||
end
|
||
end
|
||
end
|
||
####
|
ubuntu/jammy/all/linex-ubuntu-puppet/usr/share/linex-ubuntu-puppet/puppet.conf | ||
---|---|---|
[main]
|
||
logdir=/var/log/puppet
|
||
vardir=/var/lib/puppet
|
||
ssldir=/var/lib/puppet/ssl
|
||
rundir=/var/run/puppet
|
||
factpath=$vardir/lib/facter
|
||
prerun_command=/etc/puppet/etckeeper-commit-pre
|
||
postrun_command=/etc/puppet/etckeeper-commit-post
|
||
server=puppetinstituto
|
||
pluginsync=false
|
||
|
||
[master]
|
||
# These are needed when the puppetmaster is run by passenger
|
||
# and can safely be removed if webrick is used.
|
||
ssl_client_header = SSL_CLIENT_S_DN
|
||
ssl_client_verify_header = SSL_CLIENT_VERIFY
|
||
|
ubuntu/jammy/all/linex-ubuntu-puppet/usr/share/linex-ubuntu-puppet/sinc_puppet | ||
---|---|---|
#!/bin/bash
|
||
# Script para tratar de realizar la sincronización del cliente puppet
|
||
# Basado en la versión de Esteban M. Navas Martín 17/09/2020
|
||
# Fecha última modificación Administracionsi (Ismael): 03/11/2020
|
||
|
||
export DEBIAN_FRONTEND=noninteractive
|
||
export VERSION=2.17
|
||
export PATH="${PATH:+$PATH:}/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
|
||
|
||
SCRIPT=`basename "$0"`
|
||
|
||
function print_version {
|
||
echo "$SCRIPT $VERSION"
|
||
}
|
||
|
||
function print_help {
|
||
echo "$SCRIPT $VERSION"
|
||
echo "Automated sinc puppet client"
|
||
echo ""
|
||
echo "Usage: $0 [OPTIONS]"
|
||
echo "Recognized options:"
|
||
echo " -h display this help and exit"
|
||
echo " -v display $SCRIPT version and exit"
|
||
echo " -f force $SCRIPT on SPLAYLIMIT"
|
||
echo " -f now force $SCRIPT now"
|
||
echo " -r renew cert client"
|
||
echo ""
|
||
}
|
||
|
||
function preparapuppetv6 {
|
||
if ! `grep "certificate_revocation=false" /usr/share/linex-ubuntu-puppet/puppet.conf >/dev/null` ; then
|
||
sed '/\[main\]/a certificate_revocation=false' -i /usr/share/linex-ubuntu-puppet/puppet.conf
|
||
fi
|
||
}
|
||
|
||
function solveapterrors {
|
||
set +e
|
||
|
||
idioma=$LC_ALL
|
||
export LC_ALL=C
|
||
|
||
# Matamos procesos detenidos
|
||
stopped_processes=$(ps auwx | awk 'NR>1 && $8 ~ "T" {print $2}')
|
||
if [ "$stopped_processes" ]; then kill -9 $stopped_processes; fi
|
||
|
||
# Matamos el proceso más antiguo de sinc_puppet, si está corriendo
|
||
if [ $(pgrep -c sinc_puppet) -gt 1 ]; then pkill -o sinc_puppet; fi
|
||
|
||
apt-get check 1>/dev/null 2>/tmp/apterrors
|
||
|
||
if [ -s /tmp/apterrors ]; then
|
||
if `grep "Unmet dependencies. Try using -f." /tmp/apterrors >/dev/null 2>&1`; then
|
||
apt-get -yf install && dpkg --configure -a && apt-get -y autoremove
|
||
else
|
||
if `grep "dpkg was interrupted, you must manually run 'dpkg --configure -a' to correct the problem." /tmp/apterrors >/dev/null 2>&1`; then
|
||
dpkg --configure -a && apt-get -yf install && apt-get -y autoremove
|
||
else
|
||
if `grep -E 'Encountered a section with no Package: header|Problem with MergeList' /tmp/apterrors >/dev/null 2>&1`; then
|
||
rm -rf /var/lib/apt/lists/
|
||
else
|
||
if ! `grep "Could not get lock" /tmp/apterrors >/dev/null 2>&1`; then
|
||
apt-get -yf install && dpkg --configure -a && apt-get -y autoremove && apt-get clean && apt-get autoclean
|
||
fi
|
||
fi
|
||
fi
|
||
fi
|
||
fi
|
||
|
||
# Instalamos paquetes a medio instalar
|
||
dpkg -l|grep ^iF | awk '{print $2}' || apt-get -y install $(dpkg -l|grep ^iF | awk '{print $2}')
|
||
|
||
export LC_ALL=$idioma
|
||
}
|
||
|
||
function dosync {
|
||
if [ "$1" == "-f" ] && [ "$2" == "now" ]; then
|
||
echo "Conexión con servidor de puppet." | logger -s -t $0
|
||
echo "Sincronizando puppet..." | logger -s -t $0
|
||
|
||
versionanterior=""
|
||
|
||
salida=$(puppet agent --onetime --no-daemonize --no-usecacheonfailure -v 2>/tmp/puppeterror.log);CODIGO_SALIDA=$?
|
||
grep 'certificate verify failed' /tmp/puppeterror.log
|
||
|
||
if [ $? -eq 0 ]; then
|
||
uuid=$(/usr/bin/uuidgen -t) && sed -i "s/certname=.*/certname=$uuid/" /usr/share/linex-ubuntu-puppet/puppet.conf
|
||
rm -r /var/lib/puppet/ssl/*
|
||
salida=$(puppet agent --onetime --no-daemonize --no-usecacheonfailure -v 2>/tmp/puppeterror.log);CODIGO_SALIDA=$?
|
||
fi
|
||
|
||
if [ $CODIGO_SALIDA -eq 0 ]; then
|
||
echo $salida
|
||
version=$(echo $salida | grep -oE "configuration version '[0-9]*'" | grep -oE '[0-9]*')
|
||
|
||
NUMERO=1
|
||
until [ "$version" == "$versionanterior" -o $NUMERO -ge 3 ]; do
|
||
NUMERO=$((NUMERO+1))
|
||
versionanterior=$version
|
||
salida=$(puppet agent --onetime --no-daemonize --no-usecacheonfailure -v 2>/tmp/puppeterror.log);CODIGO_SALIDA=$?
|
||
echo $salida
|
||
version=$(echo $salida | grep -oE "configuration version '[0-9]*'" | grep -oE '[0-9]*')
|
||
done
|
||
|
||
if [ $CODIGO_SALIDA -eq "0" ]; then
|
||
echo "Sistema PUPPET correcto." | logger -s -t $0
|
||
exit 0
|
||
fi
|
||
fi
|
||
else
|
||
echo "Conexión con servidor de puppet." | logger -s -t $0
|
||
echo "Esperando un tiempo máximo de $SPLAYLIMIT para sincronizar puppet....." | logger -s -t $0
|
||
|
||
|
||
versionanterior=""
|
||
|
||
salida=$(puppet agent --onetime --no-daemonize --splay --splaylimit $SPLAYLIMIT --no-usecacheonfailure -v 2>/tmp/puppeterror.log);CODIGO_SALIDA=$?
|
||
|
||
if [ $CODIGO_SALIDA -eq 0 ]; then
|
||
echo $salida
|
||
version=$(echo $salida | grep -oE "configuration version '[0-9]*'" | grep -oE '[0-9]*')
|
||
|
||
NUMERO=1
|
||
until [ "$version" == "$versionanterior" -o $NUMERO -ge 3 ]; do
|
||
NUMERO=$((NUMERO+1))
|
||
versionanterior=$version
|
||
salida=$(puppet agent --onetime --no-daemonize --no-usecacheonfailure -v 2>/tmp/puppeterror.log);CODIGO_SALIDA=$?
|
||
echo $salida
|
||
version=$(echo $salida | grep -oE "configuration version '[0-9]*'" | grep -oE '[0-9]*')
|
||
done
|
||
|
||
if [ $CODIGO_SALIDA -eq "0" ]; then
|
||
echo "Sistema PUPPET correcto" | logger -s -t $0
|
||
exit 0
|
||
fi
|
||
fi
|
||
fi
|
||
}
|
||
|
||
# No forzar la ejecución de sinc_puppet por defecto
|
||
FORCE=false
|
||
|
||
# Leer y procesar argumentos
|
||
while getopts ":f: rvh" opt
|
||
do
|
||
case $opt in
|
||
v ) print_version
|
||
exit 0
|
||
;;
|
||
h ) print_help
|
||
exit 0
|
||
;;
|
||
f) force="-f"
|
||
FORCE=true
|
||
now=$OPTARG
|
||
;;
|
||
r) renew="-r"
|
||
;;
|
||
\? ) echo "Opcion invalida -$OPTARG"
|
||
exit 1
|
||
;;
|
||
: ) force="-f"
|
||
now=""
|
||
esac
|
||
done
|
||
shift $((OPTIND-1))
|
||
|
||
# Mostrar ayuda si un caracter no deseado es introducido##
|
||
if [ -n "$1" ]; then
|
||
print_help
|
||
fi
|
||
|
||
# Matamos procesos detenidos
|
||
stopped_processes=$(ps auwx | awk 'NR>1 && $8 ~ "T" {print $2}')
|
||
if [ "$stopped_processes" ]; then kill -9 $stopped_processes; fi
|
||
|
||
# Definimos el fichero de lock
|
||
lockfile=/var/lock/$(basename $0)
|
||
lockfile-create $lockfile || exit 2
|
||
lockfile-touch $lockfile &
|
||
BADGER="$!"
|
||
|
||
trap "kill "${BADGER}" 2>/dev/null || true; lockfile-remove $lockfile; exit" QUIT INT TERM EXIT
|
||
|
||
LOCALES="es_ES.UTF-8"
|
||
|
||
# Controlamos la ejecución manual o automática de sinc_puppet
|
||
ENABLE=yes
|
||
[ -r /etc/default/sincpuppet ] && . /etc/default/sincpuppet
|
||
$FORCE && ENABLE=yes
|
||
|
||
if [ "$ENABLE" == "no" ] || [ ! "$ENABLE" ]; then
|
||
echo " * [info]: La aplicación 'sinc_puppet' está desactivada en /etc/default/sincpuppet."
|
||
echo " Para activarla poner el valor ENABLE=yes."
|
||
exit 0
|
||
fi
|
||
|
||
# Establecemos los locales por defecto
|
||
export LANG=$LOCALES
|
||
export LANGUAGE="es_ES:es:en"
|
||
export LC_ALL=$LOCALES
|
||
|
||
# Número máximo de segundos sin sincronizar con el servidor puppet
|
||
MAXTIME=`expr $INTERVAL \* 3600`
|
||
|
||
# Calculamos la diferencia
|
||
uno=$(stat -c %Y /var/log/syslog)
|
||
dos=$(stat -c %Y /var/lib/puppet/state/state.yaml)
|
||
dife=$((uno-dos))
|
||
dife2=0
|
||
|
||
if [ -f /var/lib/puppet/state/agent_catalog_run.lock ]; then
|
||
tres=$(stat -c %Y /var/lib/puppet/state/agent_catalog_run.lock)
|
||
dife2=$((uno-tres))
|
||
fi
|
||
|
||
if [ $dife2 -gt $MAXTIME ]; then
|
||
rm -f /var/lib/puppet/state/agent_catalog_run.lock
|
||
fi
|
||
|
||
solveapterrors
|
||
preparapuppetv6
|
||
|
||
echo
|
||
if [ $dife -lt 0 ]; then
|
||
minutos=${dife#-}
|
||
echo "La última sincronización con PUPPET fue hace $(($minutos / 60)) minutos" | logger -s -t $0
|
||
else
|
||
echo "La última sincronización con PUPPET fue hace $(($dife / 3600)) horas" | logger -s -t $0
|
||
fi
|
||
echo "Intervalo de sincronización con PUPPET: $INTERVAL horas" | logger -s -t $0
|
||
echo
|
||
|
||
# Salimos si no se ha alcanzado el tiempo máximo sin sincronizar con PUPPET o no se ha forzado la ejecución
|
||
if [ $dife -lt $MAXTIME ] || [ $# -eq 1 ] && [ "$force" != "-f" ] || [ $# -eq 1 ] && [ "$renew" != "-r" ]; then exit 0; fi
|
||
|
||
ping -c 1 $PING_SERVER >/dev/null 2>&1
|
||
ERROR=$?
|
||
MAX=0
|
||
|
||
until [ $ERROR -eq "0" ] || [ $MAX -eq $PING_TRIES ]; do
|
||
echo "Falló Ping al servidor Puppet. Nuevo intento en $PING_INTERVAL segundos....." | logger -s -t $0
|
||
MAX=`expr $MAX + 1`
|
||
sleep $PING_INTERVAL
|
||
ping -c 1 $PING_SERVER >/dev/null 2>&1
|
||
ERROR=$?
|
||
done
|
||
|
||
if [ $MAX -eq $PING_TRIES ]; then
|
||
echo "Imposible contactar con el servidor....." | logger -s -t $0
|
||
exit $MAX
|
||
fi
|
||
|
||
# Activamos puppet, por si estuviera desactivado
|
||
puppet agent --enable
|
||
|
||
if [ "$renew" == "-r" ]; then
|
||
uuid=$(/usr/bin/uuidgen -t) && sed -i "s/certname=.*/certname=$uuid/" /usr/share/linex-ubuntu-puppet/puppet.conf
|
||
find /var/lib/puppet/ssl/ -type f -name *.pem -not -name ca.pem -not -name crl.pem -exec rm -f {} \;
|
||
dosync -f now
|
||
fi
|
||
|
||
|
||
# Obtenemos el uuid del fichero puppet.conf
|
||
uuid=$(sed -n 's|certname=\(.*\)|\1|p' /usr/share/linex-ubuntu-puppet/puppet.conf)
|
||
|
||
# Si no existe el certificado del cliente, ejecutamos puppet tratando de recibir un certificado
|
||
if [ -z "$uuid" ]; then
|
||
uuid=$(/usr/bin/uuidgen -t) && sed -i "/server=puppetinstituto/a certname=$uuid" /usr/share/linex-ubuntu-puppet/puppet.conf
|
||
echo "Se ha generado un nuevo uuid para este host: $uuid" | logger -s -t $0
|
||
find /var/lib/puppet/ssl/ -type f -name *.pem -not -name ca.pem -not -name crl.pem -exec rm -f {} \;
|
||
|
||
dosync $force $now
|
||
fi
|
||
|
||
test -f /var/lib/puppet/ssl/certs/$uuid.pem
|
||
if [ $? -eq "0" ]; then
|
||
dosync $force $now
|
||
|
||
#Si existe el certificado uuid y no se consigue sincronizar. Se sincroniza la hora, se genera un nuevo uuid y se borran todos los certificados dentro de /var/lib/puppet/ssl
|
||
ntpdate -u servidor 2>/dev/null
|
||
uuid=$(/usr/bin/uuidgen -t) && sed -i "s/certname=.*/certname=$uuid/" /usr/share/linex-ubuntu-puppet/puppet.conf
|
||
find /var/lib/puppet/ssl/ -type f -name *.pem -exec rm -f {} \;
|
||
|
||
dosync $force $now
|
||
|
||
else
|
||
[ -f /var/lib/puppet/state/puppetdlock ] && rm -f /var/lib/puppet/state/puppetdlock
|
||
uuid=$(/usr/bin/uuidgen -t) && sed -i "s/certname=.*/certname=$uuid/" /usr/share/linex-ubuntu-puppet/puppet.conf
|
||
find /var/lib/puppet/ssl/ -type f -name *.pem -not -name $uuid.pem -not -name ca.pem -not -name crl.pem -exec rm -f {} \;
|
||
|
||
dosync $force $now
|
||
fi
|
||
|
||
#Si falla puede ser porque la versión puppet del servidor sea la 6.
|
||
#Hay un problema al traer ca.pem del servidor en versiones del cliente puppet v3.x
|
||
curl -k https://$(puppet agent --configprint server):8140/puppet-ca/v1/certificate/ca > /tmp/ca.pem 2>/dev/null
|
||
if `grep "BEGIN CERTIFICATE" /tmp/ca.pem >/dev/null`; then
|
||
if ! `diff /tmp/ca.pem $(puppet agent --configprint localcacert) >/dev/null` ; then
|
||
cp -f /tmp/ca.pem $(puppet agent --configprint localcacert)
|
||
dosync $force $now
|
||
fi
|
||
fi
|
||
|
||
echo "NO SE HA PODIDO REALIZAR SINCRONIZACIÓN CON PUPPET" | logger -s -t $0
|
ubuntu/jammy/all/linex-ubuntu-puppet/usr/share/linex-ubuntu-puppet/sincpuppet.default | ||
---|---|---|
# Defaults for sinc_puppet
|
||
#
|
||
|
||
# Definimos el idioma por defecto al ejecutar sinc_puppet
|
||
# LOCALES="es_ES.UTF-8"
|
||
LOCALES="es_ES.UTF-8"
|
||
|
||
# Activar o desactivar sinc_puppet:
|
||
# ENABLE="yes": activa sinc_puppet (opción por defecto)
|
||
# ENABLE="no" : desactiva sinc_puppet
|
||
# Si no existe la variable ENABLE o no tiene valor, es equivalente al valor 'yes'.
|
||
ENABLE="yes"
|
||
|
||
# Número máximo de horas sin sincronizar con el servidor puppet
|
||
# INTERVAL="12" # horas
|
||
INTERVAL="12" # horas
|
||
|
||
# Nombre DNS del servidor al que realizar ping para comprobar que estamos en el centro
|
||
# PING_SERVER="puppetinstituto"
|
||
PING_SERVER="puppetinstituto"
|
||
|
||
# Intervalo para volver a realizar ping en segundos
|
||
# PING_INTERVAL="30" # segundos
|
||
PING_INTERVAL="30" # segundos
|
||
|
||
# Número máximo de ping a realizar antes de dejar de intentar sincronizar con puppet
|
||
# PING_TRIES="3"
|
||
PING_TRIES="3"
|
||
|
||
# Definimos un tiempo máximo en minutos para retrasar la sincronización con el servidor
|
||
# El cliente se sincronizará de forma pseudoaleatoria dentro de este intervalo
|
||
# Básicamente sirve para evitar que muchas peticiones simultáneas de clientes saturen al servidor
|
||
# Este ajuste puede definirse en segundos (30 or 30s), minutos (30m), horas (6h),
|
||
# días (2d), o años (5y).
|
||
# SPLAYLIMIT="3m"
|
||
SPLAYLIMIT="3m"
|
||
|
||
# 'puppet agent' conectará con el servidor en intervalos de 'WAITFORCERT' segundos para pedir un certificado al servidor
|
||
# WAITFORCERT="30"
|
||
WAITFORCERT="30"
|
ubuntu/jammy/all/linex-ubuntu-puppet/usr/share/linex-ubuntu-puppet/sincpuppet.service | ||
---|---|---|
[Unit]
|
||
Description=Launch /usr/sbin/sinc_puppet on boot
|
||
Requires=network-online.target
|
||
After=network-online.target
|
||
|
||
[Service]
|
||
Type=oneshot
|
||
EnvironmentFile=-/usr/share/linex-ubuntu-puppet/sincpuppet.default
|
||
TimeoutStartSec=600
|
||
RemainAfterExit=yes
|
||
ExecStart=/usr/sbin/sinc_puppet -f now
|
||
|
||
[Install]
|
||
WantedBy=network-online.target
|
Exportar a: Unified diff
Añadido nuevo repo jammy