Skip to content

Instantly share code, notes, and snippets.

@nemonik
Created October 10, 2012 20:01
Show Gist options
  • Save nemonik/3868053 to your computer and use it in GitHub Desktop.
Save nemonik/3868053 to your computer and use it in GitHub Desktop.
Install Notes for OpenStack, Puppet, RVM

Installing OpenStack

:Info: My install notes for Puppet (both agent and master) from source, OpenStack from source, and RVM on Ubuntu 12.04

:Author: Michael Joseph Walsh

Initialize a VM

Create a VirtualBox VM with 3072 MBytes of memory, a 20 GB Hard drive, 4 processors, and add 3 Network adapters (one NAT to provide Intermet access, another Host-only adapter for the public interface, and third Host-only adapter for the private network), assign the ubuntu-12.04-server-amd64.iso to the CDROM drive of the VM. Start the VM and finish the install naming the VM "stack", and create a stack account.

After the install finishes login as user stack

sudo -i
nano /etc/network/intefaces

and enter the following

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto eth0
iface eth0 inet dhcp

# Public Interface
auto eth1
iface eth1 inet static
    address 172.16.0.201
        netmask 255.255.0.0
        network 172.16.0.0
        broadcast 172.16.255.255

# Private VLAN Interface
auto eth2
iface eth2 inet manual
        up ifconfig eth2 up

Bring up the interface as root:

sudo ifup eth1

Edit /etc/hosts and enter as root:

172.16.0.201    stack.exmample.com stack

Use these commands to update the OS as root*: sudo -i apt-get update && apt-get upgrade -y

Install RVM

Guidance to install RVM (the Ruby Version Manager) used across the master and nodes.

Install the dependencies needed for ruby:

sudo -i apt-get install -y patch curl build-essential git-core curl libmysqlclient-dev nodejs openssl libreadline6 libreadline6-dev zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev ncurses-dev automake libtool bison subversion
bash -s stable < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer)

Logout, and log back in.

I found I needed to add your user to the rvm group like so:

exit
sudo usermod -a -G rvm $USER

Do NOT do this using sudo -i, but exactly as instructed above.

Logout, and log back in, and use:

groups

to validate rvm membership

Install latest ruby 1.8.x, but NOT as root or via sudo:

rvm install 1.8.7 && rvm --default use 1.8.7 && ruby -v

Install some gems, but NOT as root or via sudo:

gem update && gem install rubygems-update rspec

Install puppet from source

Guidance to install puppet from source across the master and the nodes.

Install 2.7.x:

Use the following commands, but NOT as root nor as sudo to install puppet 2.7.x:

cd ~
git clone git://github.com/puppetlabs/puppet
cd ~/puppet
git checkout -b origin/2.7.x origin/2.7.x
rake create_gem
cd pkg
gem install *.gem

Use the '--no-rdoc' parameter if you run into errors installing in regards to the install of the documentation.

Puppet cannot create users with password via itself. Each user created will have a '!'for the password in the /etc/shadow file indicating now password was not set. You must install 'ruby-libeshadow' via:

gem install libshadow

Install Openstack module from source

Guidance to install openstack module from source. Used w/ or w/o puppet master.

You'll need RVM installed.

Use these commands:

sudo -i
apt-get install git
gem install rake
mkdir /etc/puppet
mkdir /etc/puppet/modules
git clone git://github.com/puppetlabs/puppetlabs-openstack /etc/puppet/modules/openstack
cd /etc/puppet/modules/openstack
# gem install puppetlabs_spec_helper
rake modules:clone

The puppetlabs_spec_helper gem didn't appear needed for me.

Installing via puppet w/o puppet master

Install RVM.

Create puppet user and group

groupadd puppet
useradd -g puppet puppet

Install the latest puppet from source.

Install openstack module from source.

Create the following node declaration:

cd ~
nano openstack_all.pp

with the following text:

node 'stack.example.com' {
  class { 'openstack::all':
      public_address            => '172.16.0.201',
      public_interface          => eth1,
      private_interface         => eth2,
      floating_range            => '172.16.0.224/27',
      fixed_range               => '10.0.0.0/27',
      admin_email               => '[email protected]',
      admin_password            => 'openstack',
      keystone_admin_token      => 'openstack',
      nova_user_password        => 'openstack',
      glance_user_password      => 'openstack',
      rabbit_password           => 'openstack',
      rabbit_user               => 'rabbit',
      libvirt_type              => 'qemu',
  }
}

Install openstack all-in-one via:

puppet apply /home/stack/openstack_all.pp --certname openstack_all --debug

Open your browser to http://172.16.0.201

Installing Puppet Master

Install Ubuntu 12.04 server from ubuntu-12.04-server-amd64.iso. Once up, login in as puppet:

sudo -i
nano /etc/network/intefaces

and enter the following

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto eth0
iface eth0 inet dhcp

# Public Interface
auto eth1
iface eth1 inet static
    address 172.16.0.199
        netmask 255.255.0.0
        network 172.16.0.0
        broadcast 172.16.255.255

Bring up the interface

sudo ifup eth1

Edit /etc/hosts and enter:

172.16.0.199 puppet.example.com puppet

Install RVM.

Install the latest puppet from source.

Start and permanently enable the services using Puppet:

sudo -i
puppet resource service puppet ensure=running enable=true
puppet resource group puppet ensure=present

Initialize the puppet configuration:

sudo -i
puppetmasterd --genconfig > /etc/puppet/puppet.conf

Make the following changes to /etc/puppet/puppet.conf:

[main]
certname = puppet.example.com

Copy auth.conf template into place:

sudo -i
cp /home/puppet/puppet/conf/auth.conf /etc/puppet/auth.conf

Create manifests as puppet will not start without:

sudo -i
mkdir /etc/puppet/manifests
touch /etc/puppet/manifests/site.pp

Run puppet master, don't worry about running as a service just yet

sudo -i
puppet master --verbose --no-daemonize

or

sudo -i
puppet master --daemonize --debug --verbos && tail -f /var/log/syslog

Install Puppet Dashboard

In another window, install Puppet Dashboard from source:

git clone git://github.com/puppetlabs/puppet-dashboard.git

sudo apt-get install -y mysql-server libmysqlclient-dev

Install some needed gem dependencies, but not as root or via sudo:

env ARCHFLAGS="-arch x86_64"
gem install mysql --no-rdoc --no-ri -- --with-mysql-config=/usr/bin/mysql_config
gem install rdoc

Install rack (To see why version rack 1.1.2 here visit http://projects.puppetlabs.com/issues/11669):

gem install rack --version 1.1.2

Configure database and users:

mysql -u root -p

Enter these commands:

CREATE DATABASE dashboard_production CHARACTER SET utf8;
CREATE USER 'dashboard'@'localhost' IDENTIFIED BY 'puppet';
GRANT ALL PRIVILEGES ON dashboard_production.* TO 'dashboard'@'localhost';

Optionally enter these:

CREATE DATABASE dashboard_development CHARACTER SET utf8;
CREATE DATABASE dashboard_test CHARACTER SET utf8;
GRANT ALL PRIVILEGES ON dashboard_development.* TO 'dashboard'@'localhost';
GRANT ALL PRIVILEGES ON dashboard_test.* TO 'dashboard'@'localhost';

Note, to change password once set use:

SET PASSWORD FOR 'dashboard'@'localhost' = PASSWORD('some_other_password');

Exit mysql via:

quit

Then configure dashboard:

cd ~/puppet-dashboard
cp config/database.yml.example config/database.yml

Edit config/database.yml and provide the password set above for each environment above:

cp config/settings.yml.example config/settings.yml

Edit /etc/mysql/my.cnf as root and replace:

max_allowed_packet = 16M

w/

max_allowed_packet = 32M

Then restart mysql:

sudo restart mysql

Then prep the databases:

cd ~/puppet-dashboard
rake RAILS_ENV=production db:migrate
rake db:migrate db:test:prepare

Generating Certs for connecting to the Puppet Master:

cd ~/puppet-dashboard
rake cert:create_key_pair
rake cert:request
puppet cert --list
puppet cert sign dashboard
rake cert:retrieve

To view invenory supprt, edit /etc/puppet/auth.conf and add the following to the end of the file:

path /facts
auth yes
method find, search
allow dashboard

To enable the Filebucket Viewer, and edit /etc/puppet/manifests/sites.pp and add:

filebucket { "main":
  server => "puppet.example.com",
  path => false,
}

File { backup => "main" }

And edit ~/puppet-dashboard/config/settings.yml and make the following changes:

use_file_bucket_diffs: true
enable_inventory_service: true

Edit /etc/puppet/puppet.conf and make these changes:

[master]
    report = true
    reports = store, http
    reporturl = http://puppet.example.com:3000/reports/upload

One each puppet agent node, edit /etc/puppet/puppet.conf and make these changes:

[agent]
    report = true

Importing existing reports:

cd ~/puppet-dashboard
rake RAILS_ENV=production reports:import

Then run the dashboard:

cd ~/puppet-dashboard
env RAILS_ENV=production script/delayed_job -p puppet -n 1 start
./script/server -e production

Then open your browser to http://172.16.0.199:3000/

Install Openstack module

Install openstack module from source.

Install Openstack via puppet w/ puppet master

On the master

Install a Puppet Master elsewhere on your network.

Install Openstack module from source.

Ensure the site.pp on the stack contains by editing /etc/puppet/manifests/site.pp

import 'nodes.pp'
$puppetserver = 'puppet.example.com'

Add the following node configuration to the stack by edditing /etc/puppet/manifests/node.pp

node 'stack.example.com' {
  class { 'openstack::all':
    public_address            => '172.16.0.201',
    public_interface          => eth1,
    private_interface         => eth2,
    floating_range            => '172.16.0.224/27',
    fixed_range               => '10.0.0.0/27',
    admin_email               => '[email protected]',
    admin_password            => 'openstack',
    keystone_admin_token      => 'openstack',
    nova_user_password        => 'openstack',
    glance_user_password      => 'openstack',
    rabbit_password           => 'openstack',
    rabbit_user               => 'rabbit',
    libvirt_type              => 'qemu',
  }
}

Since, we're not running DNS we will need edit /etc/hosts and add the OpenStack node we'll create shortly:

172.16.0.201    stack.example.com stack

As root edit /etc/puppet/puppet.conf and set pluginsync to true:

[main]
pluginsync = true

Ensure puppet master is up an running, e.g. like so:

sudo -i
puppet master --daemonize --debug --verbose --debug && tail -f /var/log/syslog

On the OpenStack node

For the OpenStack node install Ubuntu 12.04 server from ubuntu-12.04-server-amd64.iso. Once up, login is as stack:

sudo -i
nano /etc/network/intefaces

and enter the following

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback

# Public Interface
auto eth1
iface eth1 inet static
    address 172.16.0.201
    netmask 255.255.0.0
    network 172.16.0.0
    broadcast 172.16.255.255

# Private VLAN Interface
auto eth2
iface eth2 inet manual
        up ifconfig eth2 up

Bring up the interface

sudo ifup eth1

Edit /etc/hosts and add the following as root:

172.16.0.201    stack.example.com stack
172.16.0.199    puppet.example.com puppet

Ensure the master is up and reachable:

ping puppet.example.com

Install RVM.

Create puppet user and group, if you did not creat puppet account upon OS install:

sudo -i
groupadd puppet
useradd -g puppet puppet

Install the latest puppet from source.

As root create /etc/puppet/puppet.conf and add:

[main]
pluginsync = true
runinterval = 300

[agent]
report = true

runinterval = 300 configures the agent to query the master every 5-minutes.

Start the agent on the Openstack instance:

sudo -i
puppet agent --server=puppet.example.com --no-daemonize --verbose --debug

Monitoring the logs of the master you'll see the request, once that happens you need to sign the request like so on the master:

puppet cert --sign stack.example.com

or sign all requests via:

puppet cert --sign --all

The logging on both stack and puppet master will indicate progress.

On stack the agent will successfully indicate via something like:

notice: Starting Puppet client version 2.7.18

And the Openstack node should start configuring OpenStack.

Afterward, set up the puppet agent to start at boot. Since, we are using rvm we'll need to use rvm's wrapper to configure the environment to which ruby and gems to run to execute puppet.

rvm wrapper ruby-1.8.7-p370 initd puppet

The ruby_string used here with a valuye of ruby-1.8.7-p370 maybe be different for your deployment. Use

rvm current

to return the value to use for the ruby_string. Install the following service startup script for the agent by editing /etc/init.d/puppet:

#! /bin/sh
### BEGIN INIT INFO
# Provides:          puppet
# Required-Start:    $network $named $remote_fs $syslog
# Required-Stop:     $network $named $remote_fs $syslog
# Should-Start:      puppet
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
### END INIT INFO

PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/usr/local/rvm/bin/initd_puppet

DAEMON_OPTS=""
NAME="agent"
DESC="puppet agent"
PIDFILE="/var/run/puppet/${NAME}.pid"

test -x $DAEMON || exit 0

[ -r /etc/default/puppet ] && . /etc/default/puppet

. /lib/lsb/init-functions

is_true() {
    if [ "x$1" = "xtrue" -o "x$1" = "xyes" -o "x$1" = "x0" ] ; then
         return 0
    else
        return 1
    fi
}

reload_puppet_agent() {
    start-stop-daemon --stop --quiet --signal HUP --pidfile $PIDFILE
}

start_puppet_agent() {
    if is_true "$START" ; then
        start-stop-daemon --start --quiet --pidfile $PIDFILE \
                --startas $DAEMON -- $NAME $DAEMON_OPTS
    else
        echo ""
        echo "puppet not configured to start, please edit /etc/default/puppet to enable"
    fi
}

stop_puppet_agent() {
    start-stop-daemon --stop --quiet --oknodo --pidfile $PIDFILE
}

status_puppet_agent() {
    status_of_proc -p "${PIDFILE}" "${DAEMON}" "${NAME}"
}

case "$1" in
    start)
        log_begin_msg "Starting $DESC"
        start_puppet_agent
        log_end_msg $?
        ;;
    stop)
        log_begin_msg "Stopping $DESC"
        stop_puppet_agent
        log_end_msg $?
        ;;
    reload)
        log_begin_msg "Reloading $DESC"
        reload_puppet_agent
        log_end_msg $?
        ;;
    status)
        status_puppet_agent
        ;;
    restart|force-reload)
        log_begin_msg "Restarting $DESC"
        stop_puppet_agent
        sleep 1
        start_puppet_agent
        log_end_msg $?
        ;;
    *)
        echo "Usage: $0 {start|stop|status|restart|force-reload|reload}" >&2
        exit 1
        ;;
esac

Change the permissions on the script like so:

chmod 0755 /etc/init.d/puppet

Puppet by default is not configured to start, please edit /etc/default/puppet to enable

START=yes

Optionally,

DAEMON_OPT=" --verbose --debug"

Start on the command-line:

/etc/init.d/puppet start

To monitor the daemon

tail -f /var/log/syslog

monitor for messages about certificate request and such as action may need to be taken on your part.

Install image into Openstack

export SERVICE_TOKEN=openstack
export OS_TENANT_NAME=openstack
export OS_USERNAME=admin
export OS_PASSWORD=openstack
export OS_AUTH_URL=http://localhost:5000/v2.0/
export SERVICE_ENDPOINT=http://localhost:35357/v2.0

Either:

nova image-list

or:

glance index

Retrieve some images that puppet can be installed on:

wget http://uec-images.ubuntu.com/releases/11.10/release/ubuntu-11.10-server-cloudimg-amd64-disk1.img
wget https://cloud-images.ubuntu.com/precise/current/precise-server-cloudimg-amd64-disk1.img
wget https://launchpad.net/cirros/trunk/0.3.0/+download/cirros-0.3.0-x86_64-disk.img

Install image(s) into glance via:

glance add name="Ubuntu 12.04" is_public=true container_format=ovf disk_format=qcow2 < ./precise-server-cloudimg-amd64-disk1.img

glance add name="cirrOS-0.3.0-x86_64" is_public=true container_format=bare disk_format=qcow2 distro="cirrOS-0.3.0-x86_64" < cirros-0.3.0-x86_64-disk.img

Create a ssh key pair:

ssh-keygen -t rsa

Upload the ssh public-key:

nova keypair-add --pub_key /home/stack/.ssh/id_rsa.pub stack_key && nova keypair-list

Create an Ubuntu instance:

nova boot --flavor m1.tiny --image <image id obtained from "nova image-list"> --key_name stack_key first_instance --poll
nova list
nova show <id of instance from "nova list" output>

Activate ssh access:

nova secgroup-add-rule default tcp 22 22 0.0.0.0/0

will return:

+-------------+-----------+---------+-----------+--------------+
| IP Protocol | From Port | To Port |  IP Range | Source Group |
+-------------+-----------+---------+-----------+--------------+
| tcp         | 22        | 22      | 0.0.0.0/0 |              |
+-------------+-----------+---------+-----------+--------------+

Allocate a floating IP for the instance:

nova floating-ip-create

will return:

+--------------+-------------+----------+------+
|      Ip      | Instance Id | Fixed Ip | Pool |
+--------------+-------------+----------+------+
| 172.16.0.225 | None        | None     | nova |
+--------------+-------------+----------+------+

Assign the allocated floating IP to the instance:

nova add-floating-ip first_instance <IP obtained from "nova floating-ip-create">

Secure shell into the instance:

ssh -i .ssh/id_rsa ubuntu@<IP obtained from "nova floating-ip-create">

You may not be able to secure shell in, because the ~/.ssh/known_hosts holds a value in it associated with the ip previously. If so remove it or the file, and retry to secure shell in.

Otherwise, you may need to restart the Openstack service:

/etc/init.d/nova-compute restart
/etc/init.d/nova-api restart
/etc/init.d/nova-scheduler restart
/etc/init.d/nova-cert restart

Using Euca2ools

Create a Test Project tenant:

cd ~
keystone tenant-list
keystone tenant-create --name test_project --description "Test project" --enabled true

And it will return:

+-------------+----------------------------------+
|   Property  |              Value               |
+-------------+----------------------------------+
| description | Test project                     |
| enabled     | True                             |
| id          | f19f0370ddd64381bb4eb7ef1695b278 |
| name        | test_project                     |
+-------------+----------------------------------+

Create a Keystone test user:

keystone user-create --name test --tenant_id f19f0370ddd64381bb4eb7ef1695b278 --pass test --email [email protected] --enabled true

and it will return:

+----------+-------------------------------------+
| Property |               Value                 |
+----------+-------------------------------------+
| email    | [email protected]                    |
| enabled  | True                                |
| id       | aebb1f00250148148d6dc6553e510f68    |
| name     | test                                |
| password | $6$rounds=40000$T…                  |
| tenantId | f19f0370ddd64381bb4eb7ef1695b278    |
+----------+-------------------------------------+

Add the admin roll to the test user:

keystone role-list

Note the id of the admin role and use in the next command:

keystone user-role-add --user aebb1f00250148148d6dc6553e510f68 --role acb414eca5c4411cb10092bc80851545 --tenant_id f19f0370ddd64381bb4eb7ef1695b278

keystone role-list --user aebb1f00250148148d6dc6553e510f68 --tenant_id f19f0370ddd64381bb4eb7ef1695b278

and it will return:

+----------------------------------+-------+
|                id                |  name |
+----------------------------------+-------+
| acb414eca5c4411cb10092bc80851545 | admin |
+----------------------------------+-------+

Create the ec2 credentials:

keystone ec2-credentials-create --user aebb1f00250148148d6dc6553e510f68 --tenant_id f19f0370ddd64381bb4eb7ef1695b278

List the Keystone credtionals for the test user:

keystone ec2-credentials-list --user aebb1f00250148148d6dc6553e510f68

and it will return:

+--------------+----------------------------------+----------------------------------+
|    tenant    |              access              |              secret              |
+--------------+----------------------------------+----------------------------------+
| test_project | 06ddc51997ff41a38cefa6d1a5fb8304 | e0aab28d89a64623b4b026a5def50124 |
+--------------+----------------------------------+----------------------------------+

Now create a nova test user with the same access and secret Keystone credentials.

nova-manage user admin --name=test --access=06ddc51997ff41a38cefa6d1a5fb8304 --secret=e0aab28d89a64623b4b026a5def50124

and it will return:

2012-07-27 02:04:11 AUDIT nova.auth.manager [-] Created user test (admin: True)
export EC2_ACCESS_KEY=06ddc51997ff41a38cefa6d1a5fb8304
export EC2_SECRET_KEY=e0aab28d89a64623b4b026a5def50124

Add the cloudadmin roll to test user on test_project:

nova-manage role add test cloudadmin test_project

Create the zip with your keys and env settings:

cd ~
mkdir test_project
cd ~/test_project
nova-manage project zipfile test_project test my.zip
unzip <zip file>

For me the novarc contained in the zip requiring me to edit the EC2_ACCESS_KEY changing its value to:

export EC2_ACCESS_KEY="06ddc51997ff41a38cefa6d1a5fb8304"

Verify the values for EC2_URL, S3_URL, and NOVA_URL contained in novarc by running respectfully:

netstat -tnap | grep 8773
netstat -tnap | grep 3333
netstat -tnap | grep 8774

Then:

. novarc

On stack, puppet master will have already installed the ec2tools, elsewhere install via:

sudo -i
apt-get install euca2ools

Create keypair:

euca-add-keypair openstack > ./openstack.pem
chmod 0600 *.pem

Upload an image:

uec-publish-tarball ../ubuntu-11.10-server-cloudimg-amd64.tar.gz oneiric_ocelot_bucket

will output something like:

WARNING: 'uec-publish-tarball' is now to 'cloud-publish-tarbal.
Please update your tools or docs
Fri Jul 27 03:49:31 EDT 2012: ====== extracting image ======
Warning: no ramdisk found, assuming '--ramdisk none'
kernel : oneiric-server-cloudimg-amd64-vmlinuz-virtual
ramdisk: none
image  : oneiric-server-cloudimg-amd64.img
Fri Jul 27 03:49:40 EDT 2012: ====== bundle/upload kernel ======
Fri Jul 27 03:49:44 EDT 2012: ====== bundle/upload image ======
Fri Jul 27 03:50:32 EDT 2012: ====== done ======
emi="ami-00000007"; eri="none"; eki="aki-00000006";

List available images:

euca-describe-images

Delete an image:

euca-deregister <image id, e.g. "ami-00000007">

Create an instance:

euca-run-instances ami-00000007 -k openstack  -t m1.tiny

Check that it is running:

euca-describe-instances

Note the instance id is "i-00000001" for later use.

Authorize SSH:

euca-authorize default -P tcp -p 22 -s 0.0.0.0/0

Access via SSH:

ssh -i openstack.pem [email protected]

Assign a floating IP to the instance:

euca-allocate-address
euca-associate-address -i i-00000001 172.16.0.225

Access via SSH:

ssh -i openstack.pem [email protected]

Ensure the master is up and reachable:

ping puppet.example.com

Install RVM.

Create puppet user and group, if you did not creat puppet account upon OS install:

sudo -i
groupadd puppet
useradd -g puppet puppet

Install the latest puppet from source. Configure Puppet.conf:

sudo -i
mkdir /etc/puppet

Followed by editing /etc/puppet/puppet.conf:

[main]
pluginsync = true
runinterval = 300

[agent]
server = puppet.example.com

runinterval = 300 configures the agent to query the master every 5-minutes.

Edit /etc/hosts and add the following as root:

172.16.0.201    stack.example.com stack
172.16.0.199    puppet.example.com puppet

On the master create /etc/puppet/autosign.conf as root:

*.novalocal

And restart puppet master.

Start the agent on the vm instance:

sudo -i
puppet agent --server=puppet.example.com --no-daemonize --verbose --debug

The logging on both vm instance and puppet master will indicate progress.

On the vm instance will be slower, but the agent will indicate success via something like:

notice: Starting Puppet client version 2.7.18

Afterward, set up the puppet agent to start at boot. Since, we are using rvm we'll need to use rvm's wrapper to configure the environment to which ruby and gems to run to execute puppet. Do NOT do this as root or via sudo:

rvm wrapper ruby-1.8.7-p370 initd puppet

The ruby_string used here with a valuye of ruby-1.8.7-p370 maybe be different for your deployment. Use

rvm current

to return the value to use for the ruby_string. Install the following service startup script for the agent by editing /etc/init.d/puppet as root:

#! /bin/sh
### BEGIN INIT INFO
# Provides:          puppet
# Required-Start:    $network $named $remote_fs $syslog
# Required-Stop:     $network $named $remote_fs $syslog
# Should-Start:      puppet
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
### END INIT INFO

PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/usr/local/rvm/bin/initd_puppet

DAEMON_OPTS=""
NAME="agent"
DESC="puppet agent"
PIDFILE="/var/run/puppet/${NAME}.pid"

test -x $DAEMON || exit 0

[ -r /etc/default/puppet ] && . /etc/default/puppet

. /lib/lsb/init-functions

is_true() {
    if [ "x$1" = "xtrue" -o "x$1" = "xyes" -o "x$1" = "x0" ] ; then
        return 0
    else
        return 1
    fi
}

reload_puppet_agent() {
        start-stop-daemon --stop --quiet --signal HUP --pidfile $PIDFILE
}

start_puppet_agent() {
    if is_true "$START" ; then
        start-stop-daemon --start --quiet --pidfile $PIDFILE \
            --startas $DAEMON -- $NAME $DAEMON_OPTS
    else
        echo ""
        echo "puppet not configured to start, please edit /etc/default/puppet to enable"
    fi
}

stop_puppet_agent() {
        start-stop-daemon --stop --quiet --oknodo --pidfile $PIDFILE
}

status_puppet_agent() {
        status_of_proc -p "${PIDFILE}" "${DAEMON}" "${NAME}"
}

case "$1" in
    start)
        log_begin_msg "Starting $DESC"
        start_puppet_agent
        log_end_msg $?
        ;;
    stop)
        log_begin_msg "Stopping $DESC"
        stop_puppet_agent
        log_end_msg $?
        ;;
    reload)
        log_begin_msg "Reloading $DESC"
        reload_puppet_agent
        log_end_msg $?
        ;;
    status)
        status_puppet_agent
        ;;
    restart|force-reload)
        log_begin_msg "Restarting $DESC"
        stop_puppet_agent
        sleep 1
        start_puppet_agent
        log_end_msg $?
        ;;
    *)
        echo "Usage: $0 {start|stop|status|restart|force-reload|reload}" >&2
        exit 1
        ;;
esac

Change the permissions on the script like so:

sudo chmod 0755 /etc/init.d/puppet

Puppet by default is not configured to start, please edit /etc/default/puppet as root to enable

START=yes

Optionally,

DAEMON_OPT=" --verbose --debug"

Start on the command-line:

/etc/init.d/puppet start

To monitor the daemon

tail -f /var/log/syslog

monitor for messages about certificate request and such as action may need to be taken on your part.

Install Puppet OpenStack Provisioner

I found these components are not ready for prime time.

Install node_openstack puppet module from source using these commands:

cd ~
git clone https://github.com/puppetlabs/puppetlabs-node_openstack.git node_openstack
cd ~/node_openstack
puppet module build .
sudo -i
puppet module install /home/puppet/node_openstack/pkg/puppetlabs-node_openstack-*.tar.gz

Note, the last command assumes you haven't ran a build before, and is installinga single buld. You'll need to replace the * with the version number of the build to install.

Install cloud_provisioner puppet module dependency from source using these commands:

cd ~
git clone https://github.com/puppetlabs/puppetlabs-cloud_provisioner.git cloud_provisioner
cd ~/cloud_provisioner

Go here and note the latest module release in puppet forge:

http://forge.puppetlabs.com/puppetlabs/cloud_provisioner

See if the tag is available, and select the closest:

git tag -l

and check out that tagged release like so:

git checkout -b 1.0.5 1.0.5

Then:

puppet module build .
sudo -i
puppet module install /home/puppet/cloud_provisioner/pkg/puppetlabs-cloud_provisioner-*.tar.gz

Note, the last command assumes you haven't ran a build before, and is installinga single buld. You'll need to replace the * with the version number of the build to install.

First thing you'll notice is puppet help is broke.

Using Git to manage Puppet Master

Install and initial setup

Create a git repo to store PuppetMaster configutation files by setting up a git server:

sudo -i
apt-get update && apt-get install git-core
adduser git
mkdir /home/git/.ssh

Copy your ssh public key to /home/git/.ssh/authorized_keys on the git repo server.

chown -R git:git /homr/git/.ssh
chmod 700 !#
chmod 600 /home/git/.ssh/*

Test via

ssh git@localhost

Login in via git user.

Create the repo

Create Puppetmaster repo in this case example_puppetmaster:

mkdir example_puppetmaster.git
cd !$
git --bare init

To turn the /etc/puppet directory on the Puppetmaster into a Git repository, run the following commands:

cd /etc/puppet
sudo -i
git init
git add manifests/ modules/ puppet.conf
git commit -m "initial commit"

Add the remote repo via

git remote add origin git@${SERVER_FDQN}:example_pup[puppetmaster.git

replacing ${SERVER_FDQN} with the fully qualified domain name of the git repo server.

git push -u origin master
git status

Doing your development work

To do your development work:

mkdir ~/Development/workspace
cd ~/Development/workspace

or wherever.

Then clone:

cd ~/Development/workspace
git clone  git@${SERVER_FDQN}:example_puppetmaster.git

The git repo example_puppetmaster makes use of submodules for its dependencies placed in /etc/puppet/modules. Just read through .gitmodules at the root of the project to see what will be pulled down.

To pull the submodules do the following

cd example_puppetmaster
git submodule init
git submodule update

Create a local branch so all your edits can be later folded into one commit:

git checkout -b edits

Push to remote repository, once your edits to the "edits" branch is complete:

git push -u origin edits

Then on puppet master pull from the branch:

git checkout -b origin/edits

To get the updates

git pull origin edits

To merge your branch with master, create a merge of your edit branch locally, push the branch you merged to probably master to git. Git will now contain the merge. Then delete your local and remote copy of the edit branch. (Need to iterate through these steps for documentation purposes.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment