Hi,

this is how I enable/disable swap. I tested it on RHEL5 and RHEL6, but it 
should work on all linuxes I guess.

swap { "swap": }
swap { "swap": ensure => absent }

define swap($ensure = present) {
  if $ensure == present {
    exec { "swap-on":
      command => "swapon -a",
      unless => "grep partition /proc/swaps"
    }
  } else {
    exec { "swap-off":
      command => "swapoff -a",
      onlyif => "grep partition /proc/swaps"
    }
  }
}

Cheers,
Jens


Am 05.11.11 02:08, schrieb Steven VanDevender:
> Douglas Garstang writes:
>  > All,
>  > 
>  > Trying to mount swap. Using:
>  > 
>  > mount {
>  >         'swap':
>  >             device => '/dev/xvdq1',
>  >             atboot => true,
>  >             ensure => mounted,
>  >             fstype => 'swap',
>  >             options => 'defaults';
>  > }
>  > 
>  > This is giving me:
>  > 
>  > (/Stage[main]/Oracle::Common/Mount[swap]) Could not evaluate:
>  > Execution of '/bin/mount -o defaults swap' returned 32: mount: mount
>  > point swap does not exist
>  > 
>  > What do I have wrong?
> 
> You can't activate swap using mount(8), and hence the Puppet mount
> provider is not going to cope properly with it.  It typically has to be
> activated with swapon(8) in Linux.  Yes, the swap entry is in
> /etc/fstab, but that doesn't mean it gets mounted like a filesystem.
> 


-- 
Jens Bräuer
Senior Systems Engineer
Dipl. Inf.
NumberFour AG
Schönhauser Allee 8
10119 Berlin
Germany
Mobile: +49 175 221 88 34
Phone: +49 30 40505411
Fax: +49 30 40505410
j...@numberfour.eu

numberfour.eu
facebook.com/NumberFour
twitter.com/numberfourag

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To post to this group, send email to puppet-users@googlegroups.com.
To unsubscribe from this group, send email to 
puppet-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/puppet-users?hl=en.

Reply via email to