Working with options on Package resource


#1

Hi,

I am using Chef for installing postgresql. I am using my own customized cookbook and not the one already available on the opscode community. The intention is to install postgresql by picking up the packages from a custom defined apt repository. I have created a custom sources.list and copied it to /tmp directory on the node where I am running this recipe. My sources.list looks like this

deb http://10.94.147.248:8484/linux/ubuntu_10_x64/ /

My recipe file looks like this

execute “apt-get update” do
command "apt-get update -o Dir::Etc::sourcelist=/tmp/sources.list"
ignore_failure false
action :run
end
package “postgresql” do
action :install
options "-o Dir::Etc::sourcelist=/tmp/sources.list --no-list-cleanup"
end

This however fails with the error “package[postgresql] (postgresql::client line 29) had an error: Chef::Exceptions::package: No version specified, and no candidate version available for postgresql”

However if I modify my recipe file as below, things work fine

execute “apt-get update” do
command "apt-get update -o Dir::Etc::sourcelist=/tmp/sources.list"
ignore_failure false
action :run
end

execute “install postgresql” do
command "apt-get install -q -y -o Dir::Etc::sourcelist=/tmp/sources.list --no-list-cleanup postgresql"
ignore_failure false
action :run
end

Can someone in this forum please point out why the first recipe file is failing? Any help is immensely appreciated :slight_smile:

Cheers,
Ayesha


#2

On Thu, Mar 29, 2012 at 7:01 AM, Ayesha_Iqbal@dell.com wrote:

Can someone in this forum please point out why the first recipe file is
failing? Any help is immensely appreciated J

I would start by running ‘chef-client -l debug’ looking at the
actually command that is being run as a result of this provider.

Bryan


#3

On Thu, Mar 29, 2012 at 12:01 PM, Ayesha_Iqbal@dell.com wrote:

Hi,

I am using Chef for installing postgresql. I am using my own customized
cookbook and not the one already available on the opscode community. The
intention is to install postgresql by picking up the packages from a custom
defined apt repository. I have created a custom sources.list and copied it
to /tmp directory on the node where I am running this recipe. My
sources.list looks like this

deb http://10.94.147.248:8484/linux/ubuntu_10_x64/ /

My recipe file looks like this

execute “apt-get update” do

command “apt-get update -o Dir::Etc::sourcelist=/tmp/sources.list”

ignore_failure false

action :run

end

package “postgresql” do

action :install

options “-o Dir::Etc::sourcelist=/tmp/sources.list --no-list-cleanup”

end

This however fails with the error “package[postgresql] (postgresql::client
line 29) had an error: Chef::Exceptions::package: No version specified, and
no candidate version available for postgresql”

Can someone in this forum please point out why the first recipe file is
failing? Any help is immensely appreciated J

The package resource does not pass options to apt-cache.


#4

Why not use the apt_repository lwrp to install your custom package
source (and GPG key?) instead of all these nasty executes.

You don’t use apt like that usually do you?

–AJ

On 30 March 2012 10:32, Andrea Campi andrea.campi@zephirworks.com wrote:

On Thu, Mar 29, 2012 at 12:01 PM, Ayesha_Iqbal@dell.com wrote:

Hi,

I am using Chef for installing postgresql. I am using my own customized
cookbook and not the one already available on the opscode community. The
intention is to install postgresql by picking up the packages from a custom
defined apt repository. I have created a custom sources.list and copied it
to /tmp directory on the node where I am running this recipe. My
sources.list looks like this

deb http://10.94.147.248:8484/linux/ubuntu_10_x64/ /

My recipe file looks like this

execute “apt-get update” do

command “apt-get update -o Dir::Etc::sourcelist=/tmp/sources.list”

ignore_failure false

action :run

end

package “postgresql” do

action :install

options “-o Dir::Etc::sourcelist=/tmp/sources.list --no-list-cleanup”

end

This however fails with the error “package[postgresql] (postgresql::client
line 29) had an error: Chef::Exceptions::package: No version specified, and
no candidate version available for postgresql”

Can someone in this forum please point out why the first recipe file is
failing? Any help is immensely appreciated J

The package resource does not pass options to apt-cache.