Wednesday, July 24, 2013

do you remember what your user data was when you create this AWS EC2 instance? (try this command)

curl http://169.254.169.254/latest/user-data

install a puppet agent (client) on AWS CE2 CentOS

$ sudo yum install puppet
$ puppet --version
2.7.22

## make sure your puppet server should install puppet version higher than this. (it's 3.2.3 on my puppet server)

## check your host name as in the /etc/puppet/manifests/nodes.pp file to make sure what you want to include.

$ puppet agent --server=puppet.katdc.com --debug --test --waitforcert=60

## on your puppet server side, to certify this hist

$ puppet cert list --all

## if you see a host name, such as AAA not signed.

$ puppet cert sign AAA

## back to your puppet agent, it will keep going and install all the categories.

Tuesday, July 16, 2013

to set ssh authorized_keys on CentOS is different from Ubuntu on EC2

cd ~/.ssh
chmod og-rw authorized_keys
chmod a-x authorized_keys

chmod 700 ~/.ssh

## append your local ~/.ssh/id_rsa.pub content to remote site's authorized_keys

Monday, July 15, 2013

install puppet master on an EC2 CentOS instance.

## both hostnames on master and agent are matter, not IP address.
## agent should be able to resolve puppet master's IP address, but agent (client) is not.
## therefore, puppet agents could be not on Internet, but the puppet master is on Internet.

   55  rpm -ivh http://yum.puppetlabs.com/el/5/products/i386/puppetlabs-release-5-6.noarch.rpm
   56  rpm -Uvh http://download.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-7.noarch.rpm
   57  rpm -Uvh http://mirror01.idc.hinet.net/EPEL/6/x86_64/epel-release-6-8.noarch.rpm
   58  yum install puppet-server

   59  cd /etc/puppet/manifests
   60 vi site.pp

// add following lines

import "classes/*"
    node default {
        include sudo
}

   65  mkdir classes
   66  vi /etc/puppet/manifests/classes/sudo.pp

// add following lines

class sudo {
        file {
                "/etc/sudoers": owner => "root", group => "root", mode => 440,
        }
}

   68  service puppetmaster start
   69  chkconfig puppetmaster on

   72  puppetca --list

   77  vi /etc/puppet/autosign.conf

// add "*" in autosign.conf  if you don't want to bother with certification, use firewall to control your puppet client access permission.

Thursday, July 11, 2013

mount a new file system on CentOS for EC2

1. create a new volume on AWS EC2 first. (use standard for example)
2. then attach it to the instance you want to mount on. (as a device name for example /dev/sdf)
3. ssh your instance and try to mount it.

of course, change to root using $sudo -s

4. $fdisk /dev/sdf

if there is no any partition, use n to create a new one.
then use w to sync and quit

5. $/sbin/mkfs.ext4 -L /backup /dev/sdf1

to format the whole partition to ext 4 format.

6. $mkdir /your_mount_point

make a mount point

7. $mount /dev/sdf1 /your_mount_point

8. $df
Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/sda1              8256952   7359700    477824  94% /
none                    290848       116    290732   1% /dev
none                    325224         0    325224   0% /dev/shm
none                    325224        56    325168   1% /var/run
none                    325224         0    325224   0% /var/lock
none                    325224         0    325224   0% /lib/init/rw
/dev/sdf1             51605436    184136  48799896   1% /your_mount_point

9. to keep it auto mount when system boot

copy the following line in /etc/mtab

/dev/sdf1 /your_mount_point ext4 rw 0 0

to /etc/fstab

for example

proc                   /proc  proc  nodev,noexec,nosuid                      0  0  
LABEL=cloudimg-rootfs  /      ext3  defaults                                 0  0  
/dev/sdb /mnt auto defaults,nobootwait,comment=cloudconfig 0 0
/dev/sdf1 /your_mount_point ext4 rw 0 0