Skip to content

Commit

Permalink
Show correct Operating System for Red Hat Enterprise Linux 7 in motd.
Browse files Browse the repository at this point in the history
The file /etc/issue looks on Red Hat Enterprise Linux 7 like this:

~~~
\S
Kernel \r on an \m
~~~

The \S gets expanded to the current release. For this reason the
existing functionality doesn't work as expected.

The File /etc/redhat-release contains the correct version string:

Red Hat Enterprise Linux Server release 7.1 (Maipo)
  • Loading branch information
workeitel committed Jul 3, 2015
1 parent 425c395 commit fe6a314
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
8 changes: 8 additions & 0 deletions opsworks_stack_state_sync/recipes/motd.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
os_release =
if node[:platform] == "redhat" && Chef::VersionConstraint.new("~> 7.0").include?(node["platform_version"])
os_release = File.read("/etc/redhat-release").chomp
else
`head -1 /etc/issue | sed -e 's/ \\\\.*//'`.chomp
end

template "/etc/motd.opsworks-static" do
source "motd.erb"
mode "0644"
variables({
:stack => node[:opsworks][:stack],
:layers => node[:opsworks][:layers],
:instance => node[:opsworks][:instance],
:os_release => os_release
})
end
2 changes: 1 addition & 1 deletion opsworks_stack_state_sync/templates/default/motd.erb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
This instance is managed with AWS OpsWorks.

###### OpsWorks Summary ######
Operating System: <%= `head -1 /etc/issue | sed -e 's/ \\\\.*//'`.chomp %>
Operating System: <%= @os_release %>
OpsWorks Instance: <%= @instance[:hostname] %>
OpsWorks Instance ID: <%= @instance[:id] %>
OpsWorks Layers: <%= @instance[:layers].map{|id| @layers[id][:name] }.join(', ') %>
Expand Down

0 comments on commit fe6a314

Please sign in to comment.