Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error executing action create on resource 'template[/etc/postgresql/9.4/main/postgresql.conf]' #407

Closed
RtypeStudios opened this issue Jan 15, 2017 · 4 comments

Comments

@RtypeStudios
Copy link

Cookbook version

Cheffile:

site "http://community.opscode.com/api/v1"
cookbook 'apt'
cookbook 'build-essential'
cookbook 'nodejs'
cookbook 'ruby_build'
cookbook 'rbenv', git: 'https://github.com/ianbrown78/chef-rbenv'
cookbook 'vim'
cookbook 'postgresql', '> 6.0.1'
cookbook 'postgis', '
> 0.3.0'
cookbook 'redisio', git: 'https://github.com/brianbianco/redisio'

Chef-client version

Sorry not sure how to find this, I'm using vagrant 1.9.1

Platform Details

Windows 10 using Hyper V installing a Ubuntu 15.10

Scenario:

Installing Postgres 9.5

Steps to Reproduce:

using this vagrant file:

Vagrant.configure("2") do |config|

Set the provider order.

config.vm.provider "hyperv"
config.vm.provider "virtualbox"

Use Ubuntu Wily

config.vm.box = "remyjette/wily64"
config.vm.boot_timeout = 2000

Set port forwards.

config.vm.network :forwarded_port, guest: 5000, host: 5000
config.vm.network :forwarded_port, guest: 5432, host: 5432

Set up the sync folder.

config.vm.synced_folder ".", "/vagrant", type: "smb"

Set the virtual setttings.

config.vm.provider :hyperv do |hv|
hv.memory = 2048
hv.cpus = 2
hv.ip_address_timeout = 2000
end

Use Chef Solo to provision our virtual machine

config.vm.provision :chef_solo do |chef|
chef.cookbooks_path = ["cookbooks"]

chef.add_recipe "apt"
chef.add_recipe "postgresql::server"
chef.add_recipe "postgresql::client"
chef.add_recipe "postgresql::contrib"

chef.json = {
  
  postgresql: {
    version: '9.5',
    enable_pgdg_apt: true,

    client: { packages: ["postgresql-client-9.5"] },
    server: { packages: ["postgresql-9.5", "postgresql-server-dev-9.5"] },
    contrib: { packages: ["postgresql-contrib-9.5"], extensions: ["uuid-ossp"] },
        
    config: { 
      listen_addresses: "*", 
      datestyle: 'iso, dmy' 
    },

    password: { postgres: "md532e12f215ba27cb750c9e093ce4b5127" },

    pg_hba: [
      { type: 'local', db: 'all', user: 'all', addr: nil, method: 'trust' },
      { type: 'host', db: 'all', user: 'all', addr: '127.0.0.1/32', method: 'trust' },
      { type: 'host', db: 'all', user: 'all', addr: '::1/128', method: 'trust' },
      { type: 'host', db: 'all', user: 'all', addr: 'samenet', method: 'trust' }
    ],

  }
}

end
end

Expected Result:

Expected installation of postgres 9.5

Actual Result:

An error is thrown:

==> default: * Parent directory /etc/postgresql/9.4/main does not exist.
==> default:
==> default: ================================================================================
==> default:
==> default: Error executing action create on resource 'template[/etc/postgresql/9.4/main/postgresql.conf]'
==> default:
==> default: ================================================================================
==> default:
==> default:
==> default: Chef::Exceptions::EnclosingDirectoryDoesNotExist
==> default:
==> default: ------------------------------------------------
==> default:
==> default: Parent directory /etc/postgresql/9.4/main does not exist.
==> default:
==> default:
==> default: Resource Declaration:
==> default:
==> default: ---------------------
==> default:
==> default: # In /var/chef/cache/cookbooks/postgresql/recipes/server_conf.rb
==> default:
==> default:
==> default: 40: template "#{node['postgresql']['dir']}/postgresql.conf" do
==> default:
==> default: 41: source 'postgresql.conf.erb'
==> default:
==> default: 42: owner 'postgres'
==> default:
==> default: 43: group 'postgres'
==> default:
==> default: 44: mode '0600'
==> default:
==> default: 45: notifies change_notify, 'service[postgresql]', :immediately
==> default:
==> default: 46: end
==> default:
==> default: 47:
==> default:
==> default:
==> default: Compiled Resource:
==> default:
==> default: ------------------
==> default:
==> default: # Declared in /var/chef/cache/cookbooks/postgresql/recipes/server_conf.rb:40:in `from_file'
==> default:
==> default:
==> default: template("/etc/postgresql/9.4/main/postgresql.conf") do
==> default:
==> default: action [:create]
==> default:
==> default: retries 0
==> default:
==> default: retry_delay 2
==> default:
==> default: default_guard_interpreter :default
==> default:
==> default: source "postgresql.conf.erb"
==> default:
==> default: declared_type :template
==> default:
==> default: cookbook_name "postgresql"
==> default:
==> default: recipe_name "server_conf"
==> default:
==> default: owner "postgres"
==> default:
==> default: group "postgres"
==> default:
==> default: mode "0600"
==> default:
==> default: path "/etc/postgresql/9.4/main/postgresql.conf"
==> default:
==> default: end
==> default:
==> default:
==> default: Platform:
==> default:
==> default: ---------
==> default: x86_64-linux
==> default:
==> default: [2017-01-15T02:20:08-05:00] INFO: Running queued delayed notifications before re-raising exception
==> default:
==> default: Running handlers:
==> default: [2017-01-15T02:20:08-05:00] ERROR: Running exception handlers
==> default: Running handlers complete
==> default: [2017-01-15T02:20:08-05:00] ERROR: Exception handlers complete
==> default: Chef Client failed. 13 resources updated in 03 minutes 52 seconds
==> default: [2017-01-15T02:20:08-05:00] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out
==> default: [2017-01-15T02:20:08-05:00] FATAL: Please provide the contents of the stacktrace.out file if you file a bug report
==> default: [2017-01-15T02:20:08-05:00] ERROR: template[/etc/postgresql/9.4/main/postgresql.conf] (postgresql::server_conf line 40) had an error: Chef::Exceptions::EnclosingDirectoryDoesNotExist: Parent directory /etc/postgresql/9.4/main does not exist.
==> default: [2017-01-15T02:20:08-05:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)
Chef never successfully completed! Any errors should be visible in the
output above. Please fix your recipes so that they properly complete.

This appears the same as this bug, but it is reported fixed in 4.0.0
#261

When I log into the virtual the folder for 9.5 is there.

Thanks!

@RtypeStudios
Copy link
Author

The version of chef I'm using is:
==> default: [2017-01-15T19:12:16-05:00] INFO: *** Chef 12.17.44 ***

@RtypeStudios
Copy link
Author

Altering the dir property in the chef JSON seems to have resolved the issue for me on the 6.0.1 version:

 postgresql: {
    version: '9.5',
    dir: "/etc/postgresql/9.5/main",

@tas50
Copy link
Contributor

tas50 commented Jan 27, 2017

The dir property will have to be modified as it is constructed using the existing value. This is expected and comes down to how chef attributes work. I'm looking into a redesign that would avoid this. Also you should really consider upgrading from 15.10 to a new Ubuntu release as 15.10 no longer gets security updates. Using a newer Ubuntu release and Test Kitchen would probably make your troubleshooting much easier in the future.

@tas50 tas50 closed this as completed Jan 27, 2017
@lock
Copy link

lock bot commented Jul 24, 2018

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Jul 24, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants