From 1651b7b3ee787370dc3093714689a4f67da5cdf4 Mon Sep 17 00:00:00 2001 From: Steve Smith Date: Thu, 11 Apr 2019 12:02:41 +1000 Subject: [PATCH] DCD-224: Move EC2 metadata retrieval to aws_common --- README.md | 4 ++-- roles/aws_common/tasks/amazon.yml | 5 +++++ roles/aws_efs_config/meta/main.yml | 2 +- roles/aws_efs_config/tasks/main.yml | 2 +- roles/aws_metadata/tasks/main.yml | 7 ------- 5 files changed, 9 insertions(+), 11 deletions(-) delete mode 100644 roles/aws_metadata/tasks/main.yml diff --git a/README.md b/README.md index 327c664..1901e47 100644 --- a/README.md +++ b/README.md @@ -8,5 +8,5 @@ ** This is where env-vars should be converted to Ansible vars. It also acts as a required-env list. ** The CF env is usually stored in /etc/atl. The script `bin/ansible-with-atl-env` will run Ansible with that environment set. * Runtime information about the EC2 environment can be injected by depending on - `aws_metadata` in a role's `meta/main.yml`. - + `aws_common` in a role's `meta/main.yml` (or adding it to the playbook before + the requiring role. diff --git a/roles/aws_common/tasks/amazon.yml b/roles/aws_common/tasks/amazon.yml index 4c2aebb..e014724 100644 --- a/roles/aws_common/tasks/amazon.yml +++ b/roles/aws_common/tasks/amazon.yml @@ -6,3 +6,8 @@ - ec2-utils - amazon-ssm-agent - amazon-efs-utils + +- name: Fetch local EC2 metadata + ec2_metadata_facts: + # Guard is mostly for testing + when: ansible_system_vendor == "Amazon EC2" diff --git a/roles/aws_efs_config/meta/main.yml b/roles/aws_efs_config/meta/main.yml index a2ee36a..b0f4ac0 100644 --- a/roles/aws_efs_config/meta/main.yml +++ b/roles/aws_efs_config/meta/main.yml @@ -1,3 +1,3 @@ --- dependencies: - - aws_metadata + - aws_common diff --git a/roles/aws_efs_config/tasks/main.yml b/roles/aws_efs_config/tasks/main.yml index ae1933f..44e7dd9 100644 --- a/roles/aws_efs_config/tasks/main.yml +++ b/roles/aws_efs_config/tasks/main.yml @@ -4,7 +4,7 @@ file: state: directory path: "{{ atl_shared_mountpoint }}" - owner: "{{ product_user }}" + owner: "{{ atl_product_user }}" mode: 0755 - name: Enable mountpoint in fstab diff --git a/roles/aws_metadata/tasks/main.yml b/roles/aws_metadata/tasks/main.yml deleted file mode 100644 index b40b29b..0000000 --- a/roles/aws_metadata/tasks/main.yml +++ /dev/null @@ -1,7 +0,0 @@ ---- - -# This role is primarily intended to be depended on via `meta` by -# roles that need runtime information available. - -- name: Fetch local EC2 metadata - ec2_metadata_facts: