-2

I am newbie to puppet, I have code like below in unix

log_exts=$(vgdisplay /dev/cassandra|grep Free|awk '{print $5}')

if lvcreate -n lv_cas -l ${log_exts} /dev/cassandra
then
mkfs -v -t ext4 /dev/cassandra/lv_cas
logit "Create LV file system"
fi

I want to convert this into puppet.

I should not use exec puppet command. so how can I grep for FREE and print the fifth column, then assign logical volume size.

Please help me

2 Answers 2

1

For this specific thing, you can use -l 100%FREE as a size value to assign all free space with lvcreate.

On a more fundamental level, if you don't want to use exec to get the data, you will have to extend facter to get you the data you need.

https://docs.puppetlabs.com/facter/2.3/custom_facts.html#adding-custom-facts-to-facter

4
  • I do not get what you mean by -l 100%FREE. can you please explain
    – Olive
    Nov 14, 2014 at 3:52
  • Read man lvcreate. You don't need to get the number of free extents in your case as lvcreate -n lv_cas -l 100%FREE /dev/cassandra will automatically assign all free space to the new volume.
    – Sven
    Nov 14, 2014 at 10:06
  • I tried below two method $temp= lvcreate -n lv_cas -l 100%FREE /dev/cassandra logical_volume {'lv_cas': ensure => present, path => '/dev/cassandra' size=>$temp require =>Volume_group['vg_cas'] } Even I tried like below size => 'lvcreate -n lv_cas -l 100%FREE' Still I am getting error. when i run lvcreate -n lv_cas -l 100%FREE /dev/cassandra in promet its working only when I assign to variable it is not working
    – Olive
    Nov 23, 2014 at 17:57
  • Let me repeat myself: You should really reconsider your approach. From your question history, I get the strong impression that you neither understand basic Linux system administration nor Puppet and you are just firing random shots in the dark and hope it to work. To successfully use a tool like Puppet, it is absolutely necessary to fully understand what you are trying to do manually, without automation. Understanding how Puppet works is the next step and trying to combine the two is just the last step (which you try to do first).
    – Sven
    Nov 23, 2014 at 17:59
0

To manage your logical volumes with Puppet, use an appropriate module.

You may not be able to replicate your current logic 100%. Puppet's paradigms differ from those of shell scripts. Your mileage is usually better if you adjust your workflows to this new premise.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .