Skip to content

Commit 8e2baee

Browse files
Merge branch 'master' into gauntlt
2 parents 45b0716 + 819d47e commit 8e2baee

File tree

12 files changed

+235
-1
lines changed

12 files changed

+235
-1
lines changed

ansible/bakery.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,14 @@
33

44
# Thanks https://www.tricksofthetrades.net/2017/10/02/ansible-local-playbooks/ for
55
# the trick on installing locally using "hosts: 127.0.0.1" and "connection:local"
6+
7+
- name: Install CloudWatch Agent
8+
hosts: 127.0.0.1
9+
connection: local
10+
become: yes
11+
roles:
12+
- cloudwatch-agent
13+
614
- name: Install New Relic Infrastructure
715
hosts: 127.0.0.1
816
connection: local
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
Role Name
2+
=========
3+
4+
A brief description of the role goes here.
5+
6+
Requirements
7+
------------
8+
9+
Any pre-requisites that may not be covered by Ansible itself or the role should be mentioned here. For instance, if the role uses the EC2 module, it may be a good idea to mention in this section that the boto package is required.
10+
11+
Role Variables
12+
--------------
13+
14+
A description of the settable variables for this role should go here, including any variables that are in defaults/main.yml, vars/main.yml, and any variables that can/should be set via parameters to the role. Any variables that are read from other roles and/or the global scope (ie. hostvars, group vars, etc.) should be mentioned here as well.
15+
16+
Dependencies
17+
------------
18+
19+
A list of other roles hosted on Galaxy should go here, plus any details in regards to parameters that may need to be set for other roles, or variables that are used from other roles.
20+
21+
Example Playbook
22+
----------------
23+
24+
Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too:
25+
26+
- hosts: servers
27+
roles:
28+
- { role: username.rolename, x: 42 }
29+
30+
License
31+
-------
32+
33+
BSD
34+
35+
Author Information
36+
------------------
37+
38+
An optional section for the role authors to include contact information, or a website (HTML is not allowed).
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
---
2+
# defaults file for cloudwatch-agent
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
{
2+
"agent": {
3+
"metrics_collection_interval": 60,
4+
"run_as_user": "root"
5+
},
6+
"logs": {
7+
"logs_collected": {
8+
"files": {
9+
"collect_list": [
10+
{
11+
"file_path": "/var/log/boot.log",
12+
"log_group_name": "syslog",
13+
"log_stream_name": "{instance_id}"
14+
},
15+
{
16+
"file_path": "/var/log/cron",
17+
"log_group_name": "syslog",
18+
"log_stream_name": "{instance_id}"
19+
},
20+
{
21+
"file_path": "/var/log/messages",
22+
"log_group_name": "syslog",
23+
"log_stream_name": "{instance_id}"
24+
},
25+
{
26+
"file_path": "/var/log/dmesg",
27+
"log_group_name": "syslog",
28+
"log_stream_name": "{instance_id}"
29+
},
30+
{
31+
"file_path": "/var/log/secure",
32+
"log_group_name": "syslog",
33+
"log_stream_name": "{instance_id}"
34+
},
35+
{
36+
"file_path": "/var/log/spooler",
37+
"log_group_name": "syslog",
38+
"log_stream_name": "{instance_id}"
39+
},
40+
{
41+
"file_path": "/var/log/maillog",
42+
"log_group_name": "syslog",
43+
"log_stream_name": "{instance_id}"
44+
},
45+
{
46+
"file_path": "/var/log/yum.log",
47+
"log_group_name": "package-updates",
48+
"log_stream_name": "{instance_id}"
49+
},
50+
{
51+
"file_path": "/var/log/audit/audit.log",
52+
"log_group_name": "selinux",
53+
"log_stream_name": "{instance_id}"
54+
},
55+
{
56+
"file_path": "/var/log/nginx/access.log",
57+
"log_group_name": "nginx-access",
58+
"log_stream_name": "{instance_id}"
59+
},
60+
{
61+
"file_path": "/var/log/nginx/error.log",
62+
"log_group_name": "nginx-error",
63+
"log_stream_name": "{instance_id}"
64+
}
65+
]
66+
}
67+
}
68+
},
69+
"metrics": {
70+
"append_dimensions": {
71+
"AutoScalingGroupName": "${aws:AutoScalingGroupName}",
72+
"ImageId": "${aws:ImageId}",
73+
"InstanceId": "${aws:InstanceId}",
74+
"InstanceType": "${aws:InstanceType}"
75+
},
76+
"metrics_collected": {
77+
"mem": {
78+
"measurement": [
79+
"mem_used_percent"
80+
],
81+
"metrics_collection_interval": 60
82+
},
83+
"statsd": {
84+
"metrics_aggregation_interval": 60,
85+
"metrics_collection_interval": 10,
86+
"service_address": ":8125"
87+
},
88+
"swap": {
89+
"measurement": [
90+
"swap_used_percent"
91+
],
92+
"metrics_collection_interval": 60
93+
}
94+
}
95+
}
96+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
---
2+
# handlers file for cloudwatch-agent
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
galaxy_info:
2+
author: your name
3+
description: your description
4+
company: your company (optional)
5+
6+
# If the issue tracker for your role is not on github, uncomment the
7+
# next line and provide a value
8+
# issue_tracker_url: http://example.com/issue/tracker
9+
10+
# Choose a valid license ID from https://spdx.org - some suggested licenses:
11+
# - BSD-3-Clause (default)
12+
# - MIT
13+
# - GPL-2.0-or-later
14+
# - GPL-3.0-only
15+
# - Apache-2.0
16+
# - CC-BY-4.0
17+
license: license (GPL-2.0-or-later, MIT, etc)
18+
19+
min_ansible_version: 2.4
20+
21+
# If this a Container Enabled role, provide the minimum Ansible Container version.
22+
# min_ansible_container_version:
23+
24+
#
25+
# Provide a list of supported platforms, and for each platform a list of versions.
26+
# If you don't wish to enumerate all versions for a particular platform, use 'all'.
27+
# To view available platforms and versions (or releases), visit:
28+
# https://galaxy.ansible.com/api/v1/platforms/
29+
#
30+
# platforms:
31+
# - name: Fedora
32+
# versions:
33+
# - all
34+
# - 25
35+
# - name: SomePlatform
36+
# versions:
37+
# - all
38+
# - 1.0
39+
# - 7
40+
# - 99.99
41+
42+
galaxy_tags: []
43+
# List tags for your role here, one per line. A tag is a keyword that describes
44+
# and categorizes the role. Users find roles by searching for tags. Be sure to
45+
# remove the '[]' above, if you add tags to this list.
46+
#
47+
# NOTE: A tag is limited to a single word comprised of alphanumeric characters.
48+
# Maximum 20 tags per role.
49+
50+
dependencies: []
51+
# List your role dependencies here, one per line. Be sure to remove the '[]' above,
52+
# if you add dependencies to this list.
53+
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
---
2+
# tasks file for cloudwatch-agent
3+
4+
- name: Ensure cloudwatch agent is present
5+
package: name={{item}} state=present
6+
with_items:
7+
- https://s3.amazonaws.com/amazoncloudwatch-agent/centos/amd64/latest/amazon-cloudwatch-agent.rpm
8+
tags: cloudwatch
9+
10+
- name: Copy cloudwatch config file
11+
copy:
12+
src: config.json
13+
dest: /opt/aws/amazon-cloudwatch-agent/etc/amazon-cloudwatch-agent.json
14+
tags: cloudwatch
15+
16+
- name: Enable cloudwatch-agent, as it should start off disabled
17+
service:
18+
name: amazon-cloudwatch-agent
19+
enabled: yes
20+
state: stopped
21+
tags: cloudwatch
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
localhost
2+
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
- hosts: localhost
3+
remote_user: root
4+
roles:
5+
- cloudwatch-agent
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
---
2+
# vars file for cloudwatch-agent

0 commit comments

Comments
 (0)