Error saying One or more undefined variables ansible facts is undefined

0 votes

I have this command that lists all the ansible facts:

ansible localhost -m setup

and it listed all the facts of my system. But when I tried to filter them out, i ended up getting the following error:

ansible localhost -a "echo {{ }}"
localhost | FAILED => One or more undefined variables: 'ansible_facts' is undefined

Why is this happening when the fact or variable already exists?

Jan 16, 2019 in Ansible by Lara

1 answer to this question.

0 votes

The command you've executed basically means run the setup against the localhost and hence gives you the output but when you run the echo command, it doesnt run the above command and hence has nothing to echo. 

You can create a play book that runs the setup command and stores the facts somewhere and then you can easily echo it.

The playbook would look something like this:

- hosts: localhost
      - debug: var=ansible_date_time

      - debug: msg="the current date is {{ }}"
answered Jan 16, 2019 by Karen

Related Questions In Ansible

0 votes
1 answer

Error: One or more undefined variables: 'unicode object' has no attribute 'repo'

Hey change this in your role with_items: apt_repos By ...READ MORE

answered Mar 14, 2019 in Ansible by Haseeb
0 votes
1 answer
+1 vote
1 answer
+15 votes
2 answers

Git management technique when there are multiple customers and need multiple customization?

Consider this - In 'extended' Git-Flow, (Git-Multi-Flow, ...READ MORE

answered Mar 26, 2018 in DevOps & Agile by DragonLord999
• 8,450 points
+2 votes
1 answer
0 votes
2 answers
0 votes
1 answer