Issue while bootstrapping the node

Hi All,

While doing bootstrap I am getting below error.

====
192.168.63.130 * postgresql_database_user[postgresjira] action createIgnoring mysql2-0.3.17 because its extensions are not built. Try: gem pristine
mysql2 --version 0.3.17
192.168.63.130 Ignoring pg-0.18.4 because its extensions are not built. Try: gem pristine pg --version 0.18.4
192.168.63.130 [2016-09-07T19:02:23+02:00] FATAL: Could not load the required pg gem. Make sure to include the database::postgresql or postgresql::rub
y recipes in your runlist
192.168.63.130
192.168.63.130
192.168.63.130 ================================================================================
192.168.63.130 Error executing action create on resource 'postgresql_database_user[postgresjira]'
192.168.63.130 ================================================================================
192.168.63.130
192.168.63.130 LoadError
192.168.63.130 ---------
192.168.63.130 cannot load such file – pg
192.168.63.130
192.168.63.130 Cookbook Trace:
192.168.63.130 ---------------
192.168.63.130 /var/chef/cache/cookbooks/database/libraries/provider_database_postgresql_user.rb:32:in load_current_resource' 192.168.63.130 /var/chef/cache/cookbooks/compat_resource/files/lib/chef_compat/monkeypatches/chef/runner.rb:41:inrun_action’
192.168.63.130
192.168.63.130 Resource Declaration:
192.168.63.130 ---------------------
192.168.63.130 # In /var/chef/cache/cookbooks/jira/recipes/database.rb
192.168.63.130
192.168.63.130 20: postgresql_database_user node[‘jira’][‘dbuser’] do
192.168.63.130 21: connection postgresql_connection_info
192.168.63.130 22: password node[‘jira’][‘dbpassword’]
192.168.63.130 23: action :create
192.168.63.130 24: end
192.168.63.130 25:
192.168.63.130
192.168.63.130 Compiled Resource:
192.168.63.130 ------------------
192.168.63.130 # Declared in /var/chef/cache/cookbooks/jira/recipes/database.rb:20:in `from_file’
192.168.63.130
192.168.63.130 postgresql_database_user(“postgresjira”) do
192.168.63.130 provider Chef::Provider::Database::PostgresqlUser
192.168.63.130 action [:create]
192.168.63.130 retries 0
192.168.63.130 retry_delay 2
192.168.63.130 default_guard_interpreter :default
192.168.63.130 username "postgresjira"
192.168.63.130 host "localhost"
192.168.63.130 privileges [:all]
192.168.63.130 login true
192.168.63.130 declared_type :postgresql_database_user
192.168.63.130 cookbook_name "jira"
192.168.63.130 recipe_name "database"
192.168.63.130 connection {:host=>“default-centos-72”, :port=>5432, :username=>“postgres”, :password=>“9iwRm09+gZBUZ8zr/I/K”}
192.168.63.130 password "postgresjira"
192.168.63.130 end
192.168.63.130
192.168.63.130 Platform:
192.168.63.130 ---------
192.168.63.130 x86_64-linux
192.168.63.130
192.168.63.130
192.168.63.130 Running handlers:
192.168.63.130 [2016-09-07T19:02:23+02:00] ERROR: Running exception handlers
192.168.63.130 Running handlers complete
192.168.63.130 [2016-09-07T19:02:23+02:00] ERROR: Exception handlers complete
192.168.63.130 Chef Client failed. 2 resources updated in 21 seconds
192.168.63.130 [2016-09-07T19:02:24+02:00] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out
192.168.63.130 [2016-09-07T19:02:24+02:00] FATAL: Please provide the contents of the stacktrace.out file if you file a bug report
192.168.63.130 [2016-09-07T19:02:24+02:00] ERROR: postgresql_database_user[postgresjira] (jira::database line 20) had an error: LoadError: cannot load
such file – pg
192.168.63.130 [2016-09-07T19:02:25+02:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)

I have already added recipe database::postgresql

I have tried the same chef script on local setup using kitchen and it is working fine.

Thanks and Regards,

Hi,

Could anyone please comment on this please. I am blocked for last 3 days and unable to progress.
I have tried different ways but issue remains.

Thanks and Regards,

Pankaj

I am not sure but the order of run_list is wrong and you need to run database::postgresql or postgresql::rub first to install pg gem. I would be nice if you could share me the bootstrap command.

I am using below command

knife bootstrap 192.168.63.130 --ssh-user root --ssh-password password --sudo --use-sudo-password --node-name nodejira --run-list ‘recipe[jira]’

The include_recipe ‘database::postgresql’ I have used in another recipe called database.
below is the database.rb file

{code}

Cookbook Name:: jira

Recipe:: database

Copyright © 2016 The Authors, All Rights Reserved.

include_recipe 'postgresql::config_pgtune’
include_recipe 'postgresql::server’
include_recipe ‘database::postgresql’

#creating postgres connection details
postgresql_connection_info = {
:host => node[‘jira’][‘dbhost’],
:port => 5432,
:username => ‘postgres’,
:password => node[‘postgresql’][‘password’][‘postgres’]
}

#creating DB user postgresjira and set password
postgresql_database_user node[‘jira’][‘dbuser’] do
connection postgresql_connection_info
password node[‘jira’][‘dbpassword’]
action :create
end

#Creating postgres SQL database
postgresql_database ‘jira_db’ do
connection postgresql_connection_info
connection_limit ‘-1’
# See: https://confluence.atlassian.com/display/JIRAKB/Health+Check%3A+Database+Collation
encoding 'utf8’
collation 'C’
template 'template0’
owner node[‘jira’][‘dbuser’]
action :create
end

#Grant all privileges to above use on the jira_db
postgresql_database_user node[‘jira’][‘dbuser’] do
connection postgresql_connection_info
database_name node[‘jira’][‘dbname’]
privileges [:all]
action :grant
end
{code}

Please share me the link of the cookbook if it is online one. So that I can look into it and try altering the order of recipe’s in the mean while.

Hi,

I am sorry it is not uploaded. I have the zip of entire cookbook. I can not upload here but in case u have ur email I could share the same with you.

Thanks and Regards,
Pankaj

Hi All,

Any help is much appreciated here.

Thanks and Regards,
Pankaj