Hello,

I try to use ansible facts in variable file but i get below error. Anyone 
how any idea how can i use my variable in to the playbook

fatal: [ANSIBLET01]: FAILED! => {"ansible_facts": {}, 
"ansible_included_var_files": [], "changed": false, "message": "Syntax 
Error while loading YAML.\n  found unacceptable key (unhashable type: 
'AnsibleMapping')\n\nThe error appears to be in 
'/etc/ansible/yml/AzirPlaybooks/install/elk/elkvar.yml': line 1, column 12, 
but may\nbe elsewhere in the file depending on the exact syntax 
problem.\n\nThe offending line appears to be:\n\n\nhostname: {{ 
ansible_hostname }}\n           ^ here\nWe could be wrong, but this one 
looks like it might be an issue with\nmissing quotes. Always quote template 
expression brackets when they\nstart a value. For instance:\n\n    
with_items:\n      - {{ foo }}\n\nShould be written as:\n\n    
with_items:\n      - \"{{ foo }}\"\n"}


*My var file.*

*cat elkvar.yml*
hostname: {{ ansible_hostname }}
network: {{ ansible_default_ipv4.address }}
transport: {{ ansible_default_ipv4.address }}


*My part of playbook.*

  tasks:
  - name: include dynamic variables
    include_vars: elkvar.yml

  - name: replace security
    lineinfile:
      path: /etc/elasticsearch/elasticsearch.yml
      insertafter: '#node.name: node-1'
      line: 'node.name: "{{ hostname }}"'

  - name: replace security
    lineinfile:
      path: /etc/elasticsearch/elasticsearch.yml
      insertafter: '#network.host: 192.168.0.1'
      line: 'network.host: {{ network }}'

  - name: replace security
    lineinfile:
      path: /etc/elasticsearch/elasticsearch.yml
      insertafter: 'http.cors.allow-origin'
      line: 'transport.host: {{ transport }}'




-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/6f831b28-8ece-468e-bd00-05fe278443ed%40googlegroups.com.

Reply via email to