Hi
error msg
fatal: [localhost]: FAILED! => {
“msg”: “The task includes an option with an undefined variable. The error was: ‘dict object’ has no attribute ‘ansible_facts’\n\nThe error appears to be in ‘/home/ldap/createefs.yml’: line 37, column 8, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n - set_fact:\n ^ here\n”
}
- hosts: localhost
connection: local
gather_facts: no
vars_files:
- ec2key.yml
vars:
efs_vol_name: “test_efs”
tasks:
- name: Create EFS fileserver
efs:
state: present
region: “ap-southeast-1”
name: “test_efs”
tags:
Name: “test_efstag”
targets: - subnet_id: “subnet-46817120”
security_groups: [ “sg-073c16c36bea62794” ]
performance_mode: general_purpose
encrypt: yes
- name: efs mount to ec2
vars:
efs_vol_name: “test_efs”
-
local_action:
module: efs_info
name: “{{ efs_vol_name }}”
run_once: true
register: _efs_fact -
set_fact:
_efs_fact_id: “{{ efs_fact.ansible_facts.efs[0].file_system_id }}” -
name: install efs libs
apt:
name: “{{ item }}”
state: present
become: yes
with_items: -
nfs-common
-
name: Create data store directory for efs mount
file:
dest: “/home/ec2-user/{{ efs_vol_name }}”
state: directory -
name: mount efs volume
mount:
path: “/home/ec2-user/{{ efs_vol_name }}”
src: “{{ _efs_fact_id }}.efs.ap-southeast-1.amazonaws.com:/”
fstype: “nfs4”
opts: “nfssevers=4.1,rsize=1048576,wsize=1048576,hard,timeo=600,retrans=2,noresvport”
state: mounted
become: yes