newtonne.cloudwatchagent
Ansible Role: CloudWatch Agent
This role installs and sets up the AWS Unified CloudWatch Agent.
Requirements
- None
Role Variables
Here are the available variables with their default values (check defaults/main.yml for more details):
- For Debian family:
cwa_download_url
:https://s3.amazonaws.com/amazoncloudwatch-agent/ubuntu/amd64/latest
- For RedHat family:
cwa_download_url
:https://s3.amazonaws.com/amazoncloudwatch-agent/redhat/amd64/latest
This is the URL used to download the CloudWatch Agent package.
- Package Name:
- Debian:
cwa_pkg_file
:amazon-cloudwatch-agent.deb
- RedHat:
cwa_pkg_file
:amazon-cloudwatch-agent.rpm
- Debian:
This is the name of the package.
- GPG Signature File:
- Debian:
cwa_sig_file
:amazon-cloudwatch-agent.deb.sig
- RedHat:
cwa_sig_file
:amazon-cloudwatch-agent.rpm.sig
- Debian:
This is the name of the signature file for the package.
cwa_gpg_url
:https://s3.amazonaws.com/amazoncloudwatch-agent/assets
This is the URL for the CloudWatch Agent GPG public key.
cwa_gpg_fingerprint
:"937616F3450B7D806CBD9725D58167303B789C72"
This is the fingerprint of the public key used for verification. Refer to the verification documentation for more info.
cwa_mode
:ec2
This sets the mode for running the agent. Options are ec2
, onPremise
, or auto
.
cwa_logfile
:/opt/aws/amazon-cloudwatch-agent/logs/amazon-cloudwatch-agent.log
This is the log file for the agent's events. Make sure it is specified in cwa_config_map.agent.logfile
if you change it from the default.
cwa_config_dir
:/opt/aws/amazon-cloudwatch-agent/etc
This is where the agent's configuration file will be saved.
cwa_config_map
:metrics: metrics_collected: mem: measurement: - name: mem_used_percent
This is the configuration for the CloudWatch Agent. It will be changed into JSON format and saved to the amazon-cloudwatch-agent.json
file in cwa_config_dir
. For detailed options, see the CloudWatch agent configuration documentation.
Dependencies
- None
Example Playbook
- hosts: servers
vars:
cwa_config_map:
metrics:
metrics_collected:
disk:
measurement:
- name: disk_used_percent
resources:
- /
logs:
logs_collected:
files:
collect_list:
- file_path: /var/log/auth.log
log_group_name: auth
timestamp_format: "%b %d %H:%M:%S"
log_stream_name: "{instance_id}"
roles:
- { role: newtonne.cloudwatchagent }
License
- MIT
Installs and configures the Amazon Unified CloudWatch Agent
ansible-galaxy install newtonne.cloudwatchagent