DCD-224: Add fetching of EC2 metadata and generation of EFS mount from it.

This commit is contained in:
Steve Smith
2019-04-01 15:38:26 +11:00
parent 84cb4ec9ae
commit 54baed6cca
9 changed files with 42 additions and 1 deletions

2
ansible.cfg Normal file
View File

@@ -0,0 +1,2 @@
[default]
retry_files_enabled = False

View File

@@ -9,3 +9,4 @@
- aws_linux2_common
- aws_linux2_product_common
- product_base
- aws_efs_config

View File

@@ -13,4 +13,3 @@ source $ENV_FILE
set +a
ansible-playbook -v -i $INV $PLAYBOOK

View File

@@ -2,3 +2,9 @@
java_version: "1.8.0"
postgres_version: "9.6"
git_version: "2.14.4"
atl_shared_mountpoint: "/media/atl"
# The following are imports from the environment. These are generally
# set in /etc/atl by the CloudFormation template and sourced before
# Ansible is run.
atl_efs_id: "{{ lookup('env', 'ATL_EFS_ID') }}"

View File

@@ -0,0 +1,2 @@
---
efs_target: "{{ ansible_ec2_placement_availability_zone }}.{{ atl_efs_id }}.efs.{{ ansible_ec2_placement_region }}.amazonaws.com"

View File

@@ -0,0 +1,3 @@
---
dependencies:
- aws_metadata

View File

@@ -0,0 +1,13 @@
---
- name: Enable mountpoint in fstab
# lineinfile:
# path: "/etc/fstab"
# line: "{{ efs_target }}:/ /media/atl nfs4 rw,vers=4.1,rsize=1048576,wsize=1048576,hard,timeo=600,retrans=2 0 0"
# notify: mount_all
mount:
path: "{{ atl_shared_mountpoint }}"
src: "{{ efs_target }}:/"
fstype: nfs4
opts: "rw,vers=4.1,rsize=1048576,wsize=1048576,hard,timeo=600,retrans=2"
state: mounted

View File

@@ -0,0 +1,8 @@
---
# 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:

View File

@@ -4,3 +4,10 @@
user:
name: "{{ product_user }}"
comment: "Product runtime user"
- name: Create mountpoint
file:
state: directory
path: "{{ atl_shared_mount }}"
owner: "{{ product_user }}"
mode: 0755