Hello Community,
I have a question related with my ansible playbook. Let me describe an issue:
I use hostvars in template like:
{% for host in groups[‘elasticsearch’] %}
- {{ hostvars[host].ansible_default_ipv4.address }}
{% endfor %}
all working fine, but wen I use serial option in my playbook:
- name: Upgrade Elasticsearch
hosts: elasticsearch
gather_facts: yes
serial: 1
tasks:
- name: Check Elasticsearch cluster state - Need to be green before upgrade
[…] - import_role:
name: u_elasticsearch
I receiving error:
TASK [u_elasticsearch : Elasticsearch template config] ***************************************************************** failed: [elk1] (item=elasticsearch.yml) => {“ansible_loop_var”: “item”, “changed”: false, “item”: “elasticsearch.yml”,
“msg”: “AnsibleUndefinedVariable: ‘ansible.vars.hostvars.HostVarsVars object’ has no attribute ‘ansible_all_ipv4_addresses’”}
I understood that this is because of missing all facts, is it any possibility to force gather all facts and perform serial …
I will be really happy for Your help