-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
DSOS-2093: cloudwatch-agent plus some general improvements (#364)
* add OL8.5 group vars * simplify cloudwatch agent installation * Fix for RHEL6 * Update README * readme * don't install cloudwatch agent in startup * update amazon-cloudwatch-agent * fix
- Loading branch information
1 parent
98188f7
commit 88d682c
Showing
16 changed files
with
148 additions
and
105 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
--- | ||
ansible_python_interpreter: python3.9 | ||
|
||
server_type_roles_list: | ||
- autoscale-group-hooks | ||
- get-ec2-facts | ||
- set-ec2-hostname | ||
- domain-search | ||
- ansible-script | ||
- autoscale-group-hooks-state | ||
|
||
roles_list: "{{ (ami_roles_list | default([]) | difference(server_type_roles_list | default([]))) + (server_type_roles_list | default([])) }}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# https://galaxy.ansible.com broken on RHEL6 for some collections with following error: | ||
# [WARNING]: Skipping Galaxy server https://galaxy.ansible.com/api/. Got an unexpected error when getting available versions of collection amazon.aws: | ||
# '/api/v3/plugin/ansible/content/published/collections/index/amazon/aws/versions/' | ||
# ERROR! Unexpected Exception, this is probably a bug: '/api/v3/plugin/ansible/content/published/collections/index/amazon/aws/versions/' | ||
|
||
# from Galaxy | ||
roles: | ||
|
||
collections: | ||
- name: community.general | ||
source: https://old-galaxy.ansible.com | ||
version: 6.3.0 | ||
- name: amazon.aws | ||
source: https://old-galaxy.ansible.com | ||
version: 3.2.0 | ||
- name: community.aws | ||
source: https://old-galaxy.ansible.com | ||
version: 3.2.1 | ||
- name: ansible.posix | ||
source: https://galaxy.ansible.com | ||
version: 1.4.0 | ||
- name: ansible.windows | ||
source: https://galaxy.ansible.com | ||
version: 1.13.0 | ||
- name: community.windows | ||
source: https://galaxy.ansible.com | ||
version: 1.12.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
amazon_cloudwatch_agent_config_name: linux.json.j2 | ||
amazon_cloudwatch_agent_gpg: https://amazoncloudwatch-agent-eu-west-2.s3.eu-west-2.amazonaws.com/assets/amazon-cloudwatch-agent.gpg | ||
amazon_cloudwatch_agent_package: https://amazoncloudwatch-agent-eu-west-2.s3.eu-west-2.amazonaws.com/redhat/amd64/latest/amazon-cloudwatch-agent.rpm | ||
amazon_cloudwatch_agent_config_file: amazon-cloudwatch-agent.json | ||
amazon_cloudwatch_agent_config_path: /opt/aws/amazon-cloudwatch-agent/etc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
- name: restart amazon-cloudwatch-agent | ||
ansible.builtin.service: | ||
name: amazon-cloudwatch-agent | ||
state: restarted |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,13 @@ | ||
--- | ||
- name: check if amazon-cloudwatch-agent installed | ||
ansible.builtin.shell: | | ||
check_installed() { | ||
check="$(amazon-cloudwatch-agent-ctl -m ec2 -a status)" | ||
if [[ $check ]] | ||
then | ||
return 0 | ||
else | ||
return 1 | ||
fi | ||
} | ||
check_installed | ||
ignore_errors: true | ||
register: agent_installed | ||
# Not bothering to install RPM key as RPM doesn't seem to be signed | ||
# Plus it probably won't work if selinux enabled | ||
# - name: Import amazon cloudwatch agent RPM key | ||
# ansible.builtin.rpm_key: | ||
# state: present | ||
# key: "{{ amazon_cloudwatch_agent_gpg }}" | ||
|
||
- name: Install amazon-cloudwatch-agent | ||
ansible.builtin.yum: | ||
name: "{{ amazon_cloudwatch_agent_package }}" | ||
state: present | ||
disable_gpg_check: true | ||
when: agent_installed.rc == 1 and ansible_distribution_major_version != '6' | ||
|
||
- name: Install amazon-cloudwatch-agent on Rhel 6 | ||
ansible.builtin.shell: | | ||
wget https://s3.amazonaws.com/amazoncloudwatch-agent/redhat/amd64/latest/amazon-cloudwatch-agent.rpm | ||
rpm -U ./amazon-cloudwatch-agent.rpm | ||
become: true | ||
when: agent_installed.rc == 1 and ansible_distribution_major_version == '6' | ||
disable_gpg_check: true # RPM doesn't appear to be signed even through GPG key provided |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,27 @@ | ||
--- | ||
- import_tasks: "install.yml" | ||
tags: | ||
- amazon-cloudwatch-agent-install | ||
- ec2provision | ||
- ec2patch | ||
when: ansible_distribution in ['RedHat', 'OracleLinux'] | ||
|
||
- import_tasks: "configure.yml" | ||
tags: | ||
- amazon-cloudwatch-agent-configure | ||
- ec2provision | ||
- ec2patch | ||
when: ansible_distribution in ['RedHat', 'OracleLinux'] | ||
|
||
# Ensure any restarts done prior to start | ||
- name: Flush handlers | ||
meta: flush_handlers | ||
tags: | ||
- always | ||
|
||
- import_tasks: "start.yml" | ||
tags: | ||
- amazon-cloudwatch-agent-start | ||
- ec2provision | ||
- ec2patch | ||
when: ansible_distribution in ['RedHat', 'OracleLinux'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,6 @@ | ||
--- | ||
# covers cloudwatch agent start for linux (common) | ||
- name: Start amazon-cloudwatch-agent service | ||
ansible.builtin.shell: | | ||
/opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -a fetch-config -m ec2 -s -c file:"{{ amazon_cloudwatch_agent_config_path }}/{{ amazon_cloudwatch_agent_config_file }}" | ||
# additional settings for EC2 instances if they exist | ||
- name: Append settings for amazon-cloudwatch-agent for other EC2 instances | ||
ansible.builtin.shell: | | ||
/opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -a append-config -m ec2 -s -c file:"{{ amazon_cloudwatch_agent_config_path }}/{{ item }}.json" | ||
loop: "{{ cloudwatch_agent_configs|replace('-', '_') }}" | ||
loop_control: | ||
label: item | ||
when: cloudwatch_agent_configs is defined # currently none defined | ||
notify: restart amazon-cloudwatch-agent | ||
- name: Start and enable amazon-cloudwatch-agent | ||
ansible.builtin.service: | ||
name: amazon-cloudwatch-agent | ||
state: started | ||
enabled: yes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.