publicissapient-france / chef-confluence-jira-crowd

Setups up a cluster with Confluence, Jira and Crowd all talking to one another.
Other
0 stars 1 forks source link

Travis Failure over Digital Ocean test: Error executing action `create` on resource 'template[/etc/apache2/sites-available/(none).conf]' #1

Open esciara opened 10 years ago

esciara commented 10 years ago

Failed Travis job is https://travis-ci.org/esciara/chef-confluence-jira-crowd/builds/24057988 . Full stack:

        Recipe: confluence::apache2
         * template[/etc/apache2/sites-available/(none).conf] action create[2014-04-29T18:40:58-04:00] INFO: Processing template[/etc/apache2/sites-available/(none).conf] action create (confluence::apache2 line 29)
[2014-04-29T18:40:58-04:00] INFO: template[/etc/apache2/sites-available/(none).conf] created file /etc/apache2/sites-available/(none).conf       

    - create new file /etc/apache2/sites-available/(none).conf       
================================================================================       
Error executing action `create` on resource 'template[/etc/apache2/sites-available/(none).conf]'       
================================================================================       

Chef::Mixin::Template::TemplateError       
------------------------------------       
undefined method `empty?' for nil:NilClass       

Resource Declaration:       
---------------------       
# In /tmp/kitchen/cache/cookbooks/apache2/definitions/web_app.rb       

 29:   template "#{node['apache']['dir']}/sites-available/#{application_name}.conf" do       
 30:     source   params[:template]       
 31:     local    params[:local]       
 32:     owner    'root'       
 33:     group    node['apache']['root_group']       
 34:     mode     '0644'       
 35:     cookbook params[:cookbook] if params[:cookbook]       
 36:     variables(       
 37:       :application_name => application_name,       
 38:       :params           => params       
 39:     )       
 40:     if ::File.exists?("#{node['apache']['dir']}/sites-enabled/#{application_name}.conf")       
 41:       notifies :reload, 'service[apache2]'       
 42:     end       
 43:   end       

Compiled Resource:       
------------------       
# Declared in /tmp/kitchen/cache/cookbooks/apache2/definitions/web_app.rb:29:in `block in from_file'       

template("/etc/apache2/sites-available/(none).conf") do       
  params {:template=>"web_app.conf.erb", :local=>false, :enable=>true, :name=>"(none)"}       
  provider Chef::Provider::Template       
  action "create"       
  retries 0       
  retry_delay 2       
  guard_interpreter :default       
  path "/etc/apache2/sites-available/(none).conf"       
  backup 5       
  atomic_update true       
  source "web_app.conf.erb"       
  variables {:application_name=>"(none)", :params=>{:template=>"web_app.conf.erb", :local=>false, :enable=>true, :name=>"(none)"}}       
  cookbook_name "confluence"       
  recipe_name "apache2"       
  owner "root"       
  group "root"       
  mode "0644"       
end       

Template Context:       
-----------------       
on line #9       
  7:    ServerName <%= node['confluence']['apache2']['virtual_host_name'] %>       
  8:    <% end -%>       
  9:    <% unless node['confluence']['apache2']['virtual_host_alias'].empty? -%>       
 10:    <% virtual_host_aliases = node['confluence']['apache2']['virtual_host_alias'].kind_of?(Array) ? node['confluence']['apache2']['virtual_host_alias'] : [ node['confluence']['apache2']['virtual_host_alias'] ] -%>       
 11:    <% virtual_host_aliases.each do |virtual_host_alias| -%>  
esciara commented 10 years ago

Here are the weird things:

/etc/apache2/sites-available/(none).conf

But part what really crashes is:

Chef::Mixin::Template::TemplateError       
------------------------------------       
undefined method `empty?' for nil:NilClass

This happens on the line:

  9:    <% unless node['confluence']['apache2']['virtual_host_alias'].empty? -%>  

which would mean that node['confluence']['apache2']['virtual_host_alias'] returns empty.

esciara commented 10 years ago

Reproduced the bug by running .kitchen.cloud.yml from my machine. Looking at the code, node['confluence']['apache2']['virtual_host_alias'] is set in attributes/default.rb of the bflad/chef-confluence@2802acb1c7c886a05090ef3f96df8b5e276246ff cookbook with

default['confluence']['apache2']['virtual_host_alias'] = node['fqdn']
default['confluence']['apache2']['virtual_host_name']  = node['hostname']

Looking on the Digital Ocean VM:

root@(none):~# hostname
(none)
root@(none):~# hostname --fqdn
hostname: Name or service not known
root@(none):~# cat /etc/hostname
confluence-ubuntu-1204-myusername-Ems-MacBook-Pro.local-7ywabhw6
root@(none):~# cat /etc/hosts
127.0.0.1   localhost confluence-ubuntu-1204-myusername-Ems-MacBook-Pro.local-7ywabhw6 confluence-ubuntu-1204-myusername-Ems-MacBook-Pro

The bug is corrected by forcing the hostname of the VM by adding the following in :

   driver:
     server_name: confluence-jira-crowd-server

The result on the VM is:

root@confluence-jira-crowd-server:~# hostname
confluence-jira-crowd-server
root@confluence-jira-crowd-server:~# hostname --fqdn
localhost

Looking at the code from test-kitchen/kitchen-digitalocean@b63c1bc92a7fc33590c7cb2b44057f7bcfbee6e6 in file lib/kitchen/driver/digitalocean.rb:

      default_config :server_name do |driver|
        driver.default_name
      end

# Further down...

      def default_name
        # Generate what should be a unique server name
        rand_str = Array.new(8) { rand(36).to_s(36) }.join
        "#{instance.name}-#{Etc.getlogin}-#{Socket.gethostname}-#{rand_str}"
      end

Opening an issue with test-kitchen/kitchen-digitalocean.

esciara commented 10 years ago

Temporarly fixed this and waiting for test-kitchen/kitchen-digitalocean#12 to be resolved.

esciara commented 10 years ago

Keep it open as fix is only temporary.