Skip to content

Commit

Permalink
2.1.7 - Read Changelog
Browse files Browse the repository at this point in the history
  • Loading branch information
LevonBecker committed Apr 15, 2017
1 parent 13f5f69 commit 150dd2b
Show file tree
Hide file tree
Showing 8 changed files with 89 additions and 91 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
## CHANGE LOG

## 2.1.7 - 04/15/2017 - Levon Becker
* Switch Dockerfile to copy client.rb instead of creating it.
* Added restart notification to /etc/awslogs/awscli.conf template resource
* Added chef-client logging to client.rb for Docker
* Added Deployment section to nodeinfo
* Improved node content logic to dry up some code

## 2.1.6 - 04/15/2017 - Levon Becker
* Fixed CloudWatch Logs Config order so default with us-east-1 no longer left
* Added CloudWatch Logs /var/log/chef-client.log stream
Expand Down
15 changes: 2 additions & 13 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ ARG chef_role=base
ARG chef_environment=bonusbits_base
ARG chef_config_path=/opt/chef-repo

LABEL version="2.1.6" \
LABEL version="2.1.7" \
description="Amazon Linux Image built from bonusbits_base cookbook." \
github="https://github.com/bonusbits/bonusbits_base" \
website="https://www.bonusbits.com"
Expand All @@ -34,18 +34,7 @@ COPY . cookbooks/${cookbook_name}/
COPY test/roles/* roles/
COPY test/environments/* environments/
COPY test/data_bags/* data_bags/
#COPY test/node/client.rb client.rb
RUN printf $"node_name \'docker_node\'\n\
checksum_path \'${chef_config_path}/checksums\'\n\
file_cache_path \'${chef_config_path}/cache\'\n\
file_backup_path \'${chef_config_path}/backup\'\n\
cookbook_path \'${chef_config_path}/cookbooks\'\n\
data_bag_path \'${chef_config_path}/data_bags\'\n\
environment_path \'${chef_config_path}/environments\'\n\
role_path \'${chef_config_path}/roles\'\n\
chef_server_url \'http://127.0.0.1:8889\'\n\
encrypted_data_bag_secret \'${chef_config_path}/data_bags/encrypted_data_bag_secret\'\n"\
> client.rb
COPY test/node/client.rb ${chef_config_path}/client.rb

# Download Dependant Cookbooks
WORKDIR ${chef_config_path}/cookbooks/${cookbook_name}
Expand Down
4 changes: 3 additions & 1 deletion attributes/cloudwatch_logs.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
default['bonusbits_base']['cloudwatch_logs']['configure'] = true
default['bonusbits_base']['cloudwatch_logs']['deploy_logs_conf'] = true
default['bonusbits_base']['cloudwatch_logs']['logs_group_name'] = 'kitchen-bonusbits-base'
# default['bonusbits_base']['cloudwatch_logs']['additional_logs'] = nil
# additional_logs = node['bonusbits_base']['cloudwatch_logs']['additional_logs'].nil? ? false : true

# Debug
message_list = [
'',
'** CloudWatch Logs **',
"Configure (#{node['bonusbits_base']['cloudwatch_logs']['configure']})",
"Log Group Name (#{node['bonusbits_base']['cloudwatch_logs']['logs_group_name']})"
# "Has Additional Logs (#{additional_logs})"
]
message_list.each do |message|
Chef::Log.warn(message)
Expand Down
92 changes: 39 additions & 53 deletions attributes/node_info.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,59 +14,45 @@
node_info['configure'] = true

node_info['content'] =
if node['bonusbits_base']['aws']['inside']
[
'-- NETWORK --',
"IP Address: (#{node['ipaddress']})",
"Hostname: (#{node['hostname']})",
"FQDN: (#{node['fqdn']})",
'',
'-- AWS --',
"Instance ID: (#{node['ec2']['instance_id']})",
"Region: (#{node['ec2']['placement_availability_zone'].slice(0..-2)})",
"Availability Zone: (#{node['ec2']['placement_availability_zone']})",
"AMI ID: (#{node['ec2']['ami_id']})",
'',
'-- PLATFORM --',
"OS: (#{node['os']})",
"Platform: (#{node['platform']})",
"Platform Version: (#{node['platform_version']})",
"Platform Family: (#{node['platform_family']})",
'',
'-- HARDWARE --',
"CPU Count: (#{node['cpu']['total']})",
"Memory: (#{memory_in_megabytes}MB)",
'',
'-- CHEF --',
"Detected Environment: (#{node.run_state['detected_environment']})",
"Chef Environment: (#{node.environment})",
"Chef Roles: (#{node['roles']})",
"Chef Recipes: (#{node['recipes']})"
]
else
[
'-- NETWORK --',
"IP Address: (#{node['ipaddress']})",
"Hostname: (#{node['hostname']})",
"FQDN: (#{node['fqdn']})",
'',
'-- PLATFORM --',
"OS: (#{node['os']})",
"Platform: (#{node['platform']})",
"Platform Version: (#{node['platform_version']})",
"Platform Family: (#{node['platform_family']})",
'',
'-- HARDWARE --',
"CPU Count: (#{node['cpu']['total']})",
"Memory: (#{memory_in_megabytes}MB)",
'',
'-- CHEF --',
"Detected Environment: (#{node.run_state['detected_environment']})",
"Chef Environment: (#{node.environment})",
"Chef Roles: (#{node['roles']})",
"Chef Recipes: (#{node['recipes']})"
]
end
[
'-- DEPLOYMENT --',
"Environment: (#{run_state['detected_environment']})",
"Type: (#{node['bonusbits_base']['deployment_type']})",
"Location: (#{node['bonusbits_base']['deployment_location']})",
"Method : (#{node['bonusbits_base']['deployment_method']})",
'',
'-- NETWORK --',
"IP Address: (#{node['ipaddress']})",
"Hostname: (#{node['hostname']})",
"FQDN: (#{node['fqdn']})",
'',
'-- PLATFORM --',
"OS: (#{node['os']})",
"Platform: (#{node['platform']})",
"Platform Version: (#{node['platform_version']})",
"Platform Family: (#{node['platform_family']})",
'',
'-- HARDWARE --',
"CPU Count: (#{node['cpu']['total']})",
"Memory: (#{memory_in_megabytes}MB)",
'',
'-- CHEF --',
"Node Name: (#{node.name})",
"Environment: (#{node.environment})",
"Roles: (#{node['roles']})",
"Recipes: (#{node['recipes']})"
]

if node['bonusbits_base']['aws']['inside']
node_info['content'].concat [
'',
'-- AWS --',
"Instance ID: (#{node['ec2']['instance_id']})",
"Region: (#{node['ec2']['placement_availability_zone'].slice(0..-2)})",
"Availability Zone: (#{node['ec2']['placement_availability_zone']})",
"AMI ID: (#{node['ec2']['ami_id']})"
]
end
end

# Debug
Expand Down
2 changes: 1 addition & 1 deletion metadata.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
license 'MIT'
description 'Foundation Wrapper Cookbook for all Nodes'
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
version '2.1.6'
version '2.1.7'
chef_version '~> 12.5' if respond_to?(:chef_version)
source_url 'https://github.com/bonusbits/bonusbits_base'
issues_url 'https://github.com/bonusbits/bonusbits_base/issues'
Expand Down
13 changes: 7 additions & 6 deletions recipes/cloudwatch_logs.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
inside_aws = node['bonusbits_base']['aws']['inside']

case node['os']
when 'linux'
case node['platform']
Expand Down Expand Up @@ -62,7 +64,7 @@
owner 'root'
group 'root'
mode '0755'
notifies :restart, 'service[awslogs]', :delayed
notifies :restart, 'service[awslogs]', :delayed if inside_aws
end
else
return
Expand All @@ -74,6 +76,7 @@
owner 'root'
group 'root'
mode '0644'
notifies :restart, 'service[awslogs]', :delayed if inside_aws
end

# Deploy AWS CloudWatch Logs Proxy Config
Expand All @@ -82,7 +85,7 @@
owner 'root'
group 'root'
mode '0644'
notifies :restart, 'service[awslogs]', :delayed
notifies :restart, 'service[awslogs]', :delayed if inside_aws
only_if { node['bonusbits_base']['proxy']['configure'] }
end

Expand All @@ -93,15 +96,13 @@
group 'root'
mode '0644'
notifies :restart, 'service[awslogs]', :delayed
only_if { node['bonusbits_base']['aws']['inside'] } # Ohai EC2 Plugin Used
# Wrapper Cookbook Should Lay down this file with customizations
only_if { node['bonusbits_base']['cloudwatch_logs']['deploy_logs_conf'] }
only_if { inside_aws } # Ohai EC2 Plugin Used
end

# Define Service
service 'awslogs' do
service_name 'awslogs'
action [:enable, :start]
action [:enable]
only_if { node['bonusbits_base']['aws']['inside'] }
end
when 'windows'
Expand Down
44 changes: 27 additions & 17 deletions templates/default/cloudwatch_logs/awslogs.conf.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,30 @@
state_file = /var/lib/awslogs/agent-state
use_gzip_http_content_encoding = true

[messages]
log_group_name = <%= node['bonusbits_base']['cloudwatch_logs']['logs_group_name'] %>
log_stream_name = <%= "#{node['ec2']['instance_id']}-messages" %>
datetime_format = %b %d %H:%M:%S
file = /var/log/messages

[yum]
log_group_name = <%= node['bonusbits_base']['cloudwatch_logs']['logs_group_name'] %>
log_stream_name = <%= "#{node['ec2']['instance_id']}-yum" %>
datetime_format = %b %d %H:%M:%S
file = /var/log/yum.log

[cron]
log_group_name = <%= node['bonusbits_base']['cloudwatch_logs']['logs_group_name'] %>
log_stream_name = <%= "#{node['ec2']['instance_id']}-cron" %>
datetime_format = %b %d %H:%M:%S
file = /var/log/cron

[chef-client]
log_group_name = <%= node['bonusbits_base']['cloudwatch_logs']['logs_group_name'] %>
log_stream_name = <%= "#{node['ec2']['instance_id']}-chef-client" %>
datetime_format = [%Y-%m-%dT%H:%M:%S-%z]
file = /var/log/chef-client.log

[cloud-init]
log_group_name = <%= node['bonusbits_base']['cloudwatch_logs']['logs_group_name'] %>
log_stream_name = <%= "#{node['ec2']['instance_id']}-cloud-init" %>
Expand All @@ -25,20 +49,6 @@ log_stream_name = <%= "#{node['ec2']['instance_id']}-cfn-init-cmd" %>
datetime_format = %Y-%m-%d %H:%M:%S,%f
file = /var/log/cfn-init-cmd.log

[yum]
log_group_name = <%= node['bonusbits_base']['cloudwatch_logs']['logs_group_name'] %>
log_stream_name = <%= "#{node['ec2']['instance_id']}-yum" %>
datetime_format = %b %d %H:%M:%S
file = /var/log/yum.log

[cron]
log_group_name = <%= node['bonusbits_base']['cloudwatch_logs']['logs_group_name'] %>
log_stream_name = <%= "#{node['ec2']['instance_id']}-cron" %>
datetime_format = %b %d %H:%M:%S
file = /var/log/cron

[chef-client]
log_group_name = <%= node['bonusbits_base']['cloudwatch_logs']['logs_group_name'] %>
log_stream_name = <%= "#{node['ec2']['instance_id']}-chef-client" %>
datetime_format = [%Y-%m-%dT%H:%M:%S-%z]
file = /var/log/chef-client.log
<% node['bonusbits_base']['cloudwatch_logs']['additional_logs'].each do |content| %>
<%= content %>
<% end %>
3 changes: 3 additions & 0 deletions test/node/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,6 @@
role_path '/opt/chef-repo/roles'
chef_server_url 'http://127.0.0.1:8889'
encrypted_data_bag_secret '/opt/chef-repo/data_bags/encrypted_data_bag_secret'
log_level :info
log_location '/var/log/chef-client.log'
verify_api_cert false

0 comments on commit 150dd2b

Please sign in to comment.