Ask Your Question

how to source a file for exec when using puppet

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

Rahul gravatar image


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.


edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted

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

Rahul gravatar image

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

I got an answer by following this awesome link:

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

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

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


Asked: 2015-11-24 01:13:58 -0600

Seen: 2,446 times

Last updated: Nov 24 '15