Hi
Thanks for your response.
The first answer won't work for me as I want to be dynamic about it and
take in a variable of the full path so it could just as easily be 10
directories deep. I'm getting the value for home from a CLI rather than
hand crafting something static.

The significance of the %/* means take the variable's value and right strip
back to the last '/' character. So where I have /first/second/userdir
passed in in the variable $home,
I want to create only /first/second with the mkdir -p command.

Julia

On 14 August 2012 13:54, earthgecko <garypwil...@gmail.com> wrote:

>
>
> So as a variable I get passed in $home and it may be for example
>> /first/second/userdirectory where first and second may not exist.
>>
>> So I wanted to do a simple exec command which does the following if I
>> were to do it at the command line:
>>
>> mkdir -p ${home%/*}
>>
>> ...this would make /first/second and I can allow useradd create the
>> userdirectory.
>>
>> BUT....puppet doesn't like me passing that to command.
>>
>> exec { "$home.create":
>>       path      => '/bin:/usr/bin',
>>       command   => "mkdir -p '${home%/*}'",
>>     }
>>
>> I get Could not match %/*}\"
>>
>>
>>
> So firstly in the context of
>
> command   => "mkdir -p '${home%/*}'",
>
> Puppet will try and look up variable:
>
> home%/*
>
> Because it is ${ and double quoted, so puppet is trying to compile the
> command as it is ${ in a double quoted string which puppet understands as a
> variable.
>
> I do not understand the context of the % percent and * wildcard
> references.  But is $home was defined as '/first/second', then:
>
> command   => "mkdir -p ${home}",
>
> As for passing special characters, different blends of variables and
> special characters should always be tested.  Special characters should be
> passed via the exec command context if single quoted and no variables, not
> 100% certain, it always pays to test.
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Puppet Users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/puppet-users/-/4QCHahZc-MYJ.
>
> To post to this group, send email to puppet-users@googlegroups.com.
> To unsubscribe from this group, send email to
> puppet-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/puppet-users?hl=en.
>

-- 
This email and any files transmitted with it are confidential and intended 
solely for the use of the individual or entity to whom they are addressed. 
If you have received this email in error please notify the system manager. 
This message contains confidential information and is intended only for the 
individual named. If you are not the named addressee you should not 
disseminate, distribute or copy this e-mail.

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To post to this group, send email to puppet-users@googlegroups.com.
To unsubscribe from this group, send email to 
puppet-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/puppet-users?hl=en.

Reply via email to