Ask Your Question
0

how to source a file for exec when using puppet

asked 2015-11-24 01:13:58 -0500

Rahul gravatar image

Hi,

I have to execute a script using puppet which requires few variables to be sourced before its executed. I am using exec to execute the script and my code looks like:

exec { 'my_task':
    command => 'source /root/creds; /bin/task do-something',
}

However, it gives me an error as "failed: 'source /root/creds; /bin/task do-something' is not qualified and no path was specified. Please qualify the command or specify a path."

I am unable to figure out what path I should put for source as I couldn't find it using "which source". Can someone please help me out in figuring what else I can use to achieve the same.

Thanks.

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
0

answered 2015-11-24 17:21:48 -0500

Rahul gravatar image

updated 2015-11-24 17:22:37 -0500

I got an answer by following this awesome link: https://ask.puppetlabs.com/question/2...

In a nutshell, I need to modify it as:

exec { 'my_task':
  command => "/bin/bash -c 'source /root/creds; /bin/task do-something;'",
}
edit flag offensive delete link more
0

answered 2015-11-24 16:31:02 -0500

lavaman gravatar image

source is a shell built-in. It is not a tool that exists on your filesystem. You'll need to write a script that does these commands and use exec to run that.

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: 2015-11-24 01:13:58 -0500

Seen: 1,437 times

Last updated: Nov 24 '15