Revisión cc2331ec
Añadido por root hace casi 9 años
ubuntu/xenial/all/linex-ubuntu-puppet/debian/changelog | ||
---|---|---|
linex-ubuntu-puppet (1.3) linex; urgency=medium
|
||
|
||
* Modificado escuela2.0 por ubuntu 16.04 (Eli).
|
||
* Los certificados pasan a generarse a partir de un uuid en lugar de fqdn
|
||
* 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
|
||
|
ubuntu/xenial/all/linex-ubuntu-puppet/debian/conffiles | ||
---|---|---|
/usr/share/linex-ubuntu-puppet/escuela2.0
|
||
/usr/share/linex-ubuntu-puppet/puppet.conf
|
ubuntu/xenial/all/linex-ubuntu-puppet/debian/control | ||
---|---|---|
|
||
Package: linex-ubuntu-puppet
|
||
Architecture: all
|
||
Pre-Depends: uuid-runtime
|
||
Depends: ${misc:Depends}, puppet, puppet-common, pkgsync
|
||
Description: Configuración del cliente puppet
|
||
Instalación de las dependencias del cliente de puppet,
|
ubuntu/xenial/all/linex-ubuntu-puppet/debian/install | ||
---|---|---|
etc
|
||
usr
|
ubuntu/xenial/all/linex-ubuntu-puppet/debian/linex-ubuntu-puppet.links | ||
---|---|---|
/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 /etc/init.d/sincpuppet
|
||
/usr/share/linex-ubuntu-puppet/sinc_puppet /etc/network/if-up.d/sinc_puppet
|
||
|
ubuntu/xenial/all/linex-ubuntu-puppet/debian/postinst | ||
---|---|---|
#!/bin/bash
|
||
set -e
|
||
|
||
update-rc.d sincpuppet defaults
|
||
invoke-rc.d sincpuppet start
|
||
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
|
||
|
||
|
||
rm -r /var/lib/puppet/ssl
|
||
uuidgen | xargs -I uuid sed -i 's/certname = /certname = uuid/g' /etc/puppet/puppet.conf
|
||
|
||
puppet agent disable
|
||
systemctl disable puppet.service
|
||
[ -x /bin/systemctl ] && systemctl disable puppet.service
|
||
|
||
|
||
/usr/sbin/sinc_puppet &
|
||
exit 0
|
||
|
ubuntu/xenial/all/linex-ubuntu-puppet/etc/default/sincpuppet | ||
---|---|---|
# Defaults for sinc_puppet
|
||
#
|
||
|
||
# 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
|
||
|
||
# Nombre DNS del servidor al que realizar ping para comprobar que estamos en el centro
|
||
PING_SERVER="puppetinstituto"
|
||
|
||
# Intervalo para volver a realizar ping en segundos
|
||
PING_INTERVAL="30" # segundos
|
||
|
||
# Número máximo de ping a realizar antes de dejar de intentar sincronizar con puppet
|
||
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"
|
||
|
ubuntu/xenial/all/linex-ubuntu-puppet/usr/share/linex-ubuntu-puppet/puppet.conf | ||
---|---|---|
postrun_command=/etc/puppet/etckeeper-commit-post
|
||
server=puppetinstituto
|
||
pluginsync=false
|
||
certname =
|
||
|
||
[master]
|
||
# These are needed when the puppetmaster is run by passenger
|
ubuntu/xenial/all/linex-ubuntu-puppet/usr/share/linex-ubuntu-puppet/sinc_puppet | ||
---|---|---|
#!/bin/bash
|
||
#Modificado: 22/10/2015
|
||
# Script para tratar de realizar la sincronización del cliente puppet
|
||
# Colocar en /etc/network/if-up.d/ para que se ejecute al levantar el interfaz de red
|
||
# Esteban M. Navas Martín
|
||
# Modificado: 15/02/2015
|
||
# Modificado: 19/05/2016
|
||
|
||
# Controlamos la ejecución manual o automática de sinc_puppet
|
||
ENABLE=yes
|
||
[ -r /etc/default/sincpuppet ] && . /etc/default/sincpuppet
|
||
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
|
||
|
||
# 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))
|
||
|
||
dpkg --configure -a && apt-get -yf install >/dev/null 2>&1
|
||
# Aseguramos paquetes
|
||
dpkg --configure -a && apt-get -yf install && apt-get -y autoremove
|
||
|
||
echo "La última sincronización con PUPPET fué hace: "$(($dife / 3600)) "horas" | logger -t $0
|
||
echo "La última sincronización con PUPPET fue hace: "$(($dife / 3600)) "horas" | logger -s -t $0
|
||
echo "Intervalo de sincronización con PUPPET: $INTERVAL horas" | logger -s -t $0
|
||
echo
|
||
|
||
CUENTA=0
|
||
# Salimos si no se ha alcanzado el tiempo máximo sin sincronizar con PUPPET
|
||
if [ $dife -lt $MAXTIME ]; then exit 0; fi
|
||
|
||
#ip link | grep "state UP"
|
||
GW=`ip route | grep default | cut -f3 -d" "`
|
||
ping -c 1 $GW >/dev/null 2>&1
|
||
until [ $? -eq "0" ]; do
|
||
if [ $CUENTA -lt 5 ]; then
|
||
echo "No se detecta ninguna interfaz de red levantada. Nuevo intento en 60 segundo ..." | logger -t $0
|
||
CUENTA=`expr $CUENTA + 1`
|
||
fi
|
||
sleep 60
|
||
#ip link | grep "state UP"
|
||
GW=`ip route | grep default | cut -f3 -d" "`
|
||
ping -c 1 $GW >/dev/null 2>&1
|
||
done
|
||
|
||
ping -c 1 servidor >/dev/null 2>&1
|
||
ping -c 1 $PING_SERVER >/dev/null 2>&1
|
||
ERROR=$?
|
||
MAX=0
|
||
until [ $ERROR -eq "0" ] || [ $MAX -eq "5" ]; do
|
||
echo "Falló Ping al servidor Puppet. Nuevo intento en 30 segundos....." | logger -t $0
|
||
MAX=`expr $MAX + 1`
|
||
sleep 30
|
||
ping -c 1 servidor >/dev/null 2>&1
|
||
ERROR=$?
|
||
|
||
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 "5" ]; then
|
||
echo "Imposible contactar con el servidor..... exit 5" | logger -t $0
|
||
exit 5
|
||
|
||
if [ $MAX -eq $PING_TRIES ]; then
|
||
echo "Imposible contactar con el servidor....." | logger -s -t $0
|
||
exit 5
|
||
fi
|
||
|
||
#Si ha estado más de 12 horas sin sincronizar con puppet
|
||
if [ $dife -gt 43200 ]; then
|
||
echo "Conexión con servidor de puppet. Esperando entre 0 y 5 minutos para puppet....." | logger -t $0
|
||
sleep $(($(od -dN2 /dev/urandom | sed -n 's/[^ ]* //p')%300))
|
||
#puppetd -t
|
||
puppet agent --enable
|
||
puppet agent --test >/dev/null 2>&1
|
||
while [ $? -eq "1" ]; do
|
||
rm -f /var/lib/puppet/state/puppetdlock
|
||
rm -rf /var/lib/puppet/ssl
|
||
echo "FALLO Puppet. Nuevo intento en 30 segundos" | logger -t $0
|
||
sleep 30
|
||
#puppetd -t
|
||
puppet agent --enable
|
||
puppet agent --test >/dev/null 2>&1
|
||
done
|
||
# Activamos puppet, por si estuviera desactivado
|
||
puppet agent --enable
|
||
|
||
# Si no existe el certificado del cliente, ejecutamos puppet tratando de recibir un certificado
|
||
test -f /var/lib/puppet/ssl/certs/$(hostname -f).pem
|
||
if [ $? -eq "1" ]; then
|
||
puppet agent --test --waitforcert 60 >/dev/null 2>&1
|
||
exit 0
|
||
fi
|
||
|
||
#Si ha estado más de MAXTIME segundos sin sincronizar con puppet
|
||
if [ $dife -gt $MAXTIME ]; then
|
||
echo "Conexión con servidor de puppet. Esperando $SPLAYLIMIT para puppet....." | logger -s -t $0
|
||
puppet agent --onetime --no-daemonize --splay --splaylimit $SPLAYLIMIT
|
||
|
||
while [ $? -eq "1" ]; do
|
||
test -f /var/lib/puppet/state/puppetdlock && rm -f /var/lib/puppet/state/puppetdlock
|
||
rm -rf /var/lib/puppet/ssl/certs/$(hostname -f).pem
|
||
echo "FALLO Puppet. Nuevo intento en 30 segundos" | logger -s -t $0
|
||
puppet agent --test --waitforcert 60 >/dev/null 2>&1
|
||
done
|
||
fi
|
||
echo "Sistema PUPPET correcto" | logger -t $0
|
||
echo "Sistema PUPPET correcto" | logger -s -t $0
|
||
|
||
exit 0
|
Exportar a: Unified diff
linex-ubuntu-puppet: Varios cambios