Comments on: How to Work with Ansible Variables and Facts – Part 8 https://www.tecmint.com/ansible-variables-and-facts/ Tecmint - Linux Howtos, Tutorials, Guides, News, Tips and Tricks. Sun, 13 Dec 2020 15:57:34 +0000 hourly 1 By: journeyman.lnx https://www.tecmint.com/ansible-variables-and-facts/comment-page-1/#comment-1400706 Sun, 13 Dec 2020 15:57:34 +0000 https://www.tecmint.com/?p=35303#comment-1400706 Is the YAML file formatting correct throughout the example of the ‘Inventory Variables‘ section?

The difference in the relative indentation of webserver1 vs webserver2 doesn’t seem too consistent with the initial presentation:

[web_servers]

web_server_1 ansible_user=centos http_port=80
web_server_2 ansible_user=ubuntu http_port=8080
]]>
By: Marcel de Vries https://www.tecmint.com/ansible-variables-and-facts/comment-page-1/#comment-1357260 Wed, 26 Aug 2020 14:05:57 +0000 https://www.tecmint.com/?p=35303#comment-1357260 Hello Jeff,

I tried a super simple playbook to read a dict variable:

---    
hosts: instance-01
vars:  
  vlans:
    id: 10
        
tasks: 
  - name: Read dict variable
    debug:
      msg: “{{ vlans[‘id’]  }}“   

Output:

ansible-playbook test_dict.yml 
[WARNING]: Skipping unexpected key (servers) in group (local), only "vars", "children" and "hosts" are valid
ERROR! A playbook must be a list of plays, got a  instead

The error appears to be in ‘/home/student/Ansible/klooien/test_dict.yml’: line 2, column 1, but may
be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:


hosts: instance-01
^ here

Help!

]]>
By: James Kiarie https://www.tecmint.com/ansible-variables-and-facts/comment-page-1/#comment-1328688 Mon, 20 Apr 2020 09:00:05 +0000 https://www.tecmint.com/?p=35303#comment-1328688 In reply to jef.

Hey Jeff, let me have a look at the playbook you are running to verify if the syntax is correct.

]]>
By: jef https://www.tecmint.com/ansible-variables-and-facts/comment-page-1/#comment-1328326 Sat, 18 Apr 2020 10:41:23 +0000 https://www.tecmint.com/?p=35303#comment-1328326 TASK [Install the new facts] *********************************************************************************************************************
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: If you are using a module and expect the file to exist on the remote, see the remote_src option
fatal: [host2]: FAILED! => {“changed”: false, “msg”: “Could not find or access ‘custom.facts’\nSearched in:\n\t/rh294/files/custom.facts\n\t/rh294/custom.facts\n\t/rh294/files/custom.facts\n\t/rh294/custom.facts on the Ansible Controller.\nIf you are using a module and expect the file to exist on the remote, see the remote_src option”}

]]>
By: jef https://www.tecmint.com/ansible-variables-and-facts/comment-page-1/#comment-1328325 Sat, 18 Apr 2020 10:40:16 +0000 https://www.tecmint.com/?p=35303#comment-1328325 TASK [Get custom facts] **************************************************************************************************************************
fatal: [host2]: FAILED! => {“msg”: “The task includes an option with an undefined variable. The error was: ‘dict object’ has no attribute ‘date_time’\n\nThe error appears to be in ‘/rh294/chap4_setup_facts.yaml’: line 11, column 9, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n tasks:\n – name: Get custom facts\n ^ here\n”}

I am getting this error when i run the above custom fact. I am using ansible;

[root@control-node rh294]# ansible –version
ansible 2.9.6
config file = /rh294/ansible.cfg
configured module search path = [u’/root/.ansible/plugins/modules’, u’/usr/share/ansible/plugins/modules’]
ansible python module location = /usr/lib/python2.7/site-packages/ansible
executable location = /usr/bin/ansible
python version = 2.7.5 (default, Aug 4 2017, 00:39:18) [GCC 4.8.5 20150623 (Red Hat 4.8.5-16)]

]]>