Revisión 525
Añadido por Alfonso Pastor hace más de 10 años
tareas_puppet/workstations/ramzswap_kernel3/files/ramzswap/desactiva.sh | ||
---|---|---|
#! /bin/sh
|
||
### BEGIN INIT INFO
|
||
# Provides: desactiva.sh
|
||
# Required-Start:
|
||
# Required-Stop:
|
||
# Default-Start:
|
||
# Default-Stop: 0,1,6
|
||
# Short-Description: desactiva la ramzswap
|
||
### END INIT INFO
|
||
|
||
for device in $(grep -E --only-matching '/dev/zram[[:digit:]]+' /proc/swaps); do
|
||
swapoff "$device"
|
||
done
|
||
# remove module, wait instead of failing if it's busy
|
||
rmmod --wait zram
|
||
tareas_puppet/workstations/ramzswap_kernel3/files/ramzswap/ramzswap.sh | ||
---|---|---|
#! /bin/sh
|
||
### BEGIN INIT INFO
|
||
# Provides: ramzswap.sh
|
||
# Required-Start: $remote_fs $syslog $all
|
||
# Required-Stop:
|
||
# Default-Start: 2 3 4 5
|
||
# Default-Stop: 0 1 6
|
||
# Short-Description: inicializa la ramzswap
|
||
### END INIT INFO
|
||
|
||
|
||
set -e
|
||
|
||
PATH=/sbin:/bin:/usr/sbin:/usr/bin
|
||
|
||
. /lib/init/swap-functions.sh
|
||
|
||
case "$1" in
|
||
|
||
start|"")
|
||
# Activa ramz
|
||
/root/ramzswap/inicializa.sh
|
||
;;
|
||
restart|reload|force-reload)
|
||
echo "Error: argument '$1' not supported" >&2
|
||
exit 3
|
||
;;
|
||
stop)
|
||
# Desactiva ramz
|
||
/root/ramzswap/desactiva.sh
|
||
;;
|
||
*)
|
||
echo "Usage: ramzwap.sh [start|stop]" >&2
|
||
exit 3
|
||
;;
|
||
esac
|
||
|
||
exit 0
|
||
|
||
tareas_puppet/workstations/ramzswap_kernel3/files/ramzswap/inicializa.sh | ||
---|---|---|
#! /bin/sh
|
||
### BEGIN INIT INFO
|
||
# Provides: inicializa.sh
|
||
# Required-Start:
|
||
# Required-Stop:
|
||
# Default-Start: 2 3 4 5
|
||
# Default-Stop: 0 1 6
|
||
# Short-Description: inicializa la ramzswap
|
||
### END INIT INFO
|
||
|
||
|
||
get_number_of_present_cpus() {
|
||
cpulist=$( cat /sys/devices/system/cpu/present | tr ',' ' ' )
|
||
local num_cpus=0
|
||
for item in $cpulist; do
|
||
if ( echo $item | grep --silent '-' ); then
|
||
greater_cpunum=$( echo $item | cut -d '-' -f 2 )
|
||
lesser_cpunum=$( echo $item | cut -d '-' -f 1 )
|
||
local num_cpus=$(( $num_cpus + $greater_cpunum - $lesser_cpunum + 1 ))
|
||
else
|
||
local num_cpus=$(( $num_cpus + 1 ))
|
||
fi
|
||
done
|
||
echo $num_cpus
|
||
}
|
||
|
||
# get the number of CPUs
|
||
num_cpus=$(get_number_of_present_cpus)
|
||
|
||
# set decremented number of CPUs
|
||
decr_num_cpus=$((num_cpus - 1))
|
||
|
||
# get the amount of memory in the machine
|
||
mem_total_kb=$(grep MemTotal /proc/meminfo | grep -E --only-matching '[[:digit:]]+')
|
||
mem_total=$((mem_total_kb * 1024))
|
||
|
||
# determine modprobe parameter name, depending on kernel version
|
||
if (uname --release | grep -E --silent "^3\.[123]"); then
|
||
num_devices_parameter='zram_num_devices'
|
||
else
|
||
num_devices_parameter='num_devices'
|
||
fi
|
||
|
||
# load zram modules
|
||
modprobe zram $num_devices_parameter=$num_cpus
|
||
|
||
# initialize the devices, set total size to 1/2 RAM
|
||
for i in $(seq 0 $decr_num_cpus); do
|
||
echo $((mem_total / 2 / num_cpus)) > /sys/block/zram$i/disksize
|
||
done
|
||
|
||
# Creating swap filesystems
|
||
for i in $(seq 0 $decr_num_cpus); do
|
||
mkswap /dev/zram$i
|
||
done
|
||
|
||
# Switch the swaps on
|
||
for i in $(seq 0 $decr_num_cpus); do
|
||
swapon -p 100 /dev/zram$i
|
||
done
|
||
tareas_puppet/workstations/ramzswap_kernel3/leeme.txt | ||
---|---|---|
Configura los workstations con la swap tirando de memoria RAM antes que la swap de disco.
|
||
Esto hace que todos los procesos de I/O sean mucho más rápidos.
|
||
|
||
Se intenta gestionar más eficientemente el uso de la swap.
|
||
|
||
Por defecto la configuración de ramzswap es la siguiente:
|
||
|
||
memoria_total /2 / num_cpus (para equipos con 1 Gb y 2 cpus 2 swap de ram de 256 Mb).
|
||
|
||
Autor: Oscar Vaquero (Administración SI)
|
||
|
||
|
||
Modificación de los scripts para adaptarlos a cualquier sistema,
|
||
creación de tarea puppet y pruebas.
|
||
|
||
|
||
Francisco Rodrigo López
|
||
IES Javier García Téllez (Caceres).
|
||
|
||
INSTRUCCIONES DE INSTALACION DEL MODULO
|
||
---------------------------------------
|
||
|
||
Desempaquetar en /etc/puppet/modules.
|
||
Incluirlo en clase-especifica.pp
|
tareas_puppet/workstations/ramzswap_kernel3/manifests/init.pp | ||
---|---|---|
class ramzswap_kernel3 {
|
||
|
||
file { "/root/ramzswap" :
|
||
owner=>root, group=>root, mode=>644,
|
||
ensure => directory,
|
||
}
|
||
|
||
file { "/etc/init.d/ramzswap.sh" :
|
||
owner=>root, group=>root, mode=>755,
|
||
source=>"puppet:///modules/ramzswap_kernel3/ramzswap/ramzswap.sh",
|
||
notify=> Exec ["crea-enlaces-ramzswap"],
|
||
}
|
||
|
||
file { "/root/ramzswap/desactiva.sh" :
|
||
owner=>root, group=>root, mode=>755,
|
||
source=>"puppet:///modules/ramzswap_kernel3/ramzswap/desactiva.sh",
|
||
require => File ["/root/ramzswap","/etc/init.d/ramzswap.sh"],
|
||
}
|
||
|
||
file { "/root/ramzswap/inicializa.sh" :
|
||
owner=>root, group=>root, mode=>755,
|
||
source=>"puppet:///modules/ramzswap_kernel3/ramzswap/inicializa.sh",
|
||
require => File ["/root/ramzswap","/etc/init.d/ramzswap.sh"],
|
||
notify => Exec ["crea-enlaces-ramzswap"],
|
||
}
|
||
|
||
exec { "crea-enlaces-ramzswap" :
|
||
path => "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
|
||
command => "update-rc.d ramzswap.sh defaults",
|
||
require => File ["/etc/init.d/ramzswap.sh"],
|
||
unless => "ls /etc/rc2.d/S??ramzswap.sh",
|
||
}
|
||
|
||
}
|
tareas_puppet/workstations/instala-firefox7/leeme.txt | ||
---|---|---|
|
||
Tarea: Instalacion de firefox 7 32 bits en los workstations.
|
||
|
||
Totalmente basada en la versión que hicieron Noemí y Paco, del IES Garcia Telléz, para
|
||
instalar en los clientes LTSP.
|
||
|
||
Ficheros:
|
||
instala_firefox7.pp: la tarea puppet. Ira en /etc/puppet/manifests/classes del servidor
|
||
puppet de workstations
|
||
IMPORTANTE: asume que el servidor puppet de los workstations se llama
|
||
"puppetworkstation". Si no se llama asi, hay que cambiarlo en
|
||
función de como se llame en tu IEs.
|
||
|
||
instala_firefox7.sh: el script de instalación. Irá en /etc/puppet/files del servidor puppet
|
||
de workstations. Puede usarse como script independiente para instalar a
|
||
mano el firefox7 en un workstation suelto, aunque no tengamos puppet.
|
||
|
||
local-settings.js, firefox.cfg: ficheros de configuración obligatoria de firefox. Deben ir en
|
||
/etc/puppet/files del servidor puppet de worktstations. Es la configuración
|
||
que queremos que tenga el firefox entre quien entre. En este caso he puesto
|
||
dos parámetros:
|
||
Pagina de inicio-> www.google.es
|
||
Actualizaciones firefox -> desactivadas (para evitar que se
|
||
te actualice automaticamente).
|
||
|
||
Cada cual puede poner aqui la configuración que quiera.
|
||
|
||
firefox-7.0.1.tar.bz2.32work: el fichero comprimido con el ejecutable completo. Debe ir en el
|
||
directorio /var/www/ficheros de servidor NFS de nuestro centro. No se copia
|
||
via puppet, se hace por wget.
|
||
|
||
Este fichero no va con la tarea puppet, es demasiado pesado, se puede descargar
|
||
desde:
|
||
|
||
http://172.19.231.2/ficheros/firefox-7.0.1.tar.bz2.32work
|
||
|
||
y dejarlo en el servidor NFS de cada cual.
|
||
|
||
Instalación:
|
||
|
||
Poner cada fichero en su sitio. Modificar el site.pp del servidor puppet de workstation para
|
||
hacer el include de la tarea y lanzar.
|
||
|
||
Como siempre es aconsejable probar primero en un único nodo y, si funciona correctamente, lanzarlo
|
||
para todos.
|
||
|
||
Alfonso Pastor.
|
||
IES Virgen de Guadalupe.
|
||
23/11/2011
|
tareas_puppet/workstations/instala-firefox7/instala-firefox7.sh | ||
---|---|---|
#!/bin/sh
|
||
# Noemí Bravo
|
||
# Se pueden utilizan comodines para generalizar el script.
|
||
# -----------------------------------------------------------
|
||
|
||
if [ ! -e /root/descargas ]; then mkdir -p /root/descargas; fi
|
||
|
||
cd /root/descargas
|
||
|
||
wget -q http://servidor/ficheros/firefox-7.0.1.tar.bz2.32work
|
||
|
||
#Instala el paquete
|
||
mv firefox-7.0.1.tar.bz2.32work /opt/firefox-7.0.1.tar.bz2
|
||
cd /opt
|
||
tar jxvf firefox-7.0.1.tar.bz2
|
||
rm firefox-7.0.1.tar.bz2
|
||
|
||
cd -
|
||
|
||
#modificamos el enlace a firefox
|
||
|
||
ln -fs /opt/firefox/firefox /usr/bin/iceweasel
|
||
|
tareas_puppet/workstations/instala-firefox7/firefox.cfg | ||
---|---|---|
// Lock specific preferences in Firefox so that users cannot edit them
|
||
lockPref("app.update.enabled", false);
|
||
lockPref("browser.startup.homepage", "http://www.google.es");
|
tareas_puppet/workstations/instala-firefox7/instala-firefox7.pp | ||
---|---|---|
class instala-firefox7 {
|
||
|
||
file {"/root/instala-firefox7.sh":
|
||
owner=>root, group=>root, mode=>755,
|
||
source=>"puppet://puppetworkstation/files/instala-firefox7.sh",
|
||
notify=> Exec["instala-firefox7"],
|
||
}
|
||
|
||
exec {"instala-firefox7":
|
||
command => "/root/instala-firefox7.sh",
|
||
require => File["/root/instala-firefox7.sh"],
|
||
refreshonly => true,
|
||
before => [ File["/opt/firefox/defaults/pref/local-settings.js"], File["/opt/firefox/firefox.cfg"] ],
|
||
}
|
||
|
||
file {"/opt/firefox/defaults/pref/local-settings.js":
|
||
owner=>root, group=>root, mode=>755,
|
||
source=>"puppet://puppetworkstation/files/local-settings.js",
|
||
}
|
||
|
||
file {"/opt/firefox/firefox.cfg":
|
||
owner=>root, group=>root, mode=>755,
|
||
source=>"puppet://puppetworkstation/files/firefox.cfg",
|
||
}
|
||
|
||
}
|
tareas_puppet/workstations/instala-firefox7/local-settings.js | ||
---|---|---|
pref("general.config.obscure_value", 0);
|
||
pref("general.config.filename", "firefox.cfg");
|
||
|
tareas_puppet/workstations/ramzswap/leeme.txt | ||
---|---|---|
Configura los workstations con la swap tirando de memoria RAM antes que la swap de disco.
|
||
Esto hace que todos los procesos de I/O sean mucho más rápidos.
|
||
|
||
Se intenta gestionar más eficientemente el uso de la swap.
|
||
|
||
Por defecto la configuración de ramzswap sigue esta formula:
|
||
|
||
memoria_total /2 / num_cpus (para equipos con 512 Mb con una sola cpu asigna 256 Mb).
|
||
|
||
Autor: Oscar Vaquero (Administración SI)
|
||
|
||
|
||
|
||
Modificación de los scripts para adaptarlos a cualquier sistema,
|
||
creación de tarea puppet y pruebas.
|
||
|
||
|
||
Francisco Rodrigo López
|
||
IES Javier García Téllez (Caceres).
|
||
|
||
INSTRUCCIONES DE INSTALACION DEL MODULO
|
||
---------------------------------------
|
||
|
||
Desempaquetar en /etc/puppet/modules.
|
||
Incluirlo en clase-especifica.pp
|
||
|
tareas_puppet/workstations/ramzswap/manifests/init.pp | ||
---|---|---|
class ramzswap {
|
||
|
||
file { "/root/ramzswap" :
|
||
owner=>root, group=>root, mode=>644,
|
||
ensure => directory,
|
||
}
|
||
|
||
file { "/lib/modules/2.6.32-5-686/kernel/ramzswap.ko" :
|
||
owner=>root, group=>root, mode=>664,
|
||
source=>"puppet:///modules/ramzswap/ramzswap/ramzswap.ko",
|
||
}
|
||
|
||
file { "/usr/bin/rzscontrol" :
|
||
owner=>root, group=>root, mode=>755,
|
||
source=>"puppet:///modules/ramzswap/ramzswap/rzscontrol",
|
||
}
|
||
|
||
file { "/etc/init.d/ramzswap.sh" :
|
||
owner=>root, group=>root, mode=>755,
|
||
source=>"puppet:///modules/ramzswap/ramzswap/ramzswap.sh",
|
||
notify=> Exec ["crea-enlaces-ramzswap"],
|
||
}
|
||
|
||
file { "/root/ramzswap/desactiva.sh" :
|
||
owner=>root, group=>root, mode=>755,
|
||
source=>"puppet:///modules/ramzswap/ramzswap/desactiva.sh",
|
||
require => File ["/root/ramzswap","/etc/init.d/ramzswap.sh"],
|
||
}
|
||
|
||
file { "/root/ramzswap/inicializa.sh" :
|
||
owner=>root, group=>root, mode=>755,
|
||
source=>"puppet:///modules/ramzswap/ramzswap/inicializa.sh",
|
||
require => File ["/root/ramzswap","/etc/init.d/ramzswap.sh"],
|
||
notify => Exec ["crea-enlaces-ramzswap"],
|
||
}
|
||
|
||
exec { "crea-enlaces-ramzswap" :
|
||
path => "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
|
||
command => "update-rc.d ramzswap.sh defaults",
|
||
require => File ["/etc/init.d/ramzswap.sh"],
|
||
unless => "ls /etc/rc2.d/S??ramzswap.sh",
|
||
}
|
||
|
||
}
|
tareas_puppet/workstations/ramzswap/files/ramzswap/desactiva.sh | ||
---|---|---|
#! /bin/sh
|
||
### BEGIN INIT INFO
|
||
# Provides: desactiva.sh
|
||
# Required-Start:
|
||
# Required-Stop:
|
||
# Default-Start:
|
||
# Default-Stop: 0,1,6
|
||
# Short-Description: desactiva la ramzswap
|
||
### END INIT INFO
|
||
|
||
for device in $(grep -E --only-matching '/dev/ramzswap[[:digit:]]+' /proc/swaps); do
|
||
swapoff "$device"
|
||
rzscontrol "$device" --reset
|
||
done
|
||
|
||
# remove module, wait instead of failing if it's busy
|
||
rmmod --wait ramzswap
|
||
tareas_puppet/workstations/ramzswap/files/ramzswap/ramzswap.sh | ||
---|---|---|
#! /bin/sh
|
||
### BEGIN INIT INFO
|
||
# Provides: ramzswap.sh
|
||
# Required-Start: $remote_fs $syslog $all
|
||
# Required-Stop:
|
||
# Default-Start: 2 3 4 5
|
||
# Default-Stop: 0 1 6
|
||
# Short-Description: inicializa la ramzswap
|
||
### END INIT INFO
|
||
|
||
|
||
set -e
|
||
|
||
PATH=/sbin:/bin:/usr/sbin:/usr/bin
|
||
|
||
. /lib/init/swap-functions.sh
|
||
|
||
case "$1" in
|
||
|
||
start|"")
|
||
# Activa ramz
|
||
/root/ramzswap/inicializa.sh
|
||
;;
|
||
restart|reload|force-reload)
|
||
echo "Error: argument '$1' not supported" >&2
|
||
exit 3
|
||
;;
|
||
stop)
|
||
# Desactiva ramz
|
||
/root/ramzswap/desactiva.sh
|
||
;;
|
||
*)
|
||
echo "Usage: ramzwap.sh [start|stop]" >&2
|
||
exit 3
|
||
;;
|
||
esac
|
||
|
||
exit 0
|
||
|
||
tareas_puppet/workstations/ramzswap/files/ramzswap/inicializa.sh | ||
---|---|---|
#! /bin/sh
|
||
### BEGIN INIT INFO
|
||
# Provides: inicializa.sh
|
||
# Required-Start:
|
||
# Required-Stop:
|
||
# Default-Start: 2 3 4 5
|
||
# Default-Stop: 0 1 6
|
||
# Short-Description: inicializa la ramzswap
|
||
### END INIT INFO
|
||
|
||
|
||
get_number_of_present_cpus() {
|
||
cpulist=$( cat /sys/devices/system/cpu/present | tr ',' ' ' )
|
||
local num_cpus=0
|
||
for item in $cpulist; do
|
||
if ( echo $item | grep --silent '-' ); then
|
||
greater_cpunum=$( echo $item | cut -d '-' -f 2 )
|
||
lesser_cpunum=$( echo $item | cut -d '-' -f 1 )
|
||
local num_cpus=$(( $num_cpus + $greater_cpunum - $lesser_cpunum + 1 ))
|
||
else
|
||
local num_cpus=$(( $num_cpus + 1 ))
|
||
fi
|
||
done
|
||
echo $num_cpus
|
||
}
|
||
|
||
# get the number of CPUs
|
||
num_cpus=$(get_number_of_present_cpus)
|
||
|
||
# set decremented number of CPUs
|
||
decr_num_cpus=$((num_cpus - 1))
|
||
|
||
# get the amount of memory in the machine
|
||
mem_total_kb=$(grep MemTotal /proc/meminfo | grep -E --only-matching '[[:digit:]]+')
|
||
mem_total=$((mem_total_kb * 1024))
|
||
|
||
# determine modprobe parameter name, depending on kernel version
|
||
if (uname --release | grep -E --silent "^3\.[123]"); then
|
||
num_devices_parameter='zram_num_devices'
|
||
else
|
||
num_devices_parameter='num_devices'
|
||
fi
|
||
|
||
# load zram modules
|
||
disk_size_kb=$((mem_total_kb / 2 / num_cpus))
|
||
|
||
modprobe lzo_compress
|
||
modprobe lzo_decompress
|
||
insmod /lib/modules/2.6.32-5-686/kernel/ramzswap.ko $num_devices_parameter=$num_cpus disksize_kb=$disk_size_kb
|
||
|
||
# initialize the devices, set total size to 1/2 RAM
|
||
for i in $(seq 0 $decr_num_cpus); do
|
||
rzscontrol /dev/ramzswap$i --init
|
||
done
|
||
|
||
# Switch the swaps on
|
||
for i in $(seq 0 $decr_num_cpus); do
|
||
swapon -p 100 /dev/ramzswap$i
|
||
done
|
||
tareas_puppet/workstations/configura-cliente-puppet/leeme.txt | ||
---|---|---|
DESCRIPCION
|
||
-------------------------------------------------------------------------------------------------------------
|
||
|
||
Destino : Equipos que queramos configurar como clientes del servidor puppet principal del centro (puppetinstituto).
|
||
|
||
Acción : Configura como cliente puppet el equipo donde apliquemos configura-cliente-puppet.pp haciendo lo siguiente:
|
||
|
||
* Se asegura que el paquete puppet esté instalado.
|
||
* Crea el archivo de configuración de puppet /etc/puppet/puppet.conf con la siguiente configuración:
|
||
|
||
[main]
|
||
logdir=/var/log/puppet
|
||
vardir=/var/lib/puppet
|
||
ssldir=/var/lib/puppet/ssl
|
||
rundir=/var/run/puppet
|
||
factpath=/lib/facter
|
||
#pluginsync=true
|
||
server=puppetinstituto
|
||
runinterval=5400
|
||
syslogfacility=
|
||
report=true
|
||
|
||
[master]
|
||
templatedir=/var/lib/puppet/templates
|
||
|
||
[agent]
|
||
report = true
|
||
# listen = true
|
||
|
||
* Crea el archivo /etc/default/puppet que activa el servicio en el arranque:
|
||
|
||
|
||
# Defaults for puppet - sourced by /etc/init.d/puppet
|
||
|
||
# Start puppet on boot?
|
||
START=yes
|
||
|
||
# Startup options
|
||
DAEMON_OPTS=""
|
||
|
||
|
||
* Crea el archivo /etc/escuela2.0" con el siguiente contenido:
|
||
use=workstation
|
||
|
||
* Crea el archivo /usr/lib/ruby/1.8/facter/leefichero.rb que lee los facter definidos en el fichero /etc/escuela2.0
|
||
|
||
* Asegura que exista el directorio de reports var/lib/puppet/reports
|
||
|
||
* Borra el directorio /var/lib/puppet/ssl por si existieran certificados antigüos en el cliente
|
||
|
||
* Inicia el servicio
|
||
-------------------------------------------------------------------------------------------------------------
|
||
|
||
|
||
INSTRUCCIONES DE USO
|
||
-------------------------------------------------------------------------------------------------------------
|
||
|
||
* Copiar configura-cliente-puppet.pp al equipo que queremos configurar
|
||
|
||
* Aplicar la configuración:
|
||
|
||
puppet apply configura-cliente-puppet.pp
|
||
-------------------------------------------------------------------------------------------------------------
|
||
|
||
|
||
NOTA
|
||
-------------------------------------------------------------------------------------------------------------
|
||
|
||
Podemos usar este archivo para configurar cualquier cliente, con tan sólo cambiar el siguiente recurso:
|
||
|
||
file { "/etc/escuela2.0":
|
||
content => "use=workstation",
|
||
}
|
||
-------------------------------------------------------------------------------------------------------------
|
||
|
||
|
||
|
||
Creado por:
|
||
|
||
Esteban M. Navas Martín
|
||
Administrador informático del IES Valle del Jerte.
|
||
Plasencia
|
||
12-Diciembre-2012
|
||
|
||
|
||
Modificado: 08-Febrero-2013
|
||
|
||
Deshabilitado el parámetro "listen = true" para evitar un bug por el que no
|
||
se ejecuta el agente puppet de forma automática.
|
tareas_puppet/workstations/configura-cliente-puppet/configura-cliente-puppet.pp | ||
---|---|---|
package { puppet:
|
||
ensure=>"installed"
|
||
}
|
||
|
||
file { "/etc/default/puppet":
|
||
content => "# Defaults for puppet - sourced by /etc/init.d/puppet\n\n# Start puppet on boot?\nSTART=yes\n\n# Startup options\nDAEMON_OPTS=\"\"\n"
|
||
}
|
||
|
||
file { "/etc/puppet/puppet.conf":
|
||
content => "[main]\nlogdir=/var/log/puppet\nvardir=/var/lib/puppet\nssldir=/var/lib/puppet/ssl\nrundir=/var/run/puppet\nfactpath=$vardir/lib/facter\n#pluginsync=true\nserver=puppetinstituto\nruninterval=5400\nsyslogfacility=\nreport=true\n\n[master]\ntemplatedir=/var/lib/puppet/templates\n\n[agent]\nreport = true",
|
||
require => Package["puppet"],
|
||
}
|
||
|
||
file { "/etc/escuela2.0":
|
||
content => "use=workstation",
|
||
}
|
||
|
||
file { "/usr/lib/ruby/1.8/facter/leefichero.rb":
|
||
content => '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',
|
||
}
|
||
|
||
file { "/var/lib/puppet/reports":
|
||
ensure => directory
|
||
}
|
||
|
||
file { "/var/lib/puppet/ssl":
|
||
ensure => absent,
|
||
force => true,
|
||
}
|
||
|
||
service { puppet:
|
||
ensure => running,
|
||
require => Package["puppet"],
|
||
subscribe => File["/etc/default/puppet","/etc/puppet/puppet.conf"]
|
||
}
|
tareas_puppet/workstations/squeeze/ramzswap_kernel3/leeme.txt | ||
---|---|---|
Configura los workstations con la swap tirando de memoria RAM antes que la swap de disco.
|
||
Esto hace que todos los procesos de I/O sean mucho más rápidos.
|
||
|
||
Se intenta gestionar más eficientemente el uso de la swap.
|
||
|
||
Por defecto la configuración de ramzswap es la siguiente:
|
||
|
||
memoria_total /2 / num_cpus (para equipos con 1 Gb y 2 cpus 2 swap de ram de 256 Mb).
|
||
|
||
Autor: Oscar Vaquero (Administración SI)
|
||
|
||
|
||
Modificación de los scripts para adaptarlos a cualquier sistema,
|
||
creación de tarea puppet y pruebas.
|
||
|
||
|
||
Francisco Rodrigo López
|
||
IES Javier García Téllez (Caceres).
|
||
|
||
INSTRUCCIONES DE INSTALACION DEL MODULO
|
||
---------------------------------------
|
||
|
||
Desempaquetar en /etc/puppet/modules.
|
||
Incluirlo en clase-especifica.pp
|
tareas_puppet/workstations/squeeze/ramzswap_kernel3/manifests/init.pp | ||
---|---|---|
class ramzswap_kernel3 {
|
||
|
||
file { "/root/ramzswap" :
|
||
owner=>root, group=>root, mode=>644,
|
||
ensure => directory,
|
||
}
|
||
|
||
file { "/etc/init.d/ramzswap.sh" :
|
||
owner=>root, group=>root, mode=>755,
|
||
source=>"puppet:///modules/ramzswap_kernel3/ramzswap/ramzswap.sh",
|
||
notify=> Exec ["crea-enlaces-ramzswap"],
|
||
}
|
||
|
||
file { "/root/ramzswap/desactiva.sh" :
|
||
owner=>root, group=>root, mode=>755,
|
||
source=>"puppet:///modules/ramzswap_kernel3/ramzswap/desactiva.sh",
|
||
require => File ["/root/ramzswap","/etc/init.d/ramzswap.sh"],
|
||
}
|
||
|
||
file { "/root/ramzswap/inicializa.sh" :
|
||
owner=>root, group=>root, mode=>755,
|
||
source=>"puppet:///modules/ramzswap_kernel3/ramzswap/inicializa.sh",
|
||
require => File ["/root/ramzswap","/etc/init.d/ramzswap.sh"],
|
||
notify => Exec ["crea-enlaces-ramzswap"],
|
||
}
|
||
|
||
exec { "crea-enlaces-ramzswap" :
|
||
path => "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
|
||
command => "update-rc.d ramzswap.sh defaults",
|
||
require => File ["/etc/init.d/ramzswap.sh"],
|
||
unless => "ls /etc/rc2.d/S??ramzswap.sh",
|
||
}
|
||
|
||
}
|
tareas_puppet/workstations/squeeze/ramzswap_kernel3/files/ramzswap/inicializa.sh | ||
---|---|---|
#! /bin/sh
|
||
### BEGIN INIT INFO
|
||
# Provides: inicializa.sh
|
||
# Required-Start:
|
||
# Required-Stop:
|
||
# Default-Start: 2 3 4 5
|
||
# Default-Stop: 0 1 6
|
||
# Short-Description: inicializa la ramzswap
|
||
### END INIT INFO
|
||
|
||
|
||
get_number_of_present_cpus() {
|
||
cpulist=$( cat /sys/devices/system/cpu/present | tr ',' ' ' )
|
||
local num_cpus=0
|
||
for item in $cpulist; do
|
||
if ( echo $item | grep --silent '-' ); then
|
||
greater_cpunum=$( echo $item | cut -d '-' -f 2 )
|
||
lesser_cpunum=$( echo $item | cut -d '-' -f 1 )
|
||
local num_cpus=$(( $num_cpus + $greater_cpunum - $lesser_cpunum + 1 ))
|
||
else
|
||
local num_cpus=$(( $num_cpus + 1 ))
|
||
fi
|
||
done
|
||
echo $num_cpus
|
||
}
|
||
|
||
# get the number of CPUs
|
||
num_cpus=$(get_number_of_present_cpus)
|
||
|
||
# set decremented number of CPUs
|
||
decr_num_cpus=$((num_cpus - 1))
|
||
|
||
# get the amount of memory in the machine
|
||
mem_total_kb=$(grep MemTotal /proc/meminfo | grep -E --only-matching '[[:digit:]]+')
|
||
mem_total=$((mem_total_kb * 1024))
|
||
|
||
# determine modprobe parameter name, depending on kernel version
|
||
if (uname --release | grep -E --silent "^3\.[123]"); then
|
||
num_devices_parameter='zram_num_devices'
|
||
else
|
||
num_devices_parameter='num_devices'
|
||
fi
|
||
|
||
# load zram modules
|
||
modprobe zram $num_devices_parameter=$num_cpus
|
||
|
||
# initialize the devices, set total size to 1/2 RAM
|
||
for i in $(seq 0 $decr_num_cpus); do
|
||
echo $((mem_total / 2 / num_cpus)) > /sys/block/zram$i/disksize
|
||
done
|
||
|
||
# Creating swap filesystems
|
||
for i in $(seq 0 $decr_num_cpus); do
|
||
mkswap /dev/zram$i
|
||
done
|
||
|
||
# Switch the swaps on
|
||
for i in $(seq 0 $decr_num_cpus); do
|
||
swapon -p 100 /dev/zram$i
|
||
done
|
||
tareas_puppet/workstations/squeeze/ramzswap_kernel3/files/ramzswap/desactiva.sh | ||
---|---|---|
#! /bin/sh
|
||
### BEGIN INIT INFO
|
||
# Provides: desactiva.sh
|
||
# Required-Start:
|
||
# Required-Stop:
|
||
# Default-Start:
|
||
# Default-Stop: 0,1,6
|
||
# Short-Description: desactiva la ramzswap
|
||
### END INIT INFO
|
||
|
||
for device in $(grep -E --only-matching '/dev/zram[[:digit:]]+' /proc/swaps); do
|
||
swapoff "$device"
|
||
done
|
||
# remove module, wait instead of failing if it's busy
|
||
rmmod --wait zram
|
||
tareas_puppet/workstations/squeeze/ramzswap_kernel3/files/ramzswap/ramzswap.sh | ||
---|---|---|
#! /bin/sh
|
||
### BEGIN INIT INFO
|
||
# Provides: ramzswap.sh
|
||
# Required-Start: $remote_fs $syslog $all
|
||
# Required-Stop:
|
||
# Default-Start: 2 3 4 5
|
||
# Default-Stop: 0 1 6
|
||
# Short-Description: inicializa la ramzswap
|
||
### END INIT INFO
|
||
|
||
|
||
set -e
|
||
|
||
PATH=/sbin:/bin:/usr/sbin:/usr/bin
|
||
|
||
. /lib/init/swap-functions.sh
|
||
|
||
case "$1" in
|
||
|
||
start|"")
|
||
# Activa ramz
|
||
/root/ramzswap/inicializa.sh
|
||
;;
|
||
restart|reload|force-reload)
|
||
echo "Error: argument '$1' not supported" >&2
|
||
exit 3
|
||
;;
|
||
stop)
|
||
# Desactiva ramz
|
||
/root/ramzswap/desactiva.sh
|
||
;;
|
||
*)
|
||
echo "Usage: ramzwap.sh [start|stop]" >&2
|
||
exit 3
|
||
;;
|
||
esac
|
||
|
||
exit 0
|
||
|
||
tareas_puppet/workstations/squeeze/configura-cliente-puppet/leeme.txt | ||
---|---|---|
DESCRIPCION
|
||
-------------------------------------------------------------------------------------------------------------
|
||
|
||
Destino : Equipos que queramos configurar como clientes del servidor puppet principal del centro (puppetinstituto).
|
||
|
||
Acción : Configura como cliente puppet el equipo donde apliquemos configura-cliente-puppet.pp haciendo lo siguiente:
|
||
|
||
* Se asegura que el paquete puppet esté instalado.
|
||
* Crea el archivo de configuración de puppet /etc/puppet/puppet.conf con la siguiente configuración:
|
||
|
||
[main]
|
||
logdir=/var/log/puppet
|
||
vardir=/var/lib/puppet
|
||
ssldir=/var/lib/puppet/ssl
|
||
rundir=/var/run/puppet
|
||
factpath=/lib/facter
|
||
#pluginsync=true
|
||
server=puppetinstituto
|
||
runinterval=5400
|
||
syslogfacility=
|
||
report=true
|
||
|
||
[master]
|
||
templatedir=/var/lib/puppet/templates
|
||
|
||
[agent]
|
||
report = true
|
||
# listen = true
|
||
|
||
* Crea el archivo /etc/default/puppet que activa el servicio en el arranque:
|
||
|
||
|
||
# Defaults for puppet - sourced by /etc/init.d/puppet
|
||
|
||
# Start puppet on boot?
|
||
START=yes
|
||
|
||
# Startup options
|
||
DAEMON_OPTS=""
|
||
|
||
|
||
* Crea el archivo /etc/escuela2.0" con el siguiente contenido:
|
||
use=workstation
|
||
|
||
* Crea el archivo /usr/lib/ruby/1.8/facter/leefichero.rb que lee los facter definidos en el fichero /etc/escuela2.0
|
||
|
||
* Asegura que exista el directorio de reports var/lib/puppet/reports
|
||
|
||
* Borra el directorio /var/lib/puppet/ssl por si existieran certificados antigüos en el cliente
|
||
|
||
* Inicia el servicio
|
||
-------------------------------------------------------------------------------------------------------------
|
||
|
||
|
||
INSTRUCCIONES DE USO
|
||
-------------------------------------------------------------------------------------------------------------
|
||
|
||
* Copiar configura-cliente-puppet.pp al equipo que queremos configurar
|
||
|
||
* Aplicar la configuración:
|
||
|
||
puppet apply configura-cliente-puppet.pp
|
||
-------------------------------------------------------------------------------------------------------------
|
||
|
||
|
||
NOTA
|
||
-------------------------------------------------------------------------------------------------------------
|
||
|
||
Podemos usar este archivo para configurar cualquier cliente, con tan sólo cambiar el siguiente recurso:
|
||
|
||
file { "/etc/escuela2.0":
|
||
content => "use=workstation",
|
||
}
|
||
-------------------------------------------------------------------------------------------------------------
|
||
|
||
|
||
|
||
Creado por:
|
||
|
||
Esteban M. Navas Martín
|
||
Administrador informático del IES Valle del Jerte.
|
||
Plasencia
|
||
12-Diciembre-2012
|
||
|
||
|
||
Modificado: 08-Febrero-2013
|
||
|
||
Deshabilitado el parámetro "listen = true" para evitar un bug por el que no
|
||
se ejecuta el agente puppet de forma automática.
|
tareas_puppet/workstations/squeeze/configura-cliente-puppet/configura-cliente-puppet.pp | ||
---|---|---|
package { puppet:
|
||
ensure=>"installed"
|
||
}
|
||
|
||
file { "/etc/default/puppet":
|
||
content => "# Defaults for puppet - sourced by /etc/init.d/puppet\n\n# Start puppet on boot?\nSTART=yes\n\n# Startup options\nDAEMON_OPTS=\"\"\n"
|
||
}
|
||
|
||
file { "/etc/puppet/puppet.conf":
|
||
content => "[main]\nlogdir=/var/log/puppet\nvardir=/var/lib/puppet\nssldir=/var/lib/puppet/ssl\nrundir=/var/run/puppet\nfactpath=$vardir/lib/facter\n#pluginsync=true\nserver=puppetinstituto\nruninterval=5400\nsyslogfacility=\nreport=true\n\n[master]\ntemplatedir=/var/lib/puppet/templates\n\n[agent]\nreport = true",
|
||
require => Package["puppet"],
|
||
}
|
||
|
||
file { "/etc/escuela2.0":
|
||
content => "use=workstation",
|
||
}
|
||
|
||
file { "/usr/lib/ruby/1.8/facter/leefichero.rb":
|
||
content => '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',
|
||
}
|
||
|
||
file { "/var/lib/puppet/reports":
|
||
ensure => directory
|
||
}
|
||
|
||
file { "/var/lib/puppet/ssl":
|
||
ensure => absent,
|
||
force => true,
|
||
}
|
||
|
||
service { puppet:
|
||
ensure => running,
|
||
require => Package["puppet"],
|
||
subscribe => File["/etc/default/puppet","/etc/puppet/puppet.conf"]
|
||
}
|
tareas_puppet/workstations/squeeze/instala-firefox7/instala-firefox7.pp | ||
---|---|---|
class instala-firefox7 {
|
||
|
||
file {"/root/instala-firefox7.sh":
|
||
owner=>root, group=>root, mode=>755,
|
||
source=>"puppet://puppetworkstation/files/instala-firefox7.sh",
|
||
notify=> Exec["instala-firefox7"],
|
||
}
|
||
|
||
exec {"instala-firefox7":
|
||
command => "/root/instala-firefox7.sh",
|
||
require => File["/root/instala-firefox7.sh"],
|
||
refreshonly => true,
|
||
before => [ File["/opt/firefox/defaults/pref/local-settings.js"], File["/opt/firefox/firefox.cfg"] ],
|
||
}
|
||
|
||
file {"/opt/firefox/defaults/pref/local-settings.js":
|
||
owner=>root, group=>root, mode=>755,
|
||
source=>"puppet://puppetworkstation/files/local-settings.js",
|
||
}
|
||
|
||
file {"/opt/firefox/firefox.cfg":
|
||
owner=>root, group=>root, mode=>755,
|
||
source=>"puppet://puppetworkstation/files/firefox.cfg",
|
||
}
|
||
|
||
}
|
tareas_puppet/workstations/squeeze/instala-firefox7/firefox.cfg | ||
---|---|---|
// Lock specific preferences in Firefox so that users cannot edit them
|
||
lockPref("app.update.enabled", false);
|
||
lockPref("browser.startup.homepage", "http://www.google.es");
|
tareas_puppet/workstations/squeeze/instala-firefox7/local-settings.js | ||
---|---|---|
pref("general.config.obscure_value", 0);
|
||
pref("general.config.filename", "firefox.cfg");
|
||
|
tareas_puppet/workstations/squeeze/instala-firefox7/leeme.txt | ||
---|---|---|
|
||
Tarea: Instalacion de firefox 7 32 bits en los workstations.
|
||
|
||
Totalmente basada en la versión que hicieron Noemí y Paco, del IES Garcia Telléz, para
|
||
instalar en los clientes LTSP.
|
||
|
||
Ficheros:
|
||
instala_firefox7.pp: la tarea puppet. Ira en /etc/puppet/manifests/classes del servidor
|
||
puppet de workstations
|
||
IMPORTANTE: asume que el servidor puppet de los workstations se llama
|
||
"puppetworkstation". Si no se llama asi, hay que cambiarlo en
|
||
función de como se llame en tu IEs.
|
||
|
||
instala_firefox7.sh: el script de instalación. Irá en /etc/puppet/files del servidor puppet
|
||
de workstations. Puede usarse como script independiente para instalar a
|
||
mano el firefox7 en un workstation suelto, aunque no tengamos puppet.
|
||
|
||
local-settings.js, firefox.cfg: ficheros de configuración obligatoria de firefox. Deben ir en
|
||
/etc/puppet/files del servidor puppet de worktstations. Es la configuración
|
||
que queremos que tenga el firefox entre quien entre. En este caso he puesto
|
||
dos parámetros:
|
||
Pagina de inicio-> www.google.es
|
||
Actualizaciones firefox -> desactivadas (para evitar que se
|
||
te actualice automaticamente).
|
||
|
||
Cada cual puede poner aqui la configuración que quiera.
|
||
|
||
firefox-7.0.1.tar.bz2.32work: el fichero comprimido con el ejecutable completo. Debe ir en el
|
||
directorio /var/www/ficheros de servidor NFS de nuestro centro. No se copia
|
||
via puppet, se hace por wget.
|
||
|
||
Este fichero no va con la tarea puppet, es demasiado pesado, se puede descargar
|
||
desde:
|
||
|
||
http://172.19.231.2/ficheros/firefox-7.0.1.tar.bz2.32work
|
||
|
||
y dejarlo en el servidor NFS de cada cual.
|
||
|
||
Instalación:
|
||
|
||
Poner cada fichero en su sitio. Modificar el site.pp del servidor puppet de workstation para
|
||
hacer el include de la tarea y lanzar.
|
||
|
||
Como siempre es aconsejable probar primero en un único nodo y, si funciona correctamente, lanzarlo
|
||
para todos.
|
||
|
||
Alfonso Pastor.
|
||
IES Virgen de Guadalupe.
|
||
23/11/2011
|
tareas_puppet/workstations/squeeze/instala-firefox7/instala-firefox7.sh | ||
---|---|---|
#!/bin/sh
|
||
# Noemí Bravo
|
||
# Se pueden utilizan comodines para generalizar el script.
|
||
# -----------------------------------------------------------
|
||
|
||
if [ ! -e /root/descargas ]; then mkdir -p /root/descargas; fi
|
||
|
||
cd /root/descargas
|
||
|
||
wget -q http://servidor/ficheros/firefox-7.0.1.tar.bz2.32work
|
||
|
||
#Instala el paquete
|
||
mv firefox-7.0.1.tar.bz2.32work /opt/firefox-7.0.1.tar.bz2
|
||
cd /opt
|
||
tar jxvf firefox-7.0.1.tar.bz2
|
||
rm firefox-7.0.1.tar.bz2
|
||
|
||
cd -
|
||
|
||
#modificamos el enlace a firefox
|
||
|
||
ln -fs /opt/firefox/firefox /usr/bin/iceweasel
|
||
|
tareas_puppet/workstations/squeeze/ramzswap/manifests/init.pp | ||
---|---|---|
class ramzswap {
|
||
|
||
file { "/root/ramzswap" :
|
||
owner=>root, group=>root, mode=>644,
|
||
ensure => directory,
|
||
}
|
||
|
||
file { "/lib/modules/2.6.32-5-686/kernel/ramzswap.ko" :
|
||
owner=>root, group=>root, mode=>664,
|
||
source=>"puppet:///modules/ramzswap/ramzswap/ramzswap.ko",
|
||
}
|
||
|
||
file { "/usr/bin/rzscontrol" :
|
||
owner=>root, group=>root, mode=>755,
|
||
source=>"puppet:///modules/ramzswap/ramzswap/rzscontrol",
|
||
}
|
||
|
||
file { "/etc/init.d/ramzswap.sh" :
|
||
owner=>root, group=>root, mode=>755,
|
||
source=>"puppet:///modules/ramzswap/ramzswap/ramzswap.sh",
|
||
notify=> Exec ["crea-enlaces-ramzswap"],
|
||
}
|
||
|
||
file { "/root/ramzswap/desactiva.sh" :
|
||
owner=>root, group=>root, mode=>755,
|
||
source=>"puppet:///modules/ramzswap/ramzswap/desactiva.sh",
|
||
require => File ["/root/ramzswap","/etc/init.d/ramzswap.sh"],
|
||
}
|
||
|
||
file { "/root/ramzswap/inicializa.sh" :
|
||
owner=>root, group=>root, mode=>755,
|
||
source=>"puppet:///modules/ramzswap/ramzswap/inicializa.sh",
|
||
require => File ["/root/ramzswap","/etc/init.d/ramzswap.sh"],
|
||
notify => Exec ["crea-enlaces-ramzswap"],
|
||
}
|
||
|
||
exec { "crea-enlaces-ramzswap" :
|
||
path => "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
|
||
command => "update-rc.d ramzswap.sh defaults",
|
||
require => File ["/etc/init.d/ramzswap.sh"],
|
||
unless => "ls /etc/rc2.d/S??ramzswap.sh",
|
||
}
|
||
|
||
}
|
tareas_puppet/workstations/squeeze/ramzswap/files/ramzswap/desactiva.sh | ||
---|---|---|
#! /bin/sh
|
||
### BEGIN INIT INFO
|
||
# Provides: desactiva.sh
|
||
# Required-Start:
|
||
# Required-Stop:
|
||
# Default-Start:
|
||
# Default-Stop: 0,1,6
|
||
# Short-Description: desactiva la ramzswap
|
||
### END INIT INFO
|
||
|
||
for device in $(grep -E --only-matching '/dev/ramzswap[[:digit:]]+' /proc/swaps); do
|
||
swapoff "$device"
|
||
rzscontrol "$device" --reset
|
||
done
|
||
|
||
# remove module, wait instead of failing if it's busy
|
||
rmmod --wait ramzswap
|
||
tareas_puppet/workstations/squeeze/ramzswap/files/ramzswap/ramzswap.sh | ||
---|---|---|
#! /bin/sh
|
||
### BEGIN INIT INFO
|
||
# Provides: ramzswap.sh
|
||
# Required-Start: $remote_fs $syslog $all
|
||
# Required-Stop:
|
||
# Default-Start: 2 3 4 5
|
||
# Default-Stop: 0 1 6
|
||
# Short-Description: inicializa la ramzswap
|
||
### END INIT INFO
|
||
|
||
|
||
set -e
|
||
|
||
PATH=/sbin:/bin:/usr/sbin:/usr/bin
|
||
|
||
. /lib/init/swap-functions.sh
|
||
|
||
case "$1" in
|
||
|
||
start|"")
|
||
# Activa ramz
|
||
/root/ramzswap/inicializa.sh
|
||
;;
|
||
restart|reload|force-reload)
|
||
echo "Error: argument '$1' not supported" >&2
|
||
exit 3
|
||
;;
|
||
stop)
|
||
# Desactiva ramz
|
||
/root/ramzswap/desactiva.sh
|
||
;;
|
||
*)
|
||
echo "Usage: ramzwap.sh [start|stop]" >&2
|
||
exit 3
|
||
;;
|
||
esac
|
||
|
||
exit 0
|
||
|
||
tareas_puppet/workstations/squeeze/ramzswap/files/ramzswap/inicializa.sh | ||
---|---|---|
#! /bin/sh
|
||
### BEGIN INIT INFO
|
||
# Provides: inicializa.sh
|
||
# Required-Start:
|
||
# Required-Stop:
|
||
# Default-Start: 2 3 4 5
|
Exportar a: Unified diff
Reordenacion puppet-workstations