Re: [Puppet Users] Create variable as result of command execution

2014-03-20 Thread Roman Alekseev
Thank you!

This is also working:

/usr/sbin/nginx -V 2>&1  | /bin/grep -oP "http-proxy-temp-path=.*?\s" | 
/usr/bin/awk -F\'=\' {\'print $2\'}

среда, 19 марта 2014 г., 17:31:45 UTC+4 пользователь jcbollinger написал:
>
>
>
> On Wednesday, March 19, 2014 4:03:26 AM UTC-5, Roman Alekseev wrote:
>>
>> Hi,
>>
>> I created fact but it doesn't work. What did I make wrong?
>>
>>
>>
>>
>>
>>
>>
>> *# nginx_arg.rbFacter.add("nginx_arg") do  setcode do
>> Facter::Util::Resolution.exec("/usr/sbin/nginx -V 2> /etc/puppet/nginx.args 
>> | /bin/cat /etc/puppet/nginx.args | /usr/bin/awk 
>> -F'--http-proxy-temp-path=' {'print $2'} | /usr/bin/awk {'print $1'}  | 
>> /bin/grep '\/'")  endend*
>>
>>
>
> There are a couple of weird things about that, but before that:
>
>- What does "doesn't work" mean, specifically?
>- Where is the file located on the master?
>- Do you have pluginsync enabled on the agents?
>- Is the fact value output by "facter -p" on agent nodes that have 
>synced the fact?
>
> With respect to the command itself,
>
>- which output stream from /usr/sbin/nginx are you trying to use?  
>(You are using stderr (via a temp file), but you are also piping stdout 
> and 
>ignoring it.)
>- the unquoted curly braces in the command will be parsed by the 
>shell, not passed to awk.
>- Setting awk's field separator to '--http-proxy-temp-path=' will 
>probably not do anything sensible if there are other options listed after 
>than one in nginx's output.
>- If you need a temp file, you should put it in /tmp or /var/tmp and 
>give it an unpredictable name.  But you don't need one for what it looks 
>like you're trying to do.
>
> Were I writing a command to do what I *think* yours is trying to do, it 
> would look something like this:
>
> Facter::Util::Resolution.exec(
>   "/usr/sbin/nginx -V 2>&1 1>/dev/null | /bin/sed -n 
> 's,.*--http-proxy-temp-path=\(/\S\+\).*,\1,p'"
> )
>
> That pipes the stderr stream of the nginx command into sed, discarding the 
> stdout.  Sed then filters out everything except any strings of 
> non-whitespace beginning with a slash character (/) and directly following 
> the string "--http-proxy-temp-path=".  The output does not include the 
> "--http-proxy-temp-path=".  If you need to allow for whitespace either 
> before or after the '=' character then the pattern can be adjusted to 
> achieve that.
>
>
> John
>
>

-- 
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 puppet-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/04d6b5ad-2c4b-4166-bebb-a2044fe85c4f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Puppet Users] Create variable as result of command execution

2014-03-19 Thread jcbollinger


On Wednesday, March 19, 2014 4:03:26 AM UTC-5, Roman Alekseev wrote:
>
> Hi,
>
> I created fact but it doesn't work. What did I make wrong?
>
>
>
>
>
>
>
> *# nginx_arg.rbFacter.add("nginx_arg") do  setcode do
> Facter::Util::Resolution.exec("/usr/sbin/nginx -V 2> /etc/puppet/nginx.args 
> | /bin/cat /etc/puppet/nginx.args | /usr/bin/awk 
> -F'--http-proxy-temp-path=' {'print $2'} | /usr/bin/awk {'print $1'}  | 
> /bin/grep '\/'")  endend*
>
>

There are a couple of weird things about that, but before that:

   - What does "doesn't work" mean, specifically?
   - Where is the file located on the master?
   - Do you have pluginsync enabled on the agents?
   - Is the fact value output by "facter -p" on agent nodes that have 
   synced the fact?

With respect to the command itself,

   - which output stream from /usr/sbin/nginx are you trying to use?  (You 
   are using stderr (via a temp file), but you are also piping stdout and 
   ignoring it.)
   - the unquoted curly braces in the command will be parsed by the shell, 
   not passed to awk.
   - Setting awk's field separator to '--http-proxy-temp-path=' will 
   probably not do anything sensible if there are other options listed after 
   than one in nginx's output.
   - If you need a temp file, you should put it in /tmp or /var/tmp and 
   give it an unpredictable name.  But you don't need one for what it looks 
   like you're trying to do.

Were I writing a command to do what I *think* yours is trying to do, it 
would look something like this:

Facter::Util::Resolution.exec(
  "/usr/sbin/nginx -V 2>&1 1>/dev/null | /bin/sed -n 
's,.*--http-proxy-temp-path=\(/\S\+\).*,\1,p'"
)

That pipes the stderr stream of the nginx command into sed, discarding the 
stdout.  Sed then filters out everything except any strings of 
non-whitespace beginning with a slash character (/) and directly following 
the string "--http-proxy-temp-path=".  The output does not include the 
"--http-proxy-temp-path=".  If you need to allow for whitespace either 
before or after the '=' character then the pattern can be adjusted to 
achieve that.


John

-- 
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 puppet-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/51f8f45b-e739-4f24-8f84-2d8d6489c17c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Puppet Users] Create variable as result of command execution

2014-03-19 Thread Roman Alekseev
Hi,

I created fact but it doesn't work. What did I make wrong?







*# nginx_arg.rbFacter.add("nginx_arg") do  setcode do
Facter::Util::Resolution.exec("/usr/sbin/nginx -V 2> /etc/puppet/nginx.args 
| /bin/cat /etc/puppet/nginx.args | /usr/bin/awk 
-F'--http-proxy-temp-path=' {'print $2'} | /usr/bin/awk {'print $1'}  | 
/bin/grep '\/'")  endend*

Thanks.

среда, 19 марта 2014 г., 12:13:16 UTC+4 пользователь Jose Luis Ledesma 
написал:
>
> Hi,
>
>   I think that the best way is a custom fact. 
>
> Regards
> El 19/03/2014 08:27, "Roman Alekseev" > 
> escribió:
>
>> Hello,
>>
>> What is the best way in puppet to create a variable as result of command 
>> below:
>> *$nginx_dir=`/usr/sbin/nginx -V 2> /etc/puppet/nginx.args | /bin/cat 
>> /etc/puppet/nginx.args | /usr/bin/awk -F'--http-proxy-temp-path=' {'print 
>> $2'} | /usr/bin/awk {'print $1'}  | /bin/grep '\/'`*
>>
>> Any advices will be appreciated.
>>
>> -- 
>> 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 puppet-users...@googlegroups.com .
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/puppet-users/7211e50a-32db-4c68-953e-164edecc1932%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 puppet-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/d4c7cbba-4b5a-4f60-9fba-3c0eba2bd847%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Puppet Users] Create variable as result of command execution

2014-03-19 Thread José Luis Ledesma
Hi,

  I think that the best way is a custom fact.

Regards
El 19/03/2014 08:27, "Roman Alekseev"  escribió:

> Hello,
>
> What is the best way in puppet to create a variable as result of command
> below:
> *$nginx_dir=`/usr/sbin/nginx -V 2> /etc/puppet/nginx.args | /bin/cat
> /etc/puppet/nginx.args | /usr/bin/awk -F'--http-proxy-temp-path=' {'print
> $2'} | /usr/bin/awk {'print $1'}  | /bin/grep '\/'`*
>
> Any advices will be appreciated.
>
> --
> 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 puppet-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/puppet-users/7211e50a-32db-4c68-953e-164edecc1932%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 puppet-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/CAF_B3dfwU9t0iC9_zVy%2B6xTZLviqXCyHXHp%3D%2BW-Q0vWxzzU%2BuQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


[Puppet Users] Create variable as result of command execution

2014-03-19 Thread Roman Alekseev
Hello,

What is the best way in puppet to create a variable as result of command 
below:
*$nginx_dir=`/usr/sbin/nginx -V 2> /etc/puppet/nginx.args | /bin/cat 
/etc/puppet/nginx.args | /usr/bin/awk -F'--http-proxy-temp-path=' {'print 
$2'} | /usr/bin/awk {'print $1'}  | /bin/grep '\/'`*

Any advices will be appreciated.

-- 
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 puppet-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/7211e50a-32db-4c68-953e-164edecc1932%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.