Search code examples
amazon-web-servicesaws-opsworks

aws opsworks cli run cookbook and capture cookbook output


I am trying to execute a recipe via AWS opsworks cli it is working without any problem. The problem is it is returning "DeploymentId" as output. I am executing the following command-

aws opsworks create-deployment --stack-id c7cxxxxx-efxx-xxxx-xxxx-1dexxxxxxc78 --command {"Name":"execute_recipes", "Args":{"recipes":["cookbook::recipes"]}}

Output-

{ "DeploymentId": "824749ec-7e20-42ca-89c5-6646cf0c863c" }

I want to get the opsworks instances chef deployment output - like -

[2017-03-14T00:06:50-04:00] INFO: Starting chef-zero on port 8889 with repository at repository at /opt/aws/opsworks/current
One version per cookbook
data_bags at /var/lib/aws/opsworks/data/data_bags
nodes at /var/lib/aws/opsworks/data/nodes
[2017-03-14T00:06:50-04:00] INFO: Forking chef instance to converge... [2017-03-14T00:06:50-04:00] INFO: *** Chef 11.10.4 *** [2017-03-14T00:06:50-04:00] INFO: Chef-client pid: 28634 [2017-03-14T00:06:50-04:00] INFO: Setting the run_list to ["opsworks_custom_cookbooks::load", "opsworks_custom_cookbooks::execute"] from JSON [2017-03-14T00:06:50-04:00] WARN: Run List override has been provided. [2017-03-14T00:06:50-04:00] WARN: Original Run List: [recipe[opsworks_custom_cookbooks::load], recipe[opsworks_custom_cookbooks::execute]]

Is there any way possible? I am testing this from a Jenkins and want to capture the chef-log.


Solution

  • Thanks to @Tensibai. aws opswork describe-deployment Link will give you the required help. For eg-

    aws opsworks describe-commands --deployment-id axxxxxxxxx-3xxxxxxx -4xxx-8xxxxx-9xxxxxxx
    

    This will give you the result. where you can featch the result from linked s3 location.