diff --git a/README.md b/README.md index aecd25f..a79ea38 100644 --- a/README.md +++ b/README.md @@ -8,11 +8,25 @@ Requirements Needs to be used on a system that utilizes /etc/motd.tail, e.g. Ubuntu. +Attributes +========== + +* `node['motd-tail']['additional_text']` - Additional text to add to the end + of the motd.tail (e.g. unauthorized access banner). + Usage ===== -When the node runs, the recipe will add the list of roles to -`/etc/motd.tail` so you can tell at a glance on login what the system is. +```json +"run_list": [ + "recipe[motd-tail]" +] +``` + +default +---- + +Updates motd.tail with useful node data Examples -------- @@ -29,16 +43,18 @@ For example, rsyslog_server *** + Additional text here when `node['motd-tail']['additional_text']` present. + Testing ===== This cookbook is using [ChefSpec](https://github.com/acrmp/chefspec) for testing. - $ cd $repo - $ bundle - $ librarian-chef install - $ ln -s ../ cookbooks/motd-tail - $ rspec cookbooks/motd-tail + % cd $repo + % bundle + % librarian-chef install + % ln -s ../ cookbooks/motd-tail + % rspec cookbooks/motd-tail License and Author ================== diff --git a/attributes/default.rb b/attributes/default.rb new file mode 100644 index 0000000..e3dec01 --- /dev/null +++ b/attributes/default.rb @@ -0,0 +1,21 @@ +# +# Author:: John Dewey () +# Cookbook Name:: motd +# Recipe:: default +# +# Copyright 2012, John Dewey +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +default['motd-tail']['additional_text'] = nil diff --git a/recipes/default.rb b/recipes/default.rb index f3e6110..a4a1427 100644 --- a/recipes/default.rb +++ b/recipes/default.rb @@ -20,8 +20,8 @@ template "/etc/motd.tail" do source "motd.tail.erb" - group "root" - owner "root" - mode "0644" + group "root" + owner "root" + mode 00644 backup 0 end diff --git a/spec/default_spec.rb b/spec/default_spec.rb index b435d20..041109c 100644 --- a/spec/default_spec.rb +++ b/spec/default_spec.rb @@ -75,4 +75,13 @@ chef_run.should create_file_with_content @file, "tag2" end + + it "has additional text" do + chef_run = ChefSpec::ChefRunner.new do |n| + n.set['motd-tail'] = {} + n.set['motd-tail']['additional_text'] = "this is some additional text" + end.converge "motd-tail::default" + chef_run.should create_file_with_content @file, + "this is some additional text" + end end diff --git a/templates/default/motd.tail.erb b/templates/default/motd.tail.erb index 8a7a068..8a74eaa 100644 --- a/templates/default/motd.tail.erb +++ b/templates/default/motd.tail.erb @@ -21,3 +21,5 @@ Tags: <% end -%> <% end -%> *** + +<%= node['motd-tail']['additional_text'] %>