Amazon EFS

There are only three tasks needed to create the EFS volumes; as with previous roles, we can use the ansible-galaxy command to create the folder and file structure:

$ ansible-galaxy init roles/efs

Before we add the tasks, we need to add some default variables and a template, so add the following to roles/efs/defaults/main.yml:

efs:  wait: "yes"  wait_time: "1200"

Now, create a file in roles/efs/templates called targets.j2, which should contain:

---efs_targets:{% for item in subnet_efs_ids %}      - subnet_id: "{{ item }}"        security_groups: [ "{{ sg_efs.group_id }}" ]{% endfor %}

As you can see, this template is looping over the subnet_efs_ids variable to create a list of subnet IDs and security groups under the variable name efs_targets ...

Get Learn Ansible now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.