Reputation: 3516
Per the OpsWorks documentation with Chef v11 or earlier you could access a deploy key by doing:
include 'deploy'
key = node[:deploy]['appshortname'][:scm][:ssh_key]
However per OpsWorks with Chef 12 documentation:
To migrate your recipe code that accesses stack settings from Chef 11.10 and earlier versions for Linux to Chef 12 Linux, you must revise your code to:
- Access Chef data bags instead of Chef attributes.
- Use Chef search instead of the Chef node object.
- Use AWS OpsWorks data bag names such as aws_opsworks_app, instead of using AWS * OpsWorks attribute names such as opsworks and deploy.
My issue is that the documentation on how to access the ssh_key for deploy hasn't been updated to show where in the databags I can find the key.
Does anyone know of up-to-date documentation or can someone point me in the right direction for locating the ssh deploy key?
Upvotes: 2
Views: 834
Reputation: 2016
This is listed in this documentation page, under 'app_source': http://docs.aws.amazon.com/opsworks/latest/userguide/data-bag-json-app.html#data-bag-json-app-app-source
Here is a slightly changed example from the above page which also shows SSH key:
search("aws_opsworks_app").each do |app|
Chef::Log.info("********** The app's short name is '#{app['shortname']}' **********")
Chef::Log.info("********** The app's ssh_key is '#{app['app_source’][‘ssh_key’]}’ **********")
end
Upvotes: 2