ruby - How I can capture values in command line and add to recipe? -
i new chef , ruby
i need pass 2 variables chef on command line , have variables available in recipe.
how can capture these values , them in chef?
i need this:
before_deploy command execute param1 param2 deploy{ param1/param2}
where param1
, param2
values @ run-time command-line.
when provision machine running
chef-solo
or
chef-client
you cannot provide arguments these commands can visible recipes. chef recipes work attributes. thing (or not good) attributes can set many different places: roles, nodes, environments , json file.
the workaround nearest request is
create json-file on machine pass when runningchef-client
or chef-solo
use attributes in recipe for example: apache config.
create json file: my_attrs.json
{ "apache": { "listen_port": "81", "listen_path": "/myapp" } }
and utilize them in recipe:
node[:apache][:listen_port] node[:apache][:listen_path]
run chef-client
or chef-solo
-j
flag.
chef-solo -j my_attrs.json
if my_attrs.json on remote server, can provide url.
chef-solo -j http://remote.host/path/my_attrs.json
ruby chef
No comments:
Post a Comment