Managing package preferences within chef (Debian, Ubuntu, RHEL, etc.)


#1

We’re looking for a lightweight way to specify package preferences
(inclusion and exclusion) on chef-managed hosts.

Ideally this would simply be a list of packages and desired
installation states. Primary target is Ubuntu / Debian, so:

<install|remove|purge>

… would be the general form.

I’m not seeing an obvious established way of doing this, but it seems
like the sort of thing that should exist.

What am I missing?


Dr. Ed Morbius
Chief Scientist / Philologist / Robot Wrangler / Powerplant Operator
Krell Power Systems Unlimited


#2

do you mean an array of packages?
%w{ pkg1 pkg2 pkg3}.each do |pkg|
action :remove
end

On Sat, Sep 29, 2012 at 1:09 AM, Edward Morbius dredmorbius@gmail.comwrote:

We’re looking for a lightweight way to specify package preferences
(inclusion and exclusion) on chef-managed hosts.

Ideally this would simply be a list of packages and desired
installation states. Primary target is Ubuntu / Debian, so:

<install|remove|purge>

… would be the general form.

I’m not seeing an obvious established way of doing this, but it seems
like the sort of thing that should exist.

What am I missing?


Dr. Ed Morbius
Chief Scientist / Philologist / Robot Wrangler / Powerplant Operator
Krell Power Systems Unlimited


#3

I don’t care about mechanism so much as I care about result.

I’d like to specify a set of packages and the state in which they
should exist on the system (including “not existing” as a state).

I’d like to do this in as simple, intuitive, and maintainable manner
as possible.

On Fri, Sep 28, 2012 at 2:11 PM, Ranjib Dey ranjibd@thoughtworks.com wrote:

do you mean an array of packages?
%w{ pkg1 pkg2 pkg3}.each do |pkg|
action :remove
end

On Sat, Sep 29, 2012 at 1:09 AM, Edward Morbius dredmorbius@gmail.com
wrote:

We’re looking for a lightweight way to specify package preferences
(inclusion and exclusion) on chef-managed hosts.

Ideally this would simply be a list of packages and desired
installation states. Primary target is Ubuntu / Debian, so:

<install|remove|purge>

… would be the general form.

I’m not seeing an obvious established way of doing this, but it seems
like the sort of thing that should exist.

What am I missing?


Dr. Ed Morbius
Chief Scientist / Philologist / Robot Wrangler / Powerplant Operator
Krell Power Systems Unlimited


Dr. Ed Morbius
Chief Scientist / Philologist / Robot Wrangler / Powerplant Operator
Krell Power Systems Unlimited


#4

Hello,

On 29 September 2012 10:26, Edward Morbius dredmorbius@gmail.com wrote:

I don’t care about mechanism so much as I care about result.

Using the Recipe DSL you can map node data into resources. This is a
common Chef practice/procedure.

Try building up a hash of packages/states and consuming that with the
Recipe DSL, turning 'em into Package resources:

attributes:

default[‘package_installer’][‘packages’] = {
“htop” => :install,
“bmon” => :remove
}

recipe:

node[‘package_installer’][‘packages’].map |pkg_name, pkg_action|
package pkg_name do
action pkg_action unless pkg_action.nil?
end
end

Hope this helps; you should easily be able to add more packages/states
to a role, or event extend this example to use a data-bag – usually
it is useful to care about the mechanism and the result!

Cheers,

AJ

I’d like to specify a set of packages and the state in which they
should exist on the system (including “not existing” as a state).

I’d like to do this in as simple, intuitive, and maintainable manner
as possible.

On Fri, Sep 28, 2012 at 2:11 PM, Ranjib Dey ranjibd@thoughtworks.com wrote:

do you mean an array of packages?
%w{ pkg1 pkg2 pkg3}.each do |pkg|
action :remove
end

On Sat, Sep 29, 2012 at 1:09 AM, Edward Morbius dredmorbius@gmail.com
wrote:

We’re looking for a lightweight way to specify package preferences
(inclusion and exclusion) on chef-managed hosts.

Ideally this would simply be a list of packages and desired
installation states. Primary target is Ubuntu / Debian, so:

<install|remove|purge>

… would be the general form.

I’m not seeing an obvious established way of doing this, but it seems
like the sort of thing that should exist.

What am I missing?


Dr. Ed Morbius
Chief Scientist / Philologist / Robot Wrangler / Powerplant Operator
Krell Power Systems Unlimited


Dr. Ed Morbius
Chief Scientist / Philologist / Robot Wrangler / Powerplant Operator
Krell Power Systems Unlimited


#5

Turns out Heavy Water has a cookbook for this too:

override_attributes(
:package_installer => {
:packages => {
‘vim’ => nil,
‘mailutils’ => {
:version => ‘2.2’
},
‘emacs’ => {
:action => :upgrade
}
}
}
)

Funny stuff.

Cheers,

AJ

On 29 September 2012 10:53, AJ Christensen aj@junglist.gen.nz wrote:

Hello,

On 29 September 2012 10:26, Edward Morbius dredmorbius@gmail.com wrote:

I don’t care about mechanism so much as I care about result.

Using the Recipe DSL you can map node data into resources. This is a
common Chef practice/procedure.

Try building up a hash of packages/states and consuming that with the
Recipe DSL, turning 'em into Package resources:

attributes:

default[‘package_installer’][‘packages’] = {
“htop” => :install,
“bmon” => :remove
}

recipe:

node[‘package_installer’][‘packages’].map |pkg_name, pkg_action|
package pkg_name do
action pkg_action unless pkg_action.nil?
end
end

Hope this helps; you should easily be able to add more packages/states
to a role, or event extend this example to use a data-bag – usually
it is useful to care about the mechanism and the result!

Cheers,

AJ

I’d like to specify a set of packages and the state in which they
should exist on the system (including “not existing” as a state).

I’d like to do this in as simple, intuitive, and maintainable manner
as possible.

On Fri, Sep 28, 2012 at 2:11 PM, Ranjib Dey ranjibd@thoughtworks.com wrote:

do you mean an array of packages?
%w{ pkg1 pkg2 pkg3}.each do |pkg|
action :remove
end

On Sat, Sep 29, 2012 at 1:09 AM, Edward Morbius dredmorbius@gmail.com
wrote:

We’re looking for a lightweight way to specify package preferences
(inclusion and exclusion) on chef-managed hosts.

Ideally this would simply be a list of packages and desired
installation states. Primary target is Ubuntu / Debian, so:

<install|remove|purge>

… would be the general form.

I’m not seeing an obvious established way of doing this, but it seems
like the sort of thing that should exist.

What am I missing?


Dr. Ed Morbius
Chief Scientist / Philologist / Robot Wrangler / Powerplant Operator
Krell Power Systems Unlimited


Dr. Ed Morbius
Chief Scientist / Philologist / Robot Wrangler / Powerplant Operator
Krell Power Systems Unlimited