Skip to content

Commit

Permalink
(Feature) Adding banner support
Browse files Browse the repository at this point in the history
  • Loading branch information
tphoney committed Aug 1, 2018
1 parent 5090e67 commit 0d96b21
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 1 deletion.
38 changes: 38 additions & 0 deletions lib/puppet/type/banner.rb
@@ -0,0 +1,38 @@
require_relative '../../puppet_x/puppetlabs/netdev_stdlib/check'
if PuppetX::NetdevStdlib::Check.use_old_netdev_type
Puppet::Type.newtype(:banner) do
@doc = 'Set various banner on a device'

apply_to_all

newparam(:name, namevar: true) do
desc 'The banner resource. The name stays as "default"'
newvalues(:default)
end

newproperty(:motd) do
desc 'The MOTD banner'
munge { |v| String(v) }
end
end
else
require 'puppet/resource_api'

Puppet::ResourceApi.register_type(
name: 'banner',
docs: 'Set various banner on a device.',
features: ['remote_resource'],
attributes: {
name: {
type: 'String',
desc: 'The banner resource. The name stays as "default"',
behaviour: :namevar,
default: 'default',
},
motd: {
type: 'String',
desc: 'The MOTD banner',
},
}
)
end
2 changes: 1 addition & 1 deletion lib/puppet/type/ntp_server.rb
Expand Up @@ -25,7 +25,7 @@
end

newproperty(:maxpoll) do
desc 'The maximul poll interval'
desc 'The maximum poll interval'
munge { |v| Integer(v) }
end

Expand Down
18 changes: 18 additions & 0 deletions spec/unit/puppet/type/banner.rb
@@ -0,0 +1,18 @@
# encoding: utf-8

require 'spec_helper'
describe 'banner' do
describe 'old style' do
fake_operatingsystem
describe Puppet::Type.type(:banner) do
it_behaves_like 'name is the namevar'
end
end
describe 'resource-api' do
describe 'the banner type' do
it 'loads' do
expect(Puppet::Type.type(:banner)).not_to be_nil
end
end
end
end

0 comments on commit 0d96b21

Please sign in to comment.