-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add veeam_agent_config type & provider, refactor
This is a major rework of the module to use a type and provider instead of a template for managing the configuration settings of a Veeam agent. General refactoring and updating is also included.
- Loading branch information
Showing
14 changed files
with
129 additions
and
106 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
fixtures: | ||
repositories: | ||
inifile: "https://github.com/puppetlabs/puppetlabs-inifile.git" | ||
stdlib: "https://github.com/puppetlabs/puppetlabs-stdlib.git" | ||
yum: "https://github.com/voxpupuli/puppet-yum" | ||
symlinks: | ||
"veeamagent": "#{source_dir}" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,4 +3,5 @@ | |
coverage/ | ||
Gemfile.lock | ||
pkg/ | ||
vendor/ | ||
spec/fixtures/ | ||
vendor/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,4 @@ | ||
# Handles the main configuration file. | ||
class veeamagent::config inherits veeamagent { | ||
file { $veeamagent::config_path: | ||
ensure => $veeamagent::config_ensure, | ||
content => epp('veeamagent/veeam.ini.epp'), | ||
notify => Class['::veeamagent::service'], | ||
} | ||
create_resources(veeam_agent_config, $veeamagent::config_entries) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,12 @@ | ||
# Handles the service. | ||
class veeamagent::service inherits veeamagent { | ||
service { $veeamagent::service_name: | ||
ensure => $veeamagent::service_ensure, | ||
enable => $veeamagent::service_enable, | ||
if $veeamagent::service_manage { | ||
service { $veeamagent::service_name: | ||
ensure => $veeamagent::service_ensure, | ||
enable => $veeamagent::service_enable, | ||
} | ||
|
||
# Make sure that any new or changed veeam_agent_config's refres the service | ||
Veeam_agent_config <| |> ~> Service[$veeamagent::service_name] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
require 'spec_helper' | ||
|
||
describe 'veeam_agent_config' do | ||
let(:title) { 'section_foo/setting_bar'} | ||
it { is_expected.to be_valid_type } | ||
it { is_expected.to be_valid_type.with_provider(:ini_setting) } | ||
it { is_expected.to be_valid_type.with_parameters('name') } | ||
it { is_expected.to be_valid_type.with_properties('value') } | ||
end |