Skip to content

Commit 150dd2b

Browse files
committed
2.1.7 - Read Changelog
1 parent 13f5f69 commit 150dd2b

File tree

8 files changed

+89
-91
lines changed

8 files changed

+89
-91
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
## CHANGE LOG
22

3+
## 2.1.7 - 04/15/2017 - Levon Becker
4+
* Switch Dockerfile to copy client.rb instead of creating it.
5+
* Added restart notification to /etc/awslogs/awscli.conf template resource
6+
* Added chef-client logging to client.rb for Docker
7+
* Added Deployment section to nodeinfo
8+
* Improved node content logic to dry up some code
9+
310
## 2.1.6 - 04/15/2017 - Levon Becker
411
* Fixed CloudWatch Logs Config order so default with us-east-1 no longer left
512
* Added CloudWatch Logs /var/log/chef-client.log stream

Dockerfile

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ ARG chef_role=base
99
ARG chef_environment=bonusbits_base
1010
ARG chef_config_path=/opt/chef-repo
1111

12-
LABEL version="2.1.6" \
12+
LABEL version="2.1.7" \
1313
description="Amazon Linux Image built from bonusbits_base cookbook." \
1414
github="https://github.com/bonusbits/bonusbits_base" \
1515
website="https://www.bonusbits.com"
@@ -34,18 +34,7 @@ COPY . cookbooks/${cookbook_name}/
3434
COPY test/roles/* roles/
3535
COPY test/environments/* environments/
3636
COPY test/data_bags/* data_bags/
37-
#COPY test/node/client.rb client.rb
38-
RUN printf $"node_name \'docker_node\'\n\
39-
checksum_path \'${chef_config_path}/checksums\'\n\
40-
file_cache_path \'${chef_config_path}/cache\'\n\
41-
file_backup_path \'${chef_config_path}/backup\'\n\
42-
cookbook_path \'${chef_config_path}/cookbooks\'\n\
43-
data_bag_path \'${chef_config_path}/data_bags\'\n\
44-
environment_path \'${chef_config_path}/environments\'\n\
45-
role_path \'${chef_config_path}/roles\'\n\
46-
chef_server_url \'http://127.0.0.1:8889\'\n\
47-
encrypted_data_bag_secret \'${chef_config_path}/data_bags/encrypted_data_bag_secret\'\n"\
48-
> client.rb
37+
COPY test/node/client.rb ${chef_config_path}/client.rb
4938

5039
# Download Dependant Cookbooks
5140
WORKDIR ${chef_config_path}/cookbooks/${cookbook_name}

attributes/cloudwatch_logs.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
default['bonusbits_base']['cloudwatch_logs']['configure'] = true
2-
default['bonusbits_base']['cloudwatch_logs']['deploy_logs_conf'] = true
32
default['bonusbits_base']['cloudwatch_logs']['logs_group_name'] = 'kitchen-bonusbits-base'
3+
# default['bonusbits_base']['cloudwatch_logs']['additional_logs'] = nil
4+
# additional_logs = node['bonusbits_base']['cloudwatch_logs']['additional_logs'].nil? ? false : true
45

56
# Debug
67
message_list = [
78
'',
89
'** CloudWatch Logs **',
910
"Configure (#{node['bonusbits_base']['cloudwatch_logs']['configure']})",
1011
"Log Group Name (#{node['bonusbits_base']['cloudwatch_logs']['logs_group_name']})"
12+
# "Has Additional Logs (#{additional_logs})"
1113
]
1214
message_list.each do |message|
1315
Chef::Log.warn(message)

attributes/node_info.rb

Lines changed: 39 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -14,59 +14,45 @@
1414
node_info['configure'] = true
1515

1616
node_info['content'] =
17-
if node['bonusbits_base']['aws']['inside']
18-
[
19-
'-- NETWORK --',
20-
"IP Address: (#{node['ipaddress']})",
21-
"Hostname: (#{node['hostname']})",
22-
"FQDN: (#{node['fqdn']})",
23-
'',
24-
'-- AWS --',
25-
"Instance ID: (#{node['ec2']['instance_id']})",
26-
"Region: (#{node['ec2']['placement_availability_zone'].slice(0..-2)})",
27-
"Availability Zone: (#{node['ec2']['placement_availability_zone']})",
28-
"AMI ID: (#{node['ec2']['ami_id']})",
29-
'',
30-
'-- PLATFORM --',
31-
"OS: (#{node['os']})",
32-
"Platform: (#{node['platform']})",
33-
"Platform Version: (#{node['platform_version']})",
34-
"Platform Family: (#{node['platform_family']})",
35-
'',
36-
'-- HARDWARE --',
37-
"CPU Count: (#{node['cpu']['total']})",
38-
"Memory: (#{memory_in_megabytes}MB)",
39-
'',
40-
'-- CHEF --',
41-
"Detected Environment: (#{node.run_state['detected_environment']})",
42-
"Chef Environment: (#{node.environment})",
43-
"Chef Roles: (#{node['roles']})",
44-
"Chef Recipes: (#{node['recipes']})"
45-
]
46-
else
47-
[
48-
'-- NETWORK --',
49-
"IP Address: (#{node['ipaddress']})",
50-
"Hostname: (#{node['hostname']})",
51-
"FQDN: (#{node['fqdn']})",
52-
'',
53-
'-- PLATFORM --',
54-
"OS: (#{node['os']})",
55-
"Platform: (#{node['platform']})",
56-
"Platform Version: (#{node['platform_version']})",
57-
"Platform Family: (#{node['platform_family']})",
58-
'',
59-
'-- HARDWARE --',
60-
"CPU Count: (#{node['cpu']['total']})",
61-
"Memory: (#{memory_in_megabytes}MB)",
62-
'',
63-
'-- CHEF --',
64-
"Detected Environment: (#{node.run_state['detected_environment']})",
65-
"Chef Environment: (#{node.environment})",
66-
"Chef Roles: (#{node['roles']})",
67-
"Chef Recipes: (#{node['recipes']})"
68-
]
69-
end
17+
[
18+
'-- DEPLOYMENT --',
19+
"Environment: (#{run_state['detected_environment']})",
20+
"Type: (#{node['bonusbits_base']['deployment_type']})",
21+
"Location: (#{node['bonusbits_base']['deployment_location']})",
22+
"Method : (#{node['bonusbits_base']['deployment_method']})",
23+
'',
24+
'-- NETWORK --',
25+
"IP Address: (#{node['ipaddress']})",
26+
"Hostname: (#{node['hostname']})",
27+
"FQDN: (#{node['fqdn']})",
28+
'',
29+
'-- PLATFORM --',
30+
"OS: (#{node['os']})",
31+
"Platform: (#{node['platform']})",
32+
"Platform Version: (#{node['platform_version']})",
33+
"Platform Family: (#{node['platform_family']})",
34+
'',
35+
'-- HARDWARE --',
36+
"CPU Count: (#{node['cpu']['total']})",
37+
"Memory: (#{memory_in_megabytes}MB)",
38+
'',
39+
'-- CHEF --',
40+
"Node Name: (#{node.name})",
41+
"Environment: (#{node.environment})",
42+
"Roles: (#{node['roles']})",
43+
"Recipes: (#{node['recipes']})"
44+
]
45+
46+
if node['bonusbits_base']['aws']['inside']
47+
node_info['content'].concat [
48+
'',
49+
'-- AWS --',
50+
"Instance ID: (#{node['ec2']['instance_id']})",
51+
"Region: (#{node['ec2']['placement_availability_zone'].slice(0..-2)})",
52+
"Availability Zone: (#{node['ec2']['placement_availability_zone']})",
53+
"AMI ID: (#{node['ec2']['ami_id']})"
54+
]
55+
end
7056
end
7157

7258
# Debug

metadata.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
license 'MIT'
55
description 'Foundation Wrapper Cookbook for all Nodes'
66
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
7-
version '2.1.6'
7+
version '2.1.7'
88
chef_version '~> 12.5' if respond_to?(:chef_version)
99
source_url 'https://github.com/bonusbits/bonusbits_base'
1010
issues_url 'https://github.com/bonusbits/bonusbits_base/issues'

recipes/cloudwatch_logs.rb

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
inside_aws = node['bonusbits_base']['aws']['inside']
2+
13
case node['os']
24
when 'linux'
35
case node['platform']
@@ -62,7 +64,7 @@
6264
owner 'root'
6365
group 'root'
6466
mode '0755'
65-
notifies :restart, 'service[awslogs]', :delayed
67+
notifies :restart, 'service[awslogs]', :delayed if inside_aws
6668
end
6769
else
6870
return
@@ -74,6 +76,7 @@
7476
owner 'root'
7577
group 'root'
7678
mode '0644'
79+
notifies :restart, 'service[awslogs]', :delayed if inside_aws
7780
end
7881

7982
# Deploy AWS CloudWatch Logs Proxy Config
@@ -82,7 +85,7 @@
8285
owner 'root'
8386
group 'root'
8487
mode '0644'
85-
notifies :restart, 'service[awslogs]', :delayed
88+
notifies :restart, 'service[awslogs]', :delayed if inside_aws
8689
only_if { node['bonusbits_base']['proxy']['configure'] }
8790
end
8891

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

101102
# Define Service
102103
service 'awslogs' do
103104
service_name 'awslogs'
104-
action [:enable, :start]
105+
action [:enable]
105106
only_if { node['bonusbits_base']['aws']['inside'] }
106107
end
107108
when 'windows'

templates/default/cloudwatch_logs/awslogs.conf.erb

Lines changed: 27 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,30 @@
22
state_file = /var/lib/awslogs/agent-state
33
use_gzip_http_content_encoding = true
44

5+
[messages]
6+
log_group_name = <%= node['bonusbits_base']['cloudwatch_logs']['logs_group_name'] %>
7+
log_stream_name = <%= "#{node['ec2']['instance_id']}-messages" %>
8+
datetime_format = %b %d %H:%M:%S
9+
file = /var/log/messages
10+
11+
[yum]
12+
log_group_name = <%= node['bonusbits_base']['cloudwatch_logs']['logs_group_name'] %>
13+
log_stream_name = <%= "#{node['ec2']['instance_id']}-yum" %>
14+
datetime_format = %b %d %H:%M:%S
15+
file = /var/log/yum.log
16+
17+
[cron]
18+
log_group_name = <%= node['bonusbits_base']['cloudwatch_logs']['logs_group_name'] %>
19+
log_stream_name = <%= "#{node['ec2']['instance_id']}-cron" %>
20+
datetime_format = %b %d %H:%M:%S
21+
file = /var/log/cron
22+
23+
[chef-client]
24+
log_group_name = <%= node['bonusbits_base']['cloudwatch_logs']['logs_group_name'] %>
25+
log_stream_name = <%= "#{node['ec2']['instance_id']}-chef-client" %>
26+
datetime_format = [%Y-%m-%dT%H:%M:%S-%z]
27+
file = /var/log/chef-client.log
28+
529
[cloud-init]
630
log_group_name = <%= node['bonusbits_base']['cloudwatch_logs']['logs_group_name'] %>
731
log_stream_name = <%= "#{node['ec2']['instance_id']}-cloud-init" %>
@@ -25,20 +49,6 @@ log_stream_name = <%= "#{node['ec2']['instance_id']}-cfn-init-cmd" %>
2549
datetime_format = %Y-%m-%d %H:%M:%S,%f
2650
file = /var/log/cfn-init-cmd.log
2751

28-
[yum]
29-
log_group_name = <%= node['bonusbits_base']['cloudwatch_logs']['logs_group_name'] %>
30-
log_stream_name = <%= "#{node['ec2']['instance_id']}-yum" %>
31-
datetime_format = %b %d %H:%M:%S
32-
file = /var/log/yum.log
33-
34-
[cron]
35-
log_group_name = <%= node['bonusbits_base']['cloudwatch_logs']['logs_group_name'] %>
36-
log_stream_name = <%= "#{node['ec2']['instance_id']}-cron" %>
37-
datetime_format = %b %d %H:%M:%S
38-
file = /var/log/cron
39-
40-
[chef-client]
41-
log_group_name = <%= node['bonusbits_base']['cloudwatch_logs']['logs_group_name'] %>
42-
log_stream_name = <%= "#{node['ec2']['instance_id']}-chef-client" %>
43-
datetime_format = [%Y-%m-%dT%H:%M:%S-%z]
44-
file = /var/log/chef-client.log
52+
<% node['bonusbits_base']['cloudwatch_logs']['additional_logs'].each do |content| %>
53+
<%= content %>
54+
<% end %>

test/node/client.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,6 @@
88
role_path '/opt/chef-repo/roles'
99
chef_server_url 'http://127.0.0.1:8889'
1010
encrypted_data_bag_secret '/opt/chef-repo/data_bags/encrypted_data_bag_secret'
11+
log_level :info
12+
log_location '/var/log/chef-client.log'
13+
verify_api_cert false

0 commit comments

Comments
 (0)