Skip to content
This repository was archived by the owner on Sep 13, 2019. It is now read-only.

Commit 92e3739

Browse files
Add logrotation and bugfixes
1 parent 13e0cc3 commit 92e3739

File tree

7 files changed

+61
-24
lines changed

7 files changed

+61
-24
lines changed

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,8 @@ include_recipe 'ssm_agent::default'
2121
```
2222

2323
Additionally, the EC2 instance running the service will require specific IAM permissions which may be provided via [Managed Policies](http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/systems-manager-access.html#sysman-configuring-access-policies). However, it's recommended to create a custom IAM policy due to how insecure the default managed policy seems to be.
24+
25+
References
26+
----------
27+
28+
* [github:amazon-ssm-agent](https://github.com/aws/amazon-ssm-agent)

attributes/default.rb

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,15 @@
2929
)
3030

3131
# Checksum of the package
32+
# * Note: This is currently disabled due to the URL be a /latest/
3233
# @since 0.1.0
33-
config['package']['checksum'] = value_for_platform_family(
34-
'rhel' => '',
35-
'debian' => ''
36-
)
34+
config['package']['checksum'] = nil
35+
# value_for_platform_family(
36+
# 'rhel' => '15d8c8e6b2ecef39c37b2bed5ed68f68a9b511ba30d8d4d1f1ba3f49' \
37+
# 'cfc70f0f',
38+
# 'debian' => 'a48ff0126e113ef0d5a534c911b269d172e6ae08003a8bcda9723f' \
39+
# '5052f18e58'
40+
# )
3741

3842
# Name of the agent service
3943
# @since 0.1.0

attributes/ssm_agent-logrotate.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Amazon SSM Agent logrotation
2+
# @since 0.1.0
3+
default['ssm_agent']['logrotate'].tap do |config|
4+
config['rotate'] = 7
5+
config['frequency'] = 'daily'
6+
config['postrotate'] = format(
7+
'service %s restart',
8+
node['ssm_agent']['service']['name']
9+
)
10+
end

metadata.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@
77
issues_url 'https://github.com/JonathanSerafini/chef-ssm_agent/issues'
88
source_url 'https://github.com/JonathanSerafini/chef-ssm_agent'
99
version '0.1.0'
10+
depends 'logrotate'

recipes/default.rb

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,2 @@
1-
# Download the installer
2-
# @since 0.1.0
3-
remote_file 'amazon-ssm-agent' do
4-
path node['ssm_agent']['package']['path']
5-
source node['ssm_agent']['package']['url']
6-
checksum node['ssm_agent']['package']['checksum']
7-
mode 0644
8-
end
9-
10-
# Install the pakage
11-
# @since 0.1.0
12-
package 'amazon-ssm-agent' do
13-
source node['ssm_agent']['package']['path']
14-
end
15-
16-
# Ensure service state
17-
# @since 0.1.0
18-
service node['ssm_agent']['service']['name'] do
19-
action node['ssm_agent']['service']['actions']
20-
end
1+
include_recipe "#{cookbook_name}::install"
2+
include_recipe "#{cookbook_name}::logrotate"

recipes/install.rb

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Download the installer
2+
# @since 0.1.0
3+
remote_file 'amazon-ssm-agent' do
4+
path node['ssm_agent']['package']['path']
5+
source node['ssm_agent']['package']['url']
6+
checksum node['ssm_agent']['package']['checksum']
7+
mode 0644
8+
end
9+
10+
# Install the pakage
11+
# @since 0.1.0
12+
package 'amazon-ssm-agent' do
13+
source node['ssm_agent']['package']['path']
14+
provider value_for_platform_family(
15+
'rhel' => Chef::Provider::Package::Yum,
16+
'debian' => Chef::Provider::Package::Dpkg
17+
)
18+
end
19+
20+
# Ensure service state
21+
# @since 0.1.0
22+
service node['ssm_agent']['service']['name'] do
23+
action node['ssm_agent']['service']['actions']
24+
end

recipes/logrotate.rb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
logrotate_app 'amazon-ssm-agent' do
2+
path %w(
3+
/var/log/amazon/ssm/amazon-ssm-agent.log
4+
/var/log/amazon/ssm/errors.log
5+
)
6+
rotate node['ssm_agent']['logrotate']['rotate']
7+
frequency node['ssm_agent']['logrotate']['frequency']
8+
options node['ssm_agent']['logrotate']['options']
9+
postrotate node['ssm_agent']['logrotate']['postrotate']
10+
template_mode '0644'
11+
end

0 commit comments

Comments
 (0)