On 12. okt. 2016 01:31, ZillaYT wrote:
I have a dictionary that defines AWS mounts based on IP address

- aws_mount_10_22_100_1
- aws_mount_10_22_100_2

You don't have a dictionary, you have a list with dictionaries.

Now I want a task that creates an entry in /etc/fstab

# The idea is the src value resolves to src=aws_mount_10_22_100_1 for a IP
- name: Add entry in /etc/fstab
  mount: name=/mt/mount_path src="{{ aws_efs_mount.{{
ansible_default_ipv4.address }} }}"

I get

TASK [elasticsearch-elk : Add entry in /etc/fstab *****
fatal: [10.22.x.x]: FAILED! => {"failed": true, "msg": "plate error while
templating string: expected name or number. String: {{ aws_efs_mount.{{
ansible_default_ipv4.address }} }}"}

How can I achieve this? I can't use a template since there are values in
the /etc/fstab file.

You can't use curly brackets inside curly bracket.

To make it work you need to change aws_efs_mount to
  aws_efs_mount: aws_mount_10_22_100_1 aws_mount_10_22_100_2

And the src in mount to
src={{ aws_efs_mount[hostvars[inventory_hostname].ansible_default_ipv4.address] }}

Kai Stian Olstad

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+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
For more options, visit https://groups.google.com/d/optout.

Reply via email to