I want to check "if dir exists" condition with puppet how it done here How to do a file/dir exists conditional in Puppet? but then if i write
exec { 'check_presence':
command => "true",
path => ["/usr/bin","/usr/sbin", "/bin"],
onlyif => "test -d /test"
}
file { '/test/123':
ensure => directory,
mode => '0644',
require => Exec['check_presence']
}
from exec
i get alwyas true
, and puppet always try to create /test/123
Debug: Exec[check_presence](provider=posix): Executing check 'test -e /test'
Debug: Executing 'test -e /test'
Error: Cannot create /test/123; parent directory /test does not exist
Error: /Stage[main]/tst::test/File[/test]/ensure: change from absent to directory failed: Cannot create /test/123; parent directory /test does not exist
Why he do it?! And how i must check parent directory exists?!
My puppet is 3.8
UPD I don't want to create /test
! I want to create /test/123
ONLY if /test already exists!