-
Notifications
You must be signed in to change notification settings - Fork 15
Added Efs #53
base: master
Are you sure you want to change the base?
Added Efs #53
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,3 +41,14 @@ asg_additional_security_groups: "{{ asg_additional_security_groups_env | default | |
|
||
|
||
ecs_cluster_name: "{{ cluster_name }}" | ||
|
||
|
||
efs_commands: "sudo mount -t nfs4 -o nfsvers=4.1,rsize=1048576,wsize=1048576,hard,timeo=600,retrans=2 $(curl -s http://169.254.169.254/latest/meta-data/placement/availability-zone){{ efs_instance.efs.mount_point }} data" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this should go in the readme you will create in custom-infrastructure. This is not a core module so the examples shouldn't include extra modules |
||
|
||
|
||
additional_user_data_bootcmd: | | ||
- sudo yum install -y nfs-utils | ||
- sudo mkdir data | ||
- echo "{{ efs_commands }}" | ||
- " {{ efs_commands }} " | ||
- echo after efs |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,7 @@ | |
- /usr/bin/easy_install pip | ||
- /usr/local/bin/pip install --upgrade boto3 boto awscli requests psutil {{ asg_additional_python_pip_packages }} | ||
{{ asg_additional_user_data_bootcmd }} | ||
{{ _efs_additional_bootcmd }} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. efs is not a core module, therefore core modules shouldn't be changed. Instead, leverage the already available |
||
|
||
- name: Set write_files | ||
set_fact: | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
--- | ||
|
||
### This is used to create efs | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this has to go under your There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we don't use "defaults" for custom modules |
||
# An efs needs subnets and a default security group for the vpc | ||
|
||
efs_create: false | ||
efs_name: "myefs" | ||
efs_data_dir: "data" | ||
efs_security_group: [] | ||
|
||
_efs_mount_command: "" | ||
|
||
_efs_additional_bootcmd: | | ||
- sudo yum install -y nfs-utils | ||
- sudo mkdir "{{ efs_data_dir }}" | ||
- echo before efs | ||
- echo "{{ _efs_mount_command }}" | ||
- " {{ _efs_mount_command }} " | ||
- echo after efs | ||
|
||
_efs_no_bootcmd: | | ||
- echo no efs loaded |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Custom files | ||
|
||
Add any custom files here, just like you would for any other role. | ||
An example to look at would be the role aws.ec2-autoscaling-group |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
--- | ||
|
||
- name: Populate efs targets | ||
set_fact: | ||
_efs_targets: "{{ _efs_targets|default([]) + [ {'subnet_id': item, 'security_groups': efs_security_group } ] }}" | ||
with_items: "{{ asg_subnets_env }}" | ||
|
||
- debug: var=_efs_targets | ||
|
||
|
||
# EFS provisioning | ||
- name: Create EFS | ||
efs: | ||
state: present | ||
name: "{{ efs_name }}" | ||
profile: "{{ aws_profile }}" | ||
tags: | ||
Name: "{{ efs_name }}" | ||
Purpose: file-storage | ||
targets: "{{ _efs_targets }} " | ||
register: efs_instance | ||
when: efs_create | ||
|
||
- name: Populate mount command | ||
set_fact: | ||
_efs_mount_command: "sudo mount -t nfs4 -o nfsvers=4.1,rsize=1048576,wsize=1048576,hard,timeo=600,retrans=2 $(curl -s http://169.254.169.254/latest/meta-data/placement/availability-zone){{ efs_instance.efs.mount_point }} {{ efs_data_dir }}" | ||
when: efs_create | ||
|
||
- name: Populate additional command | ||
set_fact: | ||
_efs_additional_bootcmd: "{{ efs_create | ternary(_efs_additional_bootcmd, _efs_no_bootcmd) }}" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
# Make sure to create a file named <service_name>.yml under the tasks directory | ||
- name: "Include infrastructure custom tasks" | ||
include: "{{ item }}" | ||
with_items: "{{ custom_task_files }}" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
--- | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think this is needed now is it? |
||
# custom tasks file for postgres-example | ||
- name: "Include any custom task for your service here. These will be executed before any other template" | ||
debug: | ||
msg: "Hi from: {{ postgres_hello_world }}" | ||
|
||
- name: "Export some result to be used by other tasks" | ||
set_fact: | ||
postgres_custom_label: "This variable is accessible from the other roles now" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Templates | ||
|
||
Any custom templates you might need for your tasks | ||
look at aws.ec2-autoscaling-group for an example |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is not a core module and therefore documentation should be in the custom-instrastructure folder.