I somehow keep having to google this, and the first hits are bugreports or old posts (pre 2010) that require inlined Ruby code for Puppet 2.7. There’s an easier way to check this.
To see if a variable value is present in an array, use the following.
if ! ($ensure in [ 'present', 'absent' ]) { ... }
The above checks if the variable $ensure
consists of either the value ‘present’ or ‘absent’.