0

I have below linux script

cre_disk=$(ls /dev/sd[b-z])
for disk in $cre_isk
do 
pvcreate $i
done

My understanding from the above code is, it is checking the sdb,sdc..sdz disk file. if it exist, then do physical volume creation.

what my requirement is, need to convert the above linux into puppet(lvm creation). I know the command for physical volume creation

physical volume{'/dev/sdb':
ensure => 'present'
}

I am not sure how to check the physical disk (cre_disk=$(ls /dev/sd[b-z])). is there any resource available or puppet would take care without any resource.

NOTE:I have posted this same question in different format in previous question post. Please ignore the topic, the topic name is "check physical disk directory"

1
  • 1
    Olive, you can edit your questions. Please don't post the same stuff twice and edit instead.
    – Sven
    Nov 19, 2014 at 17:39

2 Answers 2

2

Facter's variable partitions:

[vagrant@localhost ~]$ facter partitions
{"sda1"=>{"uuid"=>"X", "size"=>"1024000", "mount"=>"/boot"}, "sda2"=>{"size"=>"Y"}}

could be used within an if statement as follows:

if $partitions !~ /sd[b-z]1/ {
  notify{"partition does not exist":}
}

Outcome

[vagrant@localhost ~]$ sudo puppet agent -t
Info: Retrieving pluginfacts
Info: Retrieving plugin
Info: Caching catalog for localhost.local
Info: Applying configuration version 'X'
Notice: drive does not exist
Notice: /Stage[main]/Main/Node[default]/Notify[partition does not exist]/message: defined 'message' as 'drive does not exist'
Notice: Finished catalog run in 0.07 seconds
1

You have multiple options.

  • It's absolutely possible to have puppet run a script on the target machine. Depending on what the script does, you want to prevent it from running more than once though. This would be such a case.

  • You can add facter modules on the target machines that would export informations about block devices as facts. https://github.com/CygnusNetworks/cygnus-puppet-disk-facter would be such a module.

You must log in to answer this question.

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