Pages

Showing posts with label linux. Show all posts
Showing posts with label linux. Show all posts

Monday, August 5, 2013

puppet augeas

Augeas controls configuration files composed of key/value pairs. It might seem weird and hard to use at the beginning, but it's sure easier and friendlier then grep and sed.
Controlling the hostname with augeas and restarting rsyslog service:

class hostname ($hostname){
  augeas{ 'sysconf-hostname':
    context     => '/files/etc/sysconfig/network',
    changes     => ["set HOSTNAME $hostname"],
    notify      => Service['rsyslog'],
  }
} 

augtool is a very nice tool which help you figure out which files and options are under augeas control.

Tuesday, March 12, 2013

setting LANG environment variable

Setting LANG environment variable in linux sounds as an easy task:
    export LANG=en_US.utf8
But when attempting to make this change permanent, it is no longer an easy task. Exporting this in /etc/profile, ~/.bashrc or ~/.bash_profile does not have the desired effect. 
After doing a fair amount of googling I found out the solution for this: create a file called ~/.i18n which contains you LANG setting:
    cat ~/.i18n
   LANG=en_US.utf8
This does the trick.

Tuesday, September 13, 2011

add disk to lvm


Suppose the Disk is /dev/sdb, the second scsi disk,

  fdisk /dev/sdb
  create as many partitions as you need using command n
  Label them with command t as 8e for making it Linux LVM
  Write and Exit with the command w.

Format the partitions you require using mkfs command

  mkfs -t ext3 -c /dev/sdb1

LVM commands

  pvcreate /dev/sdb1
  vgextend VolGroup00 /dev/sdb1
  lvextend -L 15G /dev/VolGroup00/LogVol00 ;for extending LogVol to 15GB
  lvextend -L+1G /dev/VolGroup00/LogVol00 ;for adding one more GB to Logical Volume LogVol01
  resize2fs /dev/VolGroup00/LogVol00 ;for resizing the Logical Volumes

To increase the storage capacity while keeping the server online, add the disk and then rescan scsi:  

echo "- - -" > /sys/class/scsi_host/host0/scan

Monday, September 12, 2011

control cron from puppet

There is a nice way to control crontab from puppet. An example:


        cron { do_smt:
                command  => "/root/do_smt.sh",
                user     => root,
                hour     => 17,
                minute   => 30,
                monthday => '1-7',
                weekday  => 'Sat',
                month    => [1, 3, 5, 7, 9, 11],
        }

This would lead to a cron entry like this:

# HEADER: This file was autogenerated at Thu Sep 01 20:31:35 +0900 2011 by puppet.
# HEADER: While it can still be managed manually, it is definitely not recommended.
# HEADER: Note particularly that the comments starting with 'Puppet Name' should
# HEADER: not be deleted, as doing so could cause duplicate cron jobs.
# Puppet Name: do_smt
30 17 1-7 1,3,5,7,9,11 6 /root/do_smt.sh

For a complete reference to all the puppet cron type's attributes, check the puppet documentation site.

Monday, March 7, 2011

centos upgrade issue

When trying to upgrade from CentOS 4.4 to 4.8 I had this error:

159 Header V3 DSA signature: BAD, key ID

I seems the rpm database was broken. To fix it, do:

mv /var/lib/rpm/Pubkeys /var/lib/rpm/Pubkeys.old
mv /usr/lib/rpmdb/i386-redhat-linux/CentOS/Pubkeys /usr/lib/rpmdb/i386-redhat-linux/CentOS/Pubkeys.old

rpm --rebuilddb -vv

This did it an I was able to make my upgrade.

Sunday, February 20, 2011

sudoers

If you want to allow a user to run a command as another user, /etc/sudoers file should be used. Usually it's necessary for a user to run a command as root, equivalent to the Windows "Run as administrator". That is quite straight forward. Add in /etc/sudoers:

username ALL=NOPASSWD: /usr/sbin/ntpdate

Now this will be allowed:

username@laptop:~$ sudo /usr/sbin/ntpdate

There is another situation: when you need user1 to run a command as user2. For this you add to /etc/sudoers:

user1 ALL=(user2) NOPASSWD: /home/user1/bin/start_daemon

In this case user1 will be able to do:

user1@laptop:~$ sudo -u user1  /home/user1/bin/start_daemon

Monday, January 31, 2011

git hooks

git comes by default with a number of hooks. Hooks are little scripts you can place in $GIT_DIR/hooks directory to trigger action at certain points. When git init is run, a handful of example hooks are copied into the hooks directory of the new repository, but by default they are all disabled.
It's good to know that each hook that has execution rights, will indeed get executed. If you have an executable hook by mistake you can end up with this error:

lvarga@lvarga-desktop:~$ git push origin master
Counting objects: 7, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (4/4), done.
Writing objects: 100% (4/4), 455 bytes, done.
Total 4 (delta 1), reused 0 (delta 0)
*** Project description file hasn't been set
error: hooks/update exited with error code 1
error: hook declined to update refs/heads/master
! [remote rejected] master -> master (hook declined)
error: failed to push some refs to 'ssh://gitserver/var/www/git/repo.git'

This happened after I changed the permissions of the hooks. I was only using the post-receive hook, all the others were default. I gave all of them execution rights and then I had quite a hard time understanding why some empty hooks were executed.
Then googled a bit and found that the permissions are the problem. It went away after I took out the execution right of all the hooks I didn't use

Tuesday, January 25, 2011

linux restricted user

I was using scponly for creating restricted users, but I found that setup quite complicated to use, so I was searching for an alternative. I found rssh, which was much simpler:

[root@zion ~]# yum install rssh 
[root@zion ~]# adduser -g rsshusers myuser

Edit /etc/passwd:

myuser:x:513:109::/home/myuser:/usr/bin/rssh

For configuring rssh, see /etc/rssh.conf. You can:


allowscp
#allowsftp
#allowcvs
#allowrdist
#allowrsync

Also, you can configure chroot for the restricted user if you want. So, it's quite simple to setup, simple to use.

Saturday, January 8, 2011

Ubuntu can be negative!


Negative
The Negative plugin provides immediate, high-contrast windows for the visually impaired by inverting the colors of individual windows, or all windows at once.

    * To enable or disable Negative on the focused window, press Super+n.
    * To enable or disable Negative on the screen, press Super+m.


Of course this happened by mistake and I had to search for a way to revert it. Great things come out of mistakes.

Monday, January 3, 2011

puppet addon for vim

There is an addon to puppet which enalbes syntax highlighting of the *.pp files. To install this addon on ubuntu:
sudo apt-get install vim-puppet
The addon is installed, but you still need to enable it. For this you use the vim addon manager:
vim-addons install puppet