ruby - Chef custom resource action properties not working -
i'm having issue custom resource created in new cookbook i'm working on. when kitchen converge on following setup following error:
error: nomethoderror: undefined method `repository_url' poiseapplicationgit::resource
info development machine:
- chef development kit version: 2.1.11
- chef-client version: 13.2.20
- delivery version: master (73ebb72a6c42b3d2ff5370c476be800fee7e5427)
- berks version: 6.3.0
- kitchen version: 1.17.0
- inspec version: 1.33.1
here's custom resource under resources/deploy.rb:
resource_name :opsworks_deploy property :app_path, string, name_property: true property :app_name, string, required: true property :repository_url, string, required: true property :repository_key, string, required: true property :short_name, string, required: true property :app_type, string, required: true property :app, object, required: true property :permission, string, required: true action :deploy apt_update 'update' # install nginx package 'nginx' not_if { ::file.exist?("/etc/init.d/nginx") } end # setup app directory directory my_app_path owner 'www-data' group 'www-data' mode '0755' recursive true end slack_notify "notify_deployment_end" message "app #{app_name} deployed successfully" action :nothing end slack_notify "notify_nginx_reload" message "nginx has reloaded" action :nothing end slack_notify "notify_nginx_config" message "nginx site config has been updated #{app_name}" action :nothing end slack_notify "notify_git_deploy" message "app #{app_name} has been checkout out git" action :nothing end slack_notify "notify_file_permissions" message "app #{app_name} has been given proper file permissions" action :nothing end # deploy git repo opsworks app application app_path owner 'www-data' group 'www-data' git user 'root' group 'root' repository my_repo_url deploy_key my_repo_key notifies :notify, "slack_notify[notify_git_deploy]", :immediately end execute "chown-data-www" command "chown -r www-data:www-data #{my_app_path}" user "root" action :run notifies :notify, "slack_notify[notify_file_permissions]", :immediately end # setup nginx config file site template "/etc/nginx/sites-enabled/#{my_short_name}" source "#{my_app_type}.erb" owner "root" group "root" mode 0644 variables( :app => my_app ) notifies :notify, "slack_notify[notify_nginx_config]", :immediately end # reload nginx service "nginx" supports :status => true, :restart => true, :reload => true, :stop => true, :start => true action :reload notifies :notify, "slack_notify[notify_nginx_reload]", :immediately end end end
here's recipe under recipes/default.rb (all variables set , proper types, i'm using test data bags , correctly passing):
command = search(:aws_opsworks_command).first deploy_app = command[:args][:app_ids].first app = search(:aws_opsworks_app, "app_id:#{deploy_app}").first app_path = "/var/www/" + app[:shortname] opsworks_deploy app_path app_name app[:name] app_type app[:environment][:app_type] repository_url app[:app_source][:url] repository_key app[:app_source][:ssh_key] short_name app[:shortname] app app permission '0755' end
the way can working if add @ top of action declaration , update properties within match:
action :deploy my_repo_url = repository_url.dup my_repo_key = repository_key.dup my_app_path = app_path.dup my_app_type = app_type.dup my_short_name = short_name.dup my_app = app.dup ...
any reason why case? should have redeclare them in action?
use new_resource.repository_url
, similar. magic aliasing doesn't work correctly in lot of circumstances , we've formally deprecated of 13.1 (though it's been not recommended while).
Comments
Post a Comment