[Solved] puppet, what is the difference between ‘=’ and ‘=>’


= is used to assign a value to a variable, e.g.

$foo = 'bar'

There are some advanced ways to assign variables in Puppet 4, but generally speaking whenever it’s a $variable on the left hand side of the expression, add no comma and always use =. Further variable assignments are simply separated by new lines.

=> is a key-value separator in hashes or lists of attributes in resources:

{
  'foo' => 'bar',
  'bar' => 'baz',
}

or

file { '/etc/foo.conf':
  ensure  => present,
  content => 'bar',
}

Note that foo, bar, ensure and content are not variables themselves – they’re keys in a hash or attributes.

You’ll find a similar design in many languages, e.g. Perl.

solved puppet, what is the difference between ‘=’ and ‘=>’