This is an Ansible role that installs and enables the Amazon CloudWatch Agent systemd service.
Note that for an EC2 instance to successfully run the CloudWatch Agent, it must be started with an instance role that includes the "CloudWatchAgentServerPolicy" policy. See here for more details.
See here for details on configuring the Amazon CloudWatch Agent.
Note that this Ansible role makes use of the json_patch
Ansible
module, which is
proposed for inclusion into the main Ansible project. (For more
information about what JSON Patch is, see
here.) A copy of the relevant piece of
Python code from that repository is included in the library
directory, so there is no extra action required by the user.
None.
Variable | Description | Default | Required |
---|---|---|---|
cloudwatch_agent_log_group_base_name | The base name to use for all the log groups defined in the CloudWatch configuration file. Other values will be appended to the base name to create the final values as appropriate. | /instance-logs |
No |
None.
This role can be installed via the command:
ansible-galaxy install --role-file path/to/requirements.yml
where requirements.yml
looks like:
---
- name: cloudwatch_agent
src: https://github.com/cisagov/ansible-role-cloudwatch-agent
and may contain other roles as well.
For more information about installing Ansible roles via a YAML file,
please see the ansible-galaxy
documentation.
Here's how to use it in a playbook:
- hosts: ec2
become: true
become_method: sudo
tasks:
- name: Install AWS CloudWatch agent
ansible.builtin.include_role:
name: cloudwatch_agent
We welcome contributions! Please see CONTRIBUTING.md
for
details.
This project is in the worldwide public domain.
This project is in the public domain within the United States, and copyright and related rights in the work worldwide are waived through the CC0 1.0 Universal public domain dedication.
All contributions to this project will be released under the CC0 dedication. By submitting a pull request, you are agreeing to comply with this waiver of copyright interest.
Shane Frasier - [email protected]