Error mounting EFS volume to EC2 instance using ansible facts

338 views
Skip to first unread message

Anuj Dogra

unread,
Sep 17, 2017, 8:35:33 PM9/17/17
to Ansible Project
I have the following tasks in my ansible playbook to register the AZ for an AWS resource:

- name: Get current AZ from AWS.
  uri:
    return_content: yes
  register: aws_current_az

- name: Ensure EFS volume is mounted.
  mount:
    name: "{{ efs_mount_dir }}"
    src: "{{ aws_current_az.content }}.{{ efs_file_system_id }}.efs.{{ aws_region }}.amazonaws.com:/"
    fstype: nfs4
    opts: nfsvers=4.1
    state: mounted

However, I am encountering the following error when I check the diff on the ansible playbook:
FAILED! => {"failed": true, "msg": "the field 'args' has an invalid value, which appears to include a variable that is undefined. The error was: 'dict object' has no attribute 'content

The 'content' being registered in the first task, does not register in the second. 

This is causing my idempotency checks to fail. These tasks work fine when running, but only fail when checking the difference. Any idea why?

FYI: Using the following geerlingguy Ansible playbook: https://www.jeffgeerling.com/blog/2017/mount-aws-efs-filesystem-on-ec2-instance-ansible 

Thanks in advance.

Goetz Leupold

unread,
Sep 18, 2017, 6:38:06 AM9/18/17
to Ansible Project
Did you debug the var: aws_current_az?
A possible problem could be, that is a list or not set correctly.


Anuj Dogra

unread,
Sep 18, 2017, 8:17:33 AM9/18/17
to Ansible Project
Yeah, I tried that as well but still encountering the same error. I have a Jenkins job that checks idempotency with the Ansible playbook that is still failing even with the following:

- name: Ensure EFS volume is mounted.
  mount:
    name: "{{ efs_mount_dir }}"
    src: "{{ aws_current_az.content }}.{{ efs_file_system_id }}.efs.{{ aws_region }}.amazonaws.com:/"
    fstype: nfs4
    opts: nfsvers=4.1
    state: mounted
  changed_when: False
  ignore_errors: True
- debug: var=aws_current_az

Stephen Granger

unread,
Sep 18, 2017, 4:56:03 PM9/18/17
to ansible...@googlegroups.com
There is a PR for an az facts module open at the moment which is able to return the available AZ's
https://github.com/ansible/ansible/pull/20690

It will allow you to test what az's might exist. Otherwise I'd follow up on what has already been said to see what keys have been included with the registered variable, aws_current_az

- name: Show contents of aws_current_az
  debug:
    var: aws_current_az

--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-project+unsubscribe@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/53981734-4f9b-41d8-855d-309bbc545f31%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Steve
Reply all
Reply to author
Forward
0 new messages