0
I'm trying to use Chef-solo to deploy some software inside a Vagrant VM, as well as be able to re-use the same recipes to deploy onto a Centos box running on EC2.
I'd prefer to generate the root MySQL password on the box rather than include it in the boot script. But how can I set a node value in Chef at runtime?
e.g. in the recipe below, the script buildInfo.php will write some JSON data into the file /etc/chef/serverInfo.json
which I would then like Chef to read and use.
execute 'build_info' do
cwd node[:source_folder] + "/tools"
command "php buildInfo.php /etc/chef/serverInfo.json"
node.override.merge!(JSON.parse(File.read("/etc/chef/serverInfo.json")))
command "echo 'password is " + node["MYSQL_PASSWORD"] + "' > /tmp/chefvartest.txt"
end
However it seems that any command to change the values through node.override.
etc. are done when Chef-solo starts up and parses the recipes, rather than when the recipes are actually run.
How can I set the value of a node variable like node["MYSQL_PASSWORD"]
in one recipe, to be used later in a separate recipe?