Ask Your Question

Read the string from the file using puppet

asked 2016-11-02 18:55:55 -0500

ggun gravatar image

updated 2016-11-09 22:45:44 -0500

ramindk gravatar image

Hi , I just have a question. I need to read a variable value from the file using puppet. I wrote below line of code in a puppet

$variable = inline_template("<% '/bin/sed -n 's/^ *profileName *= *//p' /opt/IBM/ResponseFiles/DMGR_Creation.txt' %>")

The file DMGR_Creation.txt contains a line as profileName=ABC I need to read the value ABC . When I execute the above sed command it runs without any issue but when i run it in puppet it throws error as below Error::Syntax error at 's/^ *profileName *= *//p' in the file when I run puppet.

I tried

$variable = inline_template("<% '/bin/awk '/^profileName/{print $nf}' /opt/IBM/ResponseFiles/DMGR_Creation.txt' %>")

but I again get error for curly brackets.

Can any one please help in resolving my issue here ?


edit retag flag offensive close merge delete


template generation and calls to the generate() method run on the host that compiles the catalog. In a master/agent setup, that is the master. In masterless puppet, everything occurs on the host ( same as running puppet apply)

DarylW gravatar imageDarylW ( 2016-11-03 09:37:01 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2016-11-03 09:11:27 -0500

Kevin T gravatar image

Add a Custom fact that reads this from the file you need and presents it as a fact.

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

1 follower


Asked: 2016-11-02 18:55:28 -0500

Seen: 56 times

Last updated: Nov 03 '16