- From: Brad Knowles <
>
- To: "
" <
>
- Cc: Brad Knowles <
>
- Subject: [chef] Passing responses back to Chef?
- Date: Tue, 6 Aug 2013 13:16:26 -0500
Folks,
Okay, so I have to be missing something really basic and easy, only I can't
figure out what it is. I was hoping someone here might be able to clue me in.
We're using a modified version of the mysql cookbook, and trying to detect
which version of the MySQL Engine that the user wants to install, and turn
that into a full version string that could be passed to the package manager
via the package resource.
I know how to access the desired engine version (major.minor.patch), and I
figured out a way to determine what the full version string is of the package
that might match -- e.g., "5.1.70" might translate to
"5.1.70-0ubuntu0.10.04.1".
What I can't figure out is how to pass that full version string information
back to Chef. Setting a shell environment variable doesn't help, because the
environment of the parent process isn't affected by the child process(es), as
explained at <
http://docs.opscode.com/essentials_environment_variables.html>:
From a shell, the source command can be used to reload a given
initialization file; however, since child processes do not affect
their parent’s environment, using a script or execute resource to
run source from inside a recipe will have no effect on the
environment for the chef-client
It also doesn't help to put that information into a file that could be
"sourced" from Chef, because you'd have to go through a bash resource as a
child process, as explained at
<
http://docs.opscode.com/resource_execute.html>, because this would get done
as a child process:
Instead, use the script resource or one of the script-based resources
(bash, csh, perl, python, or ruby). For example:
bash "foo" do
code "source /tmp/foo.sh"
end
So, how else do you get a child process to pass information back to Chef in a
useful manner?
--
Brad Knowles
<
>
LinkedIn Profile: <
http://tinyurl.com/y8kpxu>
- [chef] Passing responses back to Chef?, Brad Knowles, 08/06/2013
Archive powered by MHonArc 2.6.16.