Skip to content

Instantly share code, notes, and snippets.

@jayhendren
Created March 5, 2016 00:06
Show Gist options
  • Save jayhendren/65be82e3b0fed08a7fff to your computer and use it in GitHub Desktop.
Save jayhendren/65be82e3b0fed08a7fff to your computer and use it in GitHub Desktop.
using resources method from LWRP resource collection context
[birdsnest ~/pit/local/data/sis/git/cookbooks/cub_httpd](master|✔)[I]% kitchen converge 7
-----> Starting Kitchen (v1.5.0)
-----> Using policyfile mode for chef-client
-----> Using policyfile mode for chef-client
-----> Converging <default-CUBoulder-rhel-7>...
Preparing files for transfer
Preparing dna.json
Preparing validation.pem
Preparing client.rb
-----> Chef Omnibus installation detected (12.7.2)
Transferring files to <default-CUBoulder-rhel-7>
Starting Chef Client, version 12.7.2
Using policy 'cub_httpd' at revision '68ce4a68089683a48e24f502587db9e3e7338a1adecbf4f77d78bf56256b3365'
resolving cookbooks for run list: ["cub_httpd::[email protected] (fd5d68f)"]
Synchronizing Cookbooks:
- cub_httpd (0.1.0)
- ssl_certificate (1.11.0)
- cub_shared (0.1.1)
- apache2 (3.1.0)
Compiling Cookbooks...
Converging 1 resources
Recipe: cub_httpd::default
* cub_httpd_foo[foo] action create
================================================================================
Error executing action `create` on resource 'cub_httpd_foo[foo]'
================================================================================
Chef::Exceptions::ResourceNotFound
----------------------------------
Cannot find a resource matching service[httpd] (did you define it first?)
Cookbook Trace:
---------------
/tmp/kitchen/cache/cookbooks/cub_httpd/resources/foo.rb:9:in `block in class_from_file'
Resource Declaration:
---------------------
# In /tmp/kitchen/cache/cookbooks/cub_httpd/recipes/default.rb
9: cub_httpd_foo 'foo'
Compiled Resource:
------------------
# Declared in /tmp/kitchen/cache/cookbooks/cub_httpd/recipes/default.rb:9:in `from_file'
cub_httpd_foo("foo") do
action [:create]
retries 0
retry_delay 2
default_guard_interpreter :default
declared_type :cub_httpd_foo
cookbook_name "cub_httpd"
recipe_name "default"
end
Running handlers:
[2016-03-04T17:04:19-07:00] ERROR: Running exception handlers
Running handlers complete
[2016-03-04T17:04:19-07:00] ERROR: Exception handlers complete
Chef Client failed. 0 resources updated in 01 seconds
[2016-03-04T17:04:19-07:00] FATAL: Stacktrace dumped to /tmp/kitchen/cache/chef-stacktrace.out
[2016-03-04T17:04:19-07:00] FATAL: Please provide the contents of the stacktrace.out file if you file a bug report
[2016-03-04T17:04:19-07:00] ERROR: cub_httpd_foo[foo] (cub_httpd::default line 9) had an error: Chef::Exceptions::ResourceNotFound: Cannot find a resource matching service[httpd] (did you define it first?)
[2016-03-04T17:04:19-07:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)
>>>>>> Converge failed on instance <default-CUBoulder-rhel-7>.
>>>>>> Please see .kitchen/logs/default-CUBoulder-rhel-7.log for more details
>>>>>> ------Exception-------
>>>>>> Class: Kitchen::ActionFailed
>>>>>> Message: SSH exited (1) for command: [sh -c '
sudo -E /opt/chef/bin/chef-client --local-mode --config /tmp/kitchen/client.rb --log_level auto --force-formatter --no-color --chef-zero-port 8889
']
>>>>>> ----------------------
zlib(finalizer): the stream was freed prematurely.
[birdsnest ~/pit/local/data/sis/git/cookbooks/cub_httpd](master|✔)[I]%
#
# Cookbook Name:: cub_httpd
# Recipe:: default
#
# Copyright (c) 2016 sis-unix, All Rights Reserved.
cub_httpd_foo 'foo'
property :name, String, name_property: true
action :create do
package 'httpd'
service 'httpd'
resources('service[httpd]').action :nothing
ruby_block 'delay starting apache' do
block { }
notifies :enable, 'service[httpd]', :delayed
notifies :start, 'service[httpd]', :delayed
end
# we want the converge to fail (and apache to not get reloaded) if there are
# configuration errors
execute 'apache configtest' do
command "#{node['apache']['binary']} -t"
action :nothing
subscribes :run, 'service[httpd]', :before
end
# we want the converge to fail if apache fails to come back up after a
# restart or reload, but apache reload does not generate a non-zero exit
# status if a reload fails, so manually check to see if a reload failed
execute 'apache status' do
command "#{node['apache']['apachectl']} status"
action :nothing
subscribes :run, 'service[httpd]', :immediate
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment