Skip to content

Instantly share code, notes, and snippets.

@sahilsk
Last active August 16, 2022 16:31
Show Gist options
  • Save sahilsk/c32a0a11678d37d248977ef40faad30e to your computer and use it in GitHub Desktop.
Save sahilsk/c32a0a11678d37d248977ef40faad30e to your computer and use it in GitHub Desktop.
aws opswork cheatsheet

Commands

http://docs.aws.amazon.com/opsworks/latest/userguide/agent.html

run_command

sudo opsworks-agent-cli run_command  <setup | deploy | etc >

list_commands

Lists the times for each activity that has been executed on this instance.

sudo opsworks-agent-cli list_commands

Instacne report

sudo opsworks-agent-cli instance_report

get_json

Returns information about a Chef run as a JSON object.

sudo opsworks-agent-cli get_json


  • Where is cookbook stored?

    /opt/aws/opsworks/

  • How to find run-list?

Run list is given as argument to chef run. You can find it while executing run_command in the output

eg.

RUBYOPT="-E utf-8" /opt/aws/opsworks/current/bin/chef-client -j /var/lib/aws/opsworks/chef/2016-09-28-18-11-22-01.json  \
-c /var/lib/aws/opsworks/client.stage2.rb \
-o opsworks_initial_setup,ssh_host_keys,ssh_users,mysql::client,dependencies,\
ebs,opsworks_ganglia::client,opsworks_stack_state_sync,opsworks_java::setup,\
timezone-ii,opsworks_sysctl_layer,opsworks_hostname,opsworks_resolvconf,\
opsworks_route53,java,daemontools::default,daemontools::svscan,deploy::default,deploy::java,\
,jarvis::post_deploy,test_suite,opsworks_cleanup 2>&1

Troubleshooting

include "java8"

file '/home/ubuntu/backup/payzapp/local_policy.jar' do
content IO.read('/usr/lib/jvm/java-8-oracle-amd64/jre/lib/security/local_policy.jar')
 action :create_if_missing
end


================================================================================
Recipe Compile Error in /var/lib/aws/opsworks/cache.stage2/cookbooks/xxxx/recipes/xxxx.rb
================================================================================


Errno::ENOENT
-------------
No such file or directory - /usr/lib/jvm/java-8-oracle-amd64/jre/lib/security/local_policy.jar

It's because of compile-time-vs-run-time-in-chef-recipes

Solution:

http://stackoverflow.com/questions/29545958/copying-local-file-after-compile-time-with-file-resource-in-chef

use lazy evaluation or notifications from dependent resource calls.

file '/home/ubuntu/backup/payzapp/local_policy.jar' do
  lazy { content IO.read('/usr/lib/jvm/java-8-oracle-amd64/jre/lib/security/local_policy.jar') }
  action :create_if_missing
end
@yermulnik
Copy link

Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment