-
Notifications
You must be signed in to change notification settings - Fork 81
Add shared-network configuration #237
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| # @summary | ||
| # Define a DHCP shared-network | ||
| # @param subnets | ||
| # subnets to include in the shared-network statement | ||
| # @param order | ||
| # Fragment order in the dhcpd.conf | ||
| define dhcp::sharednet ( | ||
| Hash[String,Hash] $subnets = {}, | ||
| Integer[1] $order = 75, | ||
| ) { | ||
| concat::fragment { "dhcp.conf+${order}-start_${name}.dhcp": | ||
| target => "${dhcp::dhcp_dir}/dhcpd.conf", | ||
| content => "shared-network ${name} {\n", | ||
| order => "${order}-0start", | ||
| } | ||
| concat::fragment { "dhcp.conf+${order}-end_${name}.dhcp": | ||
| target => "${dhcp::dhcp_dir}/dhcpd.conf", | ||
| content => "}\n", | ||
| order => "${order}-9end", | ||
| } | ||
| create_resources('dhcp::subnet', $subnets, { order => $order }) | ||
| } | ||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,41 @@ | ||||||
| require 'spec_helper_acceptance' | ||||||
|
|
||||||
| describe 'Simple installation' do | ||||||
| interface = 'eth0' | ||||||
| config_file = fact('os.family') == 'Archlinux' ? '/etc/dhcpd.conf' : '/etc/dhcp/dhcpd.conf' | ||||||
|
|
||||||
| it_behaves_like 'an idempotent resource' do | ||||||
| let(:manifest) do | ||||||
| <<-EOS | ||||||
| $interface = $facts['networking']['interfaces']['#{interface}'] | ||||||
|
|
||||||
| class { 'dhcp': | ||||||
| interfaces => ['#{interface}'], | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this variable interpolation looks a bit complicated. can't we just do:
Suggested change
Then you can drop line 10 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've copied the test from the repo, it use the variable interface during the test There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, the current code is correct. |
||||||
| shared_networks => { | ||||||
| 'shared' => { | ||||||
| subnets => { | ||||||
| $interface['network'] => { | ||||||
| network => $interface['network'], | ||||||
| mask => $interface['netmask'], | ||||||
| pools => [], | ||||||
| }, | ||||||
| '172.20.0.0' => { | ||||||
| network => '172.20.0.0', | ||||||
| mask => '255.255.255.0', | ||||||
| pools => [], | ||||||
| } | ||||||
| } | ||||||
| } | ||||||
| }, | ||||||
| } | ||||||
| EOS | ||||||
| end | ||||||
| end | ||||||
|
|
||||||
| it_behaves_like 'a DHCP server' | ||||||
|
|
||||||
| describe file(config_file) do | ||||||
| it { is_expected.to be_file } | ||||||
| its(:content) { should match(/shared-network shared/) } | ||||||
| end | ||||||
| end | ||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably I need to change 9end in Zend to ensure it is at the end os the of the dhcp::subnet resource