Ask Your Question

how do I do this myenv=`grep hcsEnvironment /etc/| awk -F\' '{print $2}'`

asked 2014-12-17 19:35:04 -0600

davidallanwright gravatar image

updated 2014-12-17 21:19:52 -0600

GregLarkin gravatar image


How do I set a variable to a field from a line in /etc/


In bash I could do this.

myenv=`grep hcsEnvironment /etc/| awk -F\' '{print $2}'`

I need a local variable that is the output of an exec or I have seen some augeas examples.

$myenv = exec { 'getenv':  command => "grep hcsEnvironment /etc/| awk -F\' '{print $2}'", }
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2014-12-17 21:23:54 -0600

GregLarkin gravatar image

This looks like a good problem to solve with an external fact:

You can create a script (like above) to write a fact file that resides on your agent node. That fact will be sent to the master during the agent run, and its value can be used elsewhere in your Puppet code. For instance, if your script creates an external fact named hcsenv, you can refer to the value of that fact in your Puppet code with the syntax ${::hcsenv}.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools


Asked: 2014-12-17 19:35:04 -0600

Seen: 59 times

Last updated: Dec 17 '14