mirror of
https://bitbucket.org/atlassian/dc-deployments-automation.git
synced 2025-12-14 00:43:06 -06:00
use collections; use FQCN for all tasks
This commit is contained in:
@@ -1,14 +1,14 @@
|
||||
---
|
||||
|
||||
- name: Enable CloudWatch Agent
|
||||
systemd:
|
||||
ansible.builtin.systemd:
|
||||
name: "amazon-cloudwatch-agent.service"
|
||||
daemon_reload: true
|
||||
enabled: true
|
||||
when: atl_aws_agent_restart
|
||||
|
||||
- name: Restart CloudWatch Agent
|
||||
systemd:
|
||||
ansible.builtin.systemd:
|
||||
name: "amazon-cloudwatch-agent.service"
|
||||
enabled: true
|
||||
state: restarted
|
||||
|
||||
@@ -1,18 +1,22 @@
|
||||
---
|
||||
|
||||
- name: Install AWS support packages
|
||||
yum:
|
||||
ansible.builtin.yum:
|
||||
name:
|
||||
- amazon-efs-utils
|
||||
- amazon-ssm-agent
|
||||
- awscli
|
||||
- git
|
||||
- ec2-utils
|
||||
vars:
|
||||
ansible_python_interpreter: /usr/bin/python2
|
||||
|
||||
- name: Install CloudWatch Agent
|
||||
yum:
|
||||
ansible.builtin.yum:
|
||||
name:
|
||||
- "{{ aws_cloudwatch_agent_rpm }}"
|
||||
when: atl_aws_enable_cloudwatch is defined and atl_aws_enable_cloudwatch
|
||||
notify:
|
||||
- Enable CloudWatch Agent
|
||||
vars:
|
||||
ansible_python_interpreter: /usr/bin/python2
|
||||
|
||||
@@ -1,20 +1,20 @@
|
||||
---
|
||||
|
||||
- name: Fetch local EC2 metadata
|
||||
ec2_metadata_facts:
|
||||
amazon.aws.ec2_metadata_facts:
|
||||
tags:
|
||||
- notest
|
||||
|
||||
- name: Install distro-specific prerequisites
|
||||
include_tasks: "{{ ansible_distribution|lower }}.yml"
|
||||
ansible.builtin.include_tasks: "{{ ansible_distribution|lower }}.yml"
|
||||
|
||||
- name: Use EC2 instance ID for cluster node ID
|
||||
set_fact:
|
||||
ansible.builtin.set_fact:
|
||||
atl_cluster_node_id: "{{ ansible_ec2_instance_id }}"
|
||||
atl_local_ipv4: "{{ ansible_ec2_local_ipv4 | default(ansible_default_ipv4.address) }}"
|
||||
|
||||
- name: Generate CloudWatch config
|
||||
template:
|
||||
ansible.builtin.template:
|
||||
src: "amazon-cloudwatch-agent.json.j2"
|
||||
dest: "/opt/aws/amazon-cloudwatch-agent/etc/amazon-cloudwatch-agent.json"
|
||||
owner: root
|
||||
@@ -25,7 +25,7 @@
|
||||
- Restart CloudWatch Agent
|
||||
|
||||
- name: Store some metadata about this run
|
||||
include_tasks: "write-tags.yml"
|
||||
ansible.builtin.include_tasks: "write-tags.yml"
|
||||
|
||||
- name: Initiate the startup of any new AWS services now
|
||||
meta: flush_handlers
|
||||
ansible.builtin.meta: flush_handlers
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
---
|
||||
|
||||
- name: Retrieve all available EC2 tags
|
||||
ec2_tag:
|
||||
amazon.aws.ec2_tag:
|
||||
region: "{{ ansible_ec2_placement_region }}"
|
||||
resource: "{{ ansible_ec2_instance_id }}"
|
||||
state: list
|
||||
@@ -11,18 +11,18 @@
|
||||
- notest
|
||||
|
||||
- name: Retrieve autoscaling group
|
||||
set_fact:
|
||||
ansible.builtin.set_fact:
|
||||
ec2_autoscaling_group: "{{ ec2_instance_tags.tags['aws:autoscaling:groupName'] | default('') }}"
|
||||
|
||||
- block:
|
||||
# No existing timestamp, so this is a first run. Persist some metadata into the ASG.
|
||||
- name: Fetch the git revision for this repo
|
||||
command:
|
||||
ansible.builtin.command:
|
||||
cmd: git rev-parse HEAD
|
||||
register: git_out
|
||||
|
||||
- name: Setup the new ASG tags
|
||||
set_fact:
|
||||
ansible.builtin.set_fact:
|
||||
deployment_firstrun_meta:
|
||||
- ResourceType: "auto-scaling-group"
|
||||
ResourceId: "{{ ec2_autoscaling_group }}"
|
||||
@@ -41,14 +41,14 @@
|
||||
# ignore errors as it's possible we don't have the permissions,
|
||||
# and we can't check up-front.
|
||||
- name: Set the first-run tags on the ASG ("FAIL" is not critical)
|
||||
command: "aws autoscaling
|
||||
ansible.builtin.command: "aws autoscaling
|
||||
create-or-update-tags
|
||||
--region {{ ansible_ec2_placement_region }}
|
||||
--tags '{{ deployment_firstrun_meta | to_json }}'"
|
||||
ignore_errors: true
|
||||
|
||||
- name: Set the tags on the local instance ("FAIL" is not critical)
|
||||
ec2_tag:
|
||||
amazon.aws.ec2_tag:
|
||||
region: "{{ ansible_ec2_placement_region }}"
|
||||
resource: "{{ ansible_ec2_instance_id }}"
|
||||
tags:
|
||||
|
||||
Reference in New Issue
Block a user