Skip to content

Commit

Permalink
[COOK-2089] Added ability to add additional text
Browse files Browse the repository at this point in the history
Useful for specifying unauthorized access banner
  • Loading branch information
retr0h committed Dec 19, 2012
1 parent bdda372 commit 616642c
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 10 deletions.
30 changes: 23 additions & 7 deletions README.md
Expand Up @@ -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
--------
Expand All @@ -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
==================
Expand Down
21 changes: 21 additions & 0 deletions attributes/default.rb
@@ -0,0 +1,21 @@
#
# Author:: John Dewey (<john@dewey.ws>)
# 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
6 changes: 3 additions & 3 deletions recipes/default.rb
Expand Up @@ -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
9 changes: 9 additions & 0 deletions spec/default_spec.rb
Expand Up @@ -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
2 changes: 2 additions & 0 deletions templates/default/motd.tail.erb
Expand Up @@ -21,3 +21,5 @@ Tags:
<% end -%>
<% end -%>
***

<%= node['motd-tail']['additional_text'] %>

0 comments on commit 616642c

Please sign in to comment.