Ask Your Question
1

Is it better to use 'present' or 'installed'

asked 2014-01-23 22:46:41 -0500

spuder gravatar image

A package can use either syntax

ensure  =>  present, 

ensure  =>  installed,

Why both syntaxes? Is one more likely to be deprecated?

edit retag flag offensive close merge delete

2 answers

Sort by ยป oldest newest most voted
3

answered 2014-01-24 02:06:31 -0500

I guess it's a feature. I'd be surprised if installed got deprecated, I see it as a user friendly alias, when context could help / clear ambiguity.

If you start with puppet, package {''blah': ensure => installed,} feels right. 'Present' is for consistency with other types (most of the rest have just present/absent pair).

Package is not the only one with context friendly ensure :

  • mount --> defined (also called present), unmounted, absent, mounted
  • service --> stopped (also called false), running (also called true)

Note : package has present (also called installed), absent, purged, held, latest

See http://docs.puppetlabs.com/references/3.stable/type.html

edit flag offensive delete link more
2

answered 2014-01-27 11:30:41 -0500

ramindk gravatar image

I find it useful to be explicit when possible. ensure => file for files, ensure => installed for packages, etc. It makes the code easier to grep though it isn't a huge benefit.

Which ever method you choose be consistent with it. Your code will be far less confusing to yourself a year later if you use the same syntax consistently.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2014-01-23 22:46:41 -0500

Seen: 5,429 times

Last updated: Jan 27 '14