Category Archives: ubuntu

Configure Ubuntu and CentOS Webserver using Puppet

As I’m playing with the EC2 Puppet setup, here’s my simple web server in CentOS and Ubuntu puppet recipe. (need to edit more the Ubuntu installed packages ex. add php_mysql etc)

Tested in CentOS 5.0 and Ubuntu 8.04 AMI by Eric Hammond found at http://alestic.com.

class apache {
    # CentOS v.5 only
    case  $operatingsystem { 
     "CentOS":  { 
        $wantedpackages = [ "httpd","php","php-mysql","php-mcrypt","php-mhash","php-mbstring" ]
        package { $wantedpackages: 
                  ensure => installed 
        }
        service { "httpd":
                ensure => running,
                hasstatus => true,
                hasrestart => true,
                require => Package["httpd"],
                restart => true;
        }
      } 

    "Debian": { 
        # assume Debian base..
        $wantedpackages = [ "apache2" ]
        package { $wantedpackages: 
                  ensure => installed 
        }

        service { "apache2":
                hasstatus => true,
                hasrestart => true,
                ensure => running,
                require => Package["apache2"]
        }
    } 
  } # end case
} 

Obviously a web node will have the config:

node webA.sample.org {
   include apache 
}

Running it on EC2, pass a user-data script to the AMI during launch. A script that will set the hostname, adds default puppet master for the current instance and installs the puppetd. The puppetd program will then connect to the puppet server, and get all it’s needed configurations.

🙂 Thanks to Reductive labs.

Running Rails in my Ubuntu

I just have some little experiment with Rails in the past 2days.
Reading and testing from these words I was able to get “interesting”.
Here it goes.

I get ready to install via apt-get here:

prompt$ sudo apt-get install ruby irb
prompt$ sudo apt-get install rails mongrel mongrel-doc
prompt$ sudo apt-get install mysql-server-5.0 mysql-client-5.0

prompt$ rails rails_pet

prompt$ cd rails_pets

prompt$ ruby script/generate model pet

Login to Mysql:

mysql> create database rails_pets_development;

Edit database.yml

prompt$ vi config/database.yml
-----
development:
adapter: mysql
database: rails_pets_development
username: root
password: db_password_secret
socket: /var/run/mysqld/mysqld.sock
----

prompt$ rake db:migrate
== CreatePets: migrating ======================================================
-- create_table(:pets)
-> 0.0795s
== CreatePets: migrated (0.0797s) =============================================

$prompt ruby script/generate controller pet

prompt$ ruby script/generate scaffold Pets

Launch the server:

prompt$ ruby script/server

I point my browser to: http://localhost:3000/

Then later to http://localhost:3000/pets/

So far so good, but little tricky. I need to go around with all these stuff in the next few days. I need more ways to motivate myself learning Rails..maybe a yoga or a night workout will suffice. 🙂