jueves, 13 de octubre de 2011

Agregar los repositorio a chef

SEGUNDO GRAN PASO: Agregar los repositorios, entiendase cookbooks, templates ...
Lo primero es tener instalado git para poder jalar el repo de ospcode:

sudo apt-get install python-software-properties
sudo add-apt-repository ppa:git-core/ppa
sudo aptitude update
sudo aptitude safe-upgrade
sudo aptitude install git

Git es necesario, dado que el comando knife cookbook funciona usando git, es una ventaja ademas, tener los cookbooks en un repositorio con versiones de control. Crea un repositorio en GitHub donde almacenaras tus cookbooks, y dale los permisos necesarios para acceder desde tu chef-master. Crea en el chef-master las llaves para autenticar con el repo github.

ssh-keygen -t dsa

Asegura que la carpeta /var/chef/cookbooks (donde por defecto van los cookbooks) pertenezca al usuario que modificará los mismo

sudo chown luis:luis -R cookbooks

Inicializa un repositorio git:

git config --global user.name "Luis García Acosta"
git config --global user.email luis@springstar.com
git init
git add README
git commit -m 'first commit'
git remote add origin git@github.com:lgarciaac/springstar-cookbooks.git
git push -u origin master

Una ves logrado esto, chef y hithub están configurados para gozar de las bondades de chef, puedes empezar a agregar tus propios repositorios o repositorios publicos que se encuentran en http://community.opscode.com/cookbooks. En mi caso, no me pueden faltar ni mysql, ninginx ni apt

knife cookbook site install mysql
knife cookbook site install nginx
knife cookbook site install apt

Despues, basta con un simple push para manterner todo en HitHub

Una vez descargados los cookbooks, hay que subirlos al chef-server.

knife cookbook upload munin ó knife cookbook upload -a (sube todos los cookbooks respetando las dependencias)

Si este depende de otros cookbooks, va a protestar y a pedirlo antes

miércoles, 12 de octubre de 2011

Como instalar chef server en ubuntu

Como instalar chef master me ha dado tantos dolores de cabeza, creo que lo mejor es dejar un record de lo que he echo, tanto para mi como para otras personas. La instalación va a ser a travez de apt-get, por por gem


Entorno:

Ubuntu 10.04, instalación totalmente nueva solo ssh server como extra pakete


Actualizar la paqueteria de Ubuntu

sudo apt-get update; sudo apt-get upgrade


Agregar el reposito de Ospcode como se refleja en http://wiki.opscode.com/display/chef/Installing+Chef+Server+on+Debian+or+Ubuntu+using+Packages

sudo touch /etc/apt/sources.list.d/opscode.list
sudo echo "deb http://apt.opscode.com/ `lsb_release -cs`-0.10 main" | sudo tee /etc/apt/sources.list.d/opscode.list


Agregar el GPG Key y upgradear el indice

sudo mkdir -p /etc/apt/trusted.gpg.d
gpg --keyserver keys.gnupg.net --recv-keys 83EF826A
gpg --export packages@opscode.com | sudo tee /etc/apt/trusted.gpg.d/opscode-keyring.gpg > /dev/null
sudo apt-get update
sudo apt-get install opscode-keyring

Instalar chef y chef-server. Este paso descargará cerca de 200Mb, instalará RabbitMQ, CouchDB, Chef Server apies, Chef Server UI, en fin, todo lo que necesitamos :-)


Siguiendo las instrucciones de la referencia todo debe de marchar bien. Ademas del .pem para el cliente, se tiene que copiar el validator.pem

domingo, 2 de octubre de 2011

viernes, 19 de agosto de 2011

How to use Telnet to send email over Port 25 using SMTP

Telnet: TELNET (TELetype NETwork) is a network protocol used on the Internet or local area network (LAN) connections. It was developed in 1969 and standardized as IETF STD 8, one of the first Internet standards.

SMTP: Simple Mail Transfer Protocol (SMTP) is the de facto standard for e-mail transmissions across the Internet.


Step # 1: First, open a command prompt. To open a command prompt window, click Start, Run and then type in cmd and press Enter. You can also press the +R to open the Run prompt and then type in cmd in the open text box.

Step # 2: You need to know a remote mail server. If you are still in school or working, there is the excellent opportunity to use your University mail server or your company’s mail server for this.

type in telnet RemoteMailServer 25 at the command prompt. The Remote mail server here in this command is the mail server of your school or company. It is usually mailhost..edu or compmail..com or something on those lines. When you press enter, you are shown a quick prompt that you are connecting to the remote mail server.

Step # 3: Introduce yourself to the mail server. Play around a bit.
type in helo mailhost at the command prompt. The mail server responds back with something like this

250 RemoteMailHost. Hello , pleased to meet you.

Step # 4: You can now enter your email address.
type in mail from: your email id @ blah.com
The mail server responds back with a 250 … sender ok

Step # 5: You can now enter your receipient’s email address
type in rcpt to: recipient email id @ blah.com
The mail server responds back with a “Recipient OK” message

Step # 6: Now, you are ready to type in the body of the email message.
type in data and press enter.
Now, type your message and then finally press Enter. To end your message type in a single period “.” . Your message is now in the queue

Step # 7: To complete and finish the process, type in quit and press enter. The mail server responds with a “Bye” after which you see a “Connection to host lost” message displayed.

martes, 19 de julio de 2011

Instalar Git server Ubuntu, con ssh-key

http://fclose.com/b/linux/1432/setting-up-git-server-using-gitosis/
http://fclose.com/b/linux/1434/managing-repositories-on-git-server-using-gitosis/
https://help.ubuntu.com/community/Git

Si da problemas pidiendo passwords:
http://www.baptiste-wicht.com/2010/07/tip-how-to-solve-agent-admitted-failure-to-sign-using-the-key-error/

Instalar passenger

sudo gem install passenger
sudo passenger-install-apache2-module

El segundo comando larga una serie de validaciones, es muy instuitivo de seguir. Luego hay que  modificar la configuracion del apache. Algo más o menos así debe ser escrito (seguir las instrucciones del passenger-install-apache2-module, estas son un ejemplo)

LoadModule passenger_module /opt/local/lib/ruby/gems/1.8/gems/passenger-2.2.11/ext/apache2/mod_passenger.so
PassengerRoot /opt/local/lib/ruby/gems/1.8/gems/passenger-2.2.11
PassengerRuby /opt/local/bin/ruby


Por último, crear un virtual host:

   <VirtualHost *:80>
      ServerName www.yourhost.com
      DocumentRoot /somewhere/public    # <-- be sure to point to 'public'!
      <Directory /somewhere/public>
         AllowOverride all              # <-- relax Apache security settings
         Options -MultiViews            # <-- MultiViews must be turned off
      </Directory>
   </VirtualHost>



CREANDO  MAS DE UNS PROYECTO, CORRIENDOLOS CON DIFERENTES RUBY/GEM VERSIONES


Se

Como instalar mysql gem on ubuntu

Es posible que tratando de correr el comando:

gem install mysql

Nos de un problemón. Primero que todo dejar por seguro que tenemos instalado mysql-serve y mysq-client, luego instalar las librerias de mysql para ruby, y finalmente instalar la gem :-)

sudo apt-get install mysql-server mysql-client
sudo apt-get install libmysql-ruby libmysqlclient-dev
sudo gem install mysql

jueves, 16 de junio de 2011

Variables de entorno

Si necesitas correr un script con otro usuario, y necesitas fijar variables de entorno ... ni pierdas el tiempo fijándolas en .profile que no las carga. Fßijalas en el mismo script

Ruby:

#envs only for the database
ENV['ORACLE_HOME']      ='/usr/lib/oracle/11.2/client'
ENV['LD_LIBRARY_PATH']  ='/usr/lib/oracle/11.2/client/lib'
ENV['ORACLE_SID']       ='ifollow'
ENV['TNS_ADMIN']        ='/home/nagios'

Como instalar sqlplus para check_oracle_health

Instalar esto sqlplus, no olvidar que son los básicos, y el sqlplus que está más abajo:

http://samushka.blogspot.com/2009/04/installing-oracle-sqlplus-in-ubuntu.html

Instalar el check_oracle_health. En la vida real no hace falta el Modulo perl, si se usa sqlplus

http://labs.consol.de/lang/en/nagios/check_oracle_health/

lunes, 23 de mayo de 2011

Borrar los comandos, servicios de Nagios que no se usan

Recuerda, no borrar los comandos que se usan en lase definiciones de host, o para enviar notificaciones

DELETE FROM service WHERE id NOT IN (SELECT service_id FROM service_to_host)

DELETE FROM host_service_param WHERE service_id NOT IN (SELECT service_id FROM service_to_host)

DELETE FROM command WHERE id NOT IN (SELECT command_id FROM service) AND id NOT IN (15,5,287,253,103,4,104,3,43,22)

Cambiar el usuario del nagios al enviar email

  1. Cambiar hostname en: /etc/postfix/main.cf 
  2. Cambiar hostname en: /etc/mailname
  3. Reiniciar postfix
  4. Cambiar el Nombre del usuario de Nagios en /etc/passwd

Live Status for Nagios

Instalé todo el paquete check_mk. por tanto livestatus vino con el paquete.

http://mathias-kettner.de/checkmk_livestatus.html

Tratar de instalar solo el livestatus, no el resto de las cosas

Instalando el paquete solamente hace falta bajarlo de aquí:
http://mathias-kettner.de/download/

Despues en Thruk el fichero de configuración es: thruk.conf en la carpeta raiz the thruk. Copiar cualquiera de los ejemplos

Como probar que funciona??
desde donde sse instaló, correo un comando tcp en el unix socket para ver si resuelve, se explica en la página.

No olvidar configurar /etc/xinetd.d/livestatus y reiniciar xinetd para acceder desde otra máquina

lunes, 2 de mayo de 2011

Ver tamaño de las bases de dato

SELECT table_schema,  sum(data_length) / 1024 / 1024 "data", sum(index_length) / 1024 / 1024 "index", sum( data_length + index_length ) / 1024 / 1024 "total" FROM information_schema.TABLES GROUP BY table_schema \G;

SELECT table_schema "Data Base Name", sum( data_length + index_length ) / 1024 / 1024 "Data Base Size in MB" FROM information_schema.TABLES GROUP BY table_schema;

Puppet in Solaris

Instalation


Puppet requires both Facter and Ruby, neither of which will be found in a standard Solaris 8/9/10 installation.

A good and easy way to install Puppet and its dependencies is to use the OpenCSW archive. The first step is to install pkgutil, which enables you to easily retrieve software from the OpenCSW repositories.

With pkgutil installed, you can use it to install Puppet and it’s dependencies:
# /opt/csw/bin/pkgutil --yes --install puppet

Note that this not only installs puppet, it also enables the puppet agent. This installs a SMF(5) service:

# svcs svc:/network/puppetd:default

Once installed you must create de /etc/puppet/puppet.conf, and make sure that the ssldir exist. By default the ssldir point to /var/opt/csw/puppet/ssl, and this location doesn't exist.

Even when client defines ways to provide the puppetmaster, the way it worked for me was adding an entry in /etc/host for puppet, which is the default server the client takes.

Now you can restart you client puppet ;-)

Configuration


Puppet configuration can also be managed via configuration file. Puppet’s configuration file model is in the style of INI files. Each file is divided into namespace sections, and each section name is enclosed in parentheses and named for the Puppet function it configures; for example, the namespace used to configure the Puppet client daemon is called [puppetd]. The use of namespaces means options can be used in multiple namespaces, if the option is relevant to the binary being configured. For example, you can specify the same option twice, with different values, in the [puppetd] and [puppetmasterd] namespaces, and each binary will use only the configuration option contained in its own namespace.

Sections are:
main: General configuration options for multiple elements of Puppet
puppetd: Configuration options related to the Puppet client daemon
puppetmasterd: Configuration options related to the Puppet master daemon

An example:
[main]
vardir = /var/lib/puppet
logdir = /var/log/puppet

[puppetd]
localconfig = $vardir/localconfig

You can also use any configuration option from the Puppet configuration file on the command line by prefixing it with --. So to specify the vardir option on the command line, we would specify --vardir as an argument. Boolean configuration options are specified on the command line using an on/off model like so:

# puppetd --trace
# puppetd --no-trace