Ask Your Question
0

Read the string from the file using puppet

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

ggun gravatar image

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

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 ?

Thanks

edit retag flag offensive close merge delete

Comments

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 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted
1

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

Kevin T gravatar image

https://docs.puppet.com/facter/latest...

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

Stats

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

Seen: 364 times

Last updated: Nov 03 '16