diff options
-rw-r--r-- | .sync.yml | 2 | ||||
-rw-r--r-- | .travis.yml | 24 | ||||
-rw-r--r-- | manifests/server/service.pp | 15 | ||||
-rw-r--r-- | manifests/subnet.pp | 2 | ||||
-rw-r--r-- | metadata.json | 1 | ||||
-rw-r--r-- | spec/acceptance/dhcp_server_spec.rb | 20 | ||||
-rw-r--r-- | spec/defines/dhcp_subnet_spec.rb | 4 | ||||
-rw-r--r-- | spec/spec_helper_acceptance.rb | 21 |
8 files changed, 84 insertions, 5 deletions
@@ -1,3 +1,5 @@ --- .travis.yml: + acceptance: + - '*' forge_password: "vAwCsf7dOPitWzwZFk/nKa8vCqkpvBHc/Ik9lgJHpp1f/FY+ywetifCFHtCCiaJnvmLfsolB3m6oh7XmxVfToXNb7Lcr/qwngoFI0AMDOQH3P8WXN5xTuBFWYZTz3ffjllHZGwykVPgd1DgGbStlXFZST8OoCEpRGFGf9nPxNrU=" diff --git a/.travis.yml b/.travis.yml index ec3a8ee..ff4dc90 100644 --- a/.travis.yml +++ b/.travis.yml @@ -21,6 +21,30 @@ matrix: env: PUPPET_GEM_VERSION="~> 3.0" FUTURE_PARSER="yes" - rvm: 2.1.6 env: PUPPET_GEM_VERSION="~> 4.0" + - rvm: default + sudo: required + services: docker + env: BEAKER_set="debian-6-x86_64-docker" + bundler_args: + script: sudo service docker restart ; sleep 10 && bundle exec rspec spec/acceptance/*_spec.rb + - rvm: default + sudo: required + services: docker + env: BEAKER_set="debian-7-x86_64-docker" + bundler_args: + script: sudo service docker restart ; sleep 10 && bundle exec rspec spec/acceptance/*_spec.rb + - rvm: default + sudo: required + services: docker + env: BEAKER_set="debian-8-x86_64-docker" + bundler_args: + script: sudo service docker restart ; sleep 10 && bundle exec rspec spec/acceptance/*_spec.rb + - rvm: default + sudo: required + services: docker + env: BEAKER_set="ubuntu-14.04-x86_64-docker" + bundler_args: + script: sudo service docker restart ; sleep 10 && bundle exec rspec spec/acceptance/*_spec.rb notifications: email: false deploy: diff --git a/manifests/server/service.pp b/manifests/server/service.pp index ef016c5..031a603 100644 --- a/manifests/server/service.pp +++ b/manifests/server/service.pp @@ -10,10 +10,17 @@ class dhcp::server::service { validate_string($dhcp::params::service_pattern) validate_re($dhcp::params::service_pattern, '^\S+$') + if $::operatingsystem == 'Debian' and $::operatingsystemmajrelease == '8' { + $provider = 'debian' + } else { + $provider = undef + } + service {'dhcpd': - ensure => running, - name => $dhcp::params::srv_dhcpd, - enable => true, - pattern => $dhcp::params::service_pattern, + ensure => running, + provider => $provider, + name => $dhcp::params::srv_dhcpd, + enable => true, + pattern => $dhcp::params::service_pattern, } } diff --git a/manifests/subnet.pp b/manifests/subnet.pp index e7c72dd..1f069af 100644 --- a/manifests/subnet.pp +++ b/manifests/subnet.pp @@ -34,6 +34,8 @@ define dhcp::subnet( $is_shared = false ) { + Dhcp::Subnet[$title] ~> Class['dhcp::server::service'] + include ::dhcp::params $ip_re = '^([1-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])(\.([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])){3}$' diff --git a/metadata.json b/metadata.json index 9a45df3..0867c27 100644 --- a/metadata.json +++ b/metadata.json @@ -30,7 +30,6 @@ { "operatingsystem": "Ubuntu", "operatingsystemrelease": [ - "12.04", "14.04" ] } diff --git a/spec/acceptance/dhcp_server_spec.rb b/spec/acceptance/dhcp_server_spec.rb new file mode 100644 index 0000000..ae54c9f --- /dev/null +++ b/spec/acceptance/dhcp_server_spec.rb @@ -0,0 +1,20 @@ +require 'spec_helper_acceptance' + +describe 'dhcp::server' do + describe 'running puppet code' do + it 'should work with no errors' do + pp = <<-EOS + class { 'dhcp::server': } + dhcp::subnet { '172.17.0.0': + ensure => present, + broadcast => '172.17.0.255', + other_opts => ['range 172.17.0.100 172.17.0.250'], + } + EOS + + # Run it twice and test for idempotency + apply_manifest(pp, :catch_failures => true) + apply_manifest(pp, :catch_changes => true) + end + end +end diff --git a/spec/defines/dhcp_subnet_spec.rb b/spec/defines/dhcp_subnet_spec.rb index b0f7ab7..f3ea284 100644 --- a/spec/defines/dhcp_subnet_spec.rb +++ b/spec/defines/dhcp_subnet_spec.rb @@ -3,6 +3,10 @@ require 'spec_helper' describe 'dhcp::subnet' do let (:title) { '1.2.3.4' } + let(:pre_condition) do + "class { '::dhcp::server': }" + end + on_supported_os.each do |os, facts| context "on #{os}" do let(:facts) do diff --git a/spec/spec_helper_acceptance.rb b/spec/spec_helper_acceptance.rb new file mode 100644 index 0000000..3fa72d4 --- /dev/null +++ b/spec/spec_helper_acceptance.rb @@ -0,0 +1,21 @@ +require 'beaker-rspec' + +install_puppet_agent_on hosts, {} + +RSpec.configure do |c| + module_root = File.expand_path(File.join(File.dirname(__FILE__), '..')) + module_name = module_root.split('-').last + + # Readable test descriptions + c.formatter = :documentation + + # Configure all nodes in nodeset + c.before :suite do + # Install module + puppet_module_install(:source => module_root, :module_name => module_name) + hosts.each do |host| + on host, puppet('module','install','puppetlabs-concat'), { :acceptable_exit_codes => [0,1] } + on host, puppet('module','install','puppetlabs-stdlib'), { :acceptable_exit_codes => [0,1] } + end + end +end |