RE: Working with options on Package resource


#1

Modifying the email subject

From: Iqbal, Ayesha
Sent: Thursday, March 29, 2012 4:32 PM
To: chef@lists.opscode.com
Cc: Iqbal, Ayesha
Subject: Working with options on Package resource

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