Error in running python script using chef -
so, trying run simple python script using python resource of chef-cookbook. here recipe looks like:
python "excute_file" cwd '/home/peeyush/' code <<-eoh python #{filename} eoh end
but when run cookbook, following error:
recipe: hellochef::default * python[excute_file] action run ================================================================================ error executing action `run` on resource 'python[excute_file]' ================================================================================ mixlib::shellout::shellcommandfailed ------------------------------------ expected process exit [0], received '1' ---- begin output of "python" "/tmp/chef-script20140306-18792-iqfp89" ---- stdout: stderr: file "/tmp/chef-script20140306-18792-iqfp89", line 1 python test.py ^ indentationerror: unexpected indent ---- end output of "python" "/tmp/chef-script20140306-18792-iqfp89" ---- ran "python" "/tmp/chef-script20140306-18792-iqfp89" returned 1 resource declaration: --------------------- # in /home/peeyush/chef/cookbook/hellochef/recipes/default.rb 17: python "excute_file" 18: cwd '/home/peeyush/' 19: code <<-eoh 20: python #{filename} 21: eoh 22: end compiled resource: ------------------ # declared in /home/peeyush/chef/cookbook/hellochef/recipes/default.rb:17:in `from_file' python("excute_file") action "run" retries 0 retry_delay 2 command "\"python\" \"/tmp/chef-script20140306-18792-iqfp89\"" backup 5 cwd "/home/peeyush/" returns 0 code " python test.py\n" interpreter "python" cookbook_name :hellochef recipe_name "default" end running handlers: [2014-03-06t17:30:21+05:30] error: running exception handlers running handlers complete [2014-03-06t17:30:21+05:30] error: exception handlers complete [2014-03-06t17:30:21+05:30] fatal: stacktrace dumped /home/peeyush/chef/chef-stacktrace.out chef client failed. 0 resources updated in 6.727546421 seconds [2014-03-06t17:30:21+05:30] error: python[excute_file] (hellochef::default line 17) had error: mixlib::shellout::shellcommandfailed: expected process exit [0], received '1' ---- begin output of "python" "/tmp/chef-script20140306-18792-iqfp89" ---- stdout: stderr: file "/tmp/chef-script20140306-18792-iqfp89", line 1 python test.py ^ indentationerror: unexpected indent ---- end output of "python" "/tmp/chef-script20140306-18792-iqfp89" ---- ran "python" "/tmp/chef-script20140306-18792-iqfp89" returned 1 [2014-03-06t17:30:21+05:30] fatal: chef::exceptions::childconvergeerror: chef run process exited unsuccessfully (exit code 1)
i using chef-solo. can please me figure out error.
update: added "action :run" script. error is:
recipe: hellochef::default * python[excute_file] action run ================================================================================ error executing action `run` on resource 'python[excute_file]' ================================================================================ mixlib::shellout::shellcommandfailed ------------------------------------ expected process exit [0], received '1' ---- begin output of "python" "/tmp/chef-script20140306-19760-hs5acr" ---- stdout: stderr: file "/tmp/chef-script20140306-19760-hs5acr", line 1 python test.py ^ syntaxerror: invalid syntax ---- end output of "python" "/tmp/chef-script20140306-19760-hs5acr" ---- ran "python" "/tmp/chef-script20140306-19760-hs5acr" returned 1 resource declaration: --------------------- # in /home/peeyush/chef/cookbook/hellochef/recipes/default.rb 17: python "excute_file" 18: cwd '/home/peeyush/' 19: code <<-eoh 20: python #{filename} 21: eoh 22: action :run 23: end compiled resource: ------------------ # declared in /home/peeyush/chef/cookbook/hellochef/recipes/default.rb:17:in `from_file' python("excute_file") action [:run] retries 0 retry_delay 2 command "\"python\" \"/tmp/chef-script20140306-19760-hs5acr\"" backup 5 cwd "/home/peeyush/" returns 0 code "python test.py\n" interpreter "python" cookbook_name :hellochef recipe_name "default" end running handlers: [2014-03-06t17:43:33+05:30] error: running exception handlers running handlers complete [2014-03-06t17:43:33+05:30] error: exception handlers complete [2014-03-06t17:43:33+05:30] fatal: stacktrace dumped /home/peeyush/chef/chef-stacktrace.out chef client failed. 0 resources updated in 1.204350962 seconds [2014-03-06t17:43:33+05:30] error: python[excute_file] (hellochef::default line 17) had error: mixlib::shellout::shellcommandfailed: expected process exit [0], received '1' ---- begin output of "python" "/tmp/chef-script20140306-19760-hs5acr" ---- stdout: stderr: file "/tmp/chef-script20140306-19760-hs5acr", line 1 python test.py ^ syntaxerror: invalid syntax ---- end output of "python" "/tmp/chef-script20140306-19760-hs5acr" ---- ran "python" "/tmp/chef-script20140306-19760-hs5acr" returned 1 [2014-03-06t17:43:33+05:30] fatal: chef::exceptions::childconvergeerror: chef run process exited unsuccessfully (exit code 1)
the python
resource runs code as python. trying run python script - different things. in case, should use script
resource:
script 'execute_file' cwd '/home/peeyush' code "python #{filename}" end
or can execute contents of file using python
:
python 'execute' code <<-eoh.gsub(/^ {4}/, '') some.magical.python: code.in.here eoh end
Comments
Post a Comment