This message was deleted.
# puppet
s
This message was deleted.
y
I see something in the lvm module
puppetlabs-lvm
<- this one
d
y
at least
grep
shows something
though.. I’m not sure there is a way to call it with
-a
option.. I guess it’s for mounting/umounting a swap device with known name
r
ja i think its only for createing swapfs or smoething https://github.com/puppetlabs/puppetlabs-lvm/search?q=swap
i think i will go with:
Copy code
exec { 'Disable SWAP':
    command => '/sbin/swapoff -a',
    path    => $facts['path'],
    onlyif  => 'test $(swapon -s | wc -c) -gt 0',
  }
swapon -s shows output if there is swap, so if wc count is greater than 0 i need to swapoff thonk
or this 🤔
Copy code
onlyif  => 'swap' in $facts['memory'].keys,
s
Of course, you always want to avoid exec if you can.... but, if you do go for exec, I wonder if
awk '/SwapTotal/ {print $2}' </proc/memory
might not be more efficient.
r
you mean of this is >0? thonk
Copy code
awk '/SwapTotal/ {print $2}' /proc/meminfo
s
Yep
y
onlyif is executed on an agent so you cannot use puppet dsl there (i.e. cannot check if swap is in facts)
awk can compare numbers for you too :) though I’m not sure about exit code
b
Copy code
systemctl mask swap.target
perhaps? That'd require a reboot but would kill off all swap.
That won't prevent a "swapon -a" if someone does it from the command line, though.