Hi,

you want to find out whether a directory exists on a node.
This has to be done on the node by using custom facts.

When the master compiles the catalog you want to switch processing of Puppet 
code depending on the fact result.

This means:

you have to write a custom fact which best distributed to the nodes.
(https://docs.puppetlabs.com/facter/2.1/custom_facts.html)
This fact will be available as variable on the master during catalog compile.

You then want to check for the fact and split stuff.



Besides this: you want to tell your node how it should look like. You do not 
want your node to make decisions what he wants.

hth,

Martin


On 20 Aug 2014, at 13:52, Sneha More <[email protected]> wrote:

> Jorge, :
> the other way you specified does the same as:
> File { " /etc/puppet/test":
> ensure => "directory",
> }
> This will also create a directory if it does not exist.
> 
> Satish:
> There must be some reason for which you are checking presence of directory.
> So you can add unless condition with exec resource as specified by Jorge to 
> execute something if the the directory is present or not
> 
> Thanks and Regards,
> Sneha More
> 
> 
> On Wednesday, August 20, 2014 1:19:55 AM UTC+5:30, Flamarion Jorge wrote:
> Ok. I'm sorry.  Here other way.
> 
> exec { "create dir":
> ....
> command => 'mkdir -p /etc/puppet/test'
> unless => 'test -d /etc/puppet/test'
> ......
> }
> 
> Now your directory will be created if it doesn't exist.
> 
> Flamarion Jorge
> Sent from my mobile
> 
> Em 19/08/2014 15:02, "Yanis Guenane" <[email protected]> escreveu:
> Jorge,
> 
> This is wrong. unless is not a parameter of the file resource
> 
> https://docs.puppetlabs.com/references/latest/type.html#file
> 
> unless applies only to the exec resource.
> 
> --
> Yanis Guenane
> 
> On 08/18/2014 05:21 PM, Flamarion Jorge wrote:
>> File { " /etc/puppet/test":
>> ensure => "directory",
>> unless => 'test -d /etc/puppet/test'
>> }
>> 
>> Flamarion Jorge
>> Sent from my mobile
>> Em 18/08/2014 09:05, "Satish Katuru" <[email protected]> escreveu:
>> 
>> Hi ,
>> 
>> I wanted to find out whether the directory exists or not in the machine.How
>> can I do it?
>> 
>> if I do it as below it will create a directory:
>> 
>> File { " /etc/puppet/test":
>> ensure => "directory",
>> 
>> }
>> 
>> 
>> 
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Puppet Users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to [email protected].
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/puppet-users/6f8d03fb-8d97-4832-a3b7-70868132c451%40googlegroups.com
>> <https://groups.google.com/d/msgid/puppet-users/6f8d03fb-8d97-4832-a3b7-70868132c451%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>> 
> 
> --
> You received this message because you are subscribed to the Google Groups 
> "Puppet Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to [email protected].
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/puppet-users/53F3912C.50504%40gmail.com.
> For more options, visit https://groups.google.com/d/optout.
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Puppet Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to [email protected].
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/puppet-users/fe796814-04d6-496f-adb4-d6bc66691317%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/C76E369F-1628-40C3-84EB-182EB49C56FB%40gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to