0
votes

I need to use Linux "set" command in Chef recipe, I tried it using "execute" resource, in-order to set positional parameters on the node server. It shows no error, after running the convergence 'chef-client'. But when I check it on the node, to echo out the value for the position variable (Ex: "echo $2"), there is no value displayed. How can I resolve it, is they any other process or I'm getting it wrong? Below are the exact lines in the recipe

execute "temp_password" do
  command "set `cat temppasswd.txt`"
end
1

1 Answers

1
votes

set is not a command, it's a shell built-in function. I think you are trying to say you want to set some environment variables for use later in the recipe based on the content of a file. Unfortunately this isn't how Unix works, setting an environment variable in a subprocess (bash) has no effect on its parent (chef-client). I also don't know what you mean by "positional parameters" in this context. If you can provide more details about your actual goal I can provide more help, but as written the best I can tell is that no part of your question is actually a thing.