Module: AugeasProviders::Type
- Defined in:
- lib/augeasproviders/type.rb
Overview
Utilities to help write types for Puppet with Augeas-based providers.
To use, include in the type:
Puppet::Type.newtype(:example) do
  extend AugeasProviders::Type
  # [..]
end
Instance Method Summary collapse
- 
  
    
      #positionable { ... } ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    Implements ‘ensurable` with an additional value of `positioned`. 
Instance Method Details
#positionable { ... } ⇒ Object
Implements ‘ensurable` with an additional value of `positioned`.
When set to ‘positioned`, the type will call `provider.in_position?` to check if the resource is currently in the correct position in the file. If it isn’t, the resource will be destroyed and recreated - assuming the provider then creates it in the correct position.
| 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | # File 'lib/augeasproviders/type.rb', line 25 def positionable(&block) ensurable do defaultvalues block if block_given? newvalue(:positioned) do current = self.retrieve if current == :absent provider.create elsif !provider.in_position? provider.destroy provider.create end end def insync?(is) return true if should == :positioned and is == :present and provider.in_position? super end end end |