Ask Your Question

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

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

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

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

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


edit flag offensive delete link more

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

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


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

Seen: 8,191 times

Last updated: Jan 27 '14