Class: Puppet::Provider::Postconf
- Inherits:
-
Puppet::Provider
- Object
- Puppet::Provider
- Puppet::Provider::Postconf
- Defined in:
- lib/puppet/provider/postconf.rb
Instance Attribute Summary collapse
Class Method Summary collapse
- .initvars ⇒ Object
- .postconf_multi(config_dir, *args) ⇒ Object
- .postfix_instances ⇒ Object
- .prefetch(resources) ⇒ Object
-
.resource_type=(resource) ⇒ Object
Always make the resource methods.
Instance Method Summary collapse
- #create ⇒ Object
- #destroy ⇒ Object
- #exists? ⇒ Boolean
- #flush ⇒ Object
-
#initialize(*args) ⇒ Postconf
constructor
A new instance of Postconf.
Constructor Details
#initialize(*args) ⇒ Postconf
Returns a new instance of Postconf.
28 29 30 31 32 |
# File 'lib/puppet/provider/postconf.rb', line 28 def initialize(*args) super(*args) @property_flush = {} end |
Instance Attribute Details
#config_dir ⇒ Object
60 61 62 63 64 65 66 67 |
# File 'lib/puppet/provider/postconf.rb', line 60 def config_dir instance = resource.instance_name if instance.nil? nil else @config_dir ||= self.class.postfix_instances[instance] end end |
Class Method Details
.initvars ⇒ Object
4 5 6 7 8 9 |
# File 'lib/puppet/provider/postconf.rb', line 4 def self.initvars super commands postmulti_cmd: 'postmulti' commands postconf_cmd: 'postconf' end |
.postconf_multi(config_dir, *args) ⇒ Object
69 70 71 72 73 74 75 76 77 |
# File 'lib/puppet/provider/postconf.rb', line 69 def self.postconf_multi(config_dir, *args) output = if config_dir postconf_cmd('-c', config_dir, *args) else postconf_cmd(*args) end return output.encode('UTF-8', 'binary', invalid: :replace, undef: :replace, replace: '') unless output.nil? end |
.postfix_instances ⇒ Object
52 53 54 55 56 57 58 |
# File 'lib/puppet/provider/postconf.rb', line 52 def self.postfix_instances postmulti_cmd('-l').split("\n").each_with_object({}) do |line, i| line = line.split(%r{ +}, 4) i[line[0]] = line[3] i end end |
.prefetch(resources) ⇒ Object
19 20 21 22 23 24 25 26 |
# File 'lib/puppet/provider/postconf.rb', line 19 def self.prefetch(resources) provs = instances resources.each_key do |name| if (provider = provs.find { |p| p.name == name }) resources[name].provider = provider end end end |
.resource_type=(resource) ⇒ Object
Always make the resource methods.
14 15 16 17 |
# File 'lib/puppet/provider/postconf.rb', line 14 def self.resource_type=(resource) super mk_resource_methods end |
Instance Method Details
#create ⇒ Object
38 39 40 |
# File 'lib/puppet/provider/postconf.rb', line 38 def create @property_flush[:ensure] = :present end |
#destroy ⇒ Object
42 43 44 |
# File 'lib/puppet/provider/postconf.rb', line 42 def destroy @property_flush[:ensure] = :absent end |
#exists? ⇒ Boolean
34 35 36 |
# File 'lib/puppet/provider/postconf.rb', line 34 def exists? @property_hash[:ensure] == :present end |
#flush ⇒ Object
46 47 48 49 50 |
# File 'lib/puppet/provider/postconf.rb', line 46 def flush write_entry @property_hash.clear end |