Skip to content

Commit

Permalink
creating a type and provider for veeam.ini
Browse files Browse the repository at this point in the history
  • Loading branch information
genebean committed Jun 22, 2018
1 parent 676f798 commit 9398a28
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
23 changes: 23 additions & 0 deletions lib/puppet/provider/veeam_agent_config/ini_setting.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# veeamagent/lib/puppet/provider/veeam_agent_config/ini_setting.rb
Puppet::Type.type(:veeam_agent_config).provide(
:ini_setting,
# set ini_setting as the parent provider
:parent => Puppet::Type.type(:ini_setting).provider(:ruby)
) do
# hard code the separator to the one used in the stock veeam.ini
def separator
'= '
end
# implement section as the first part of the namevar
def section
resource[:name].split('/', 2).first
end
def setting
# implement setting as the second part of the namevar
resource[:name].split('/', 2).last
end
# hard code the file path (this allows purging)
def self.file_path
'/etc/veeam/veeam.ini'
end
end
15 changes: 15 additions & 0 deletions lib/puppet/type/veeam_agent_config.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# veeamagent/lib/puppet/type/veeam_agent_config.rb
Puppet::Type.newtype(:veeam_agent_config) do
ensurable
newparam(:name, :namevar => true) do
desc 'Section/setting name to manage from veeam.ini'
# namevar should be of the form section/setting
newvalues(/\S+\/\S+/)
end
newproperty(:value) do
desc 'The value of the setting to define'
munge do |v|
v.to_s.strip
end
end
end

0 comments on commit 9398a28

Please sign in to comment.