Hello Freddie

On 1/3/19 5:23 PM, Freddie Eisa wrote:
What version are you running? The linux host is centos7.6

Ansible is 2.5.1, managed hosts are two Centos 7.6 cloud servers in my tests.


I tried the following:

- gather facts (automatic)

- locally render the template *on the controlling node*, once

- push the templated file to the managed hosts.


Curious if this will work for you:


template:

{% for host in groups['all'] %}
{{ hostvars[host]['ansible_facts']['ssh_host_key_ecdsa_public'] }}
{% endfor %}

playbook:

---
- hosts: all

  tasks:
    - name: Render the known_hosts file locally
      template:
        src: template.j2
        dest: /tmp/known_hosts
      delegate_to: localhost
      run_once: true

    - name: Copy the rendered file to all the nodes
      copy:
        src: /tmp/known_hosts
        dest: /tmp


---


Still not getting the error you're getting, except when trying to use the variable as *ansible_*ssh_host_key_ecdsa_public and that's not consistent, so I may be running into a completely different issue.


--

Hugo F. gonzalez

Senior Consultant

Red Hat LATAM <https://www.redhat.com>

<https://red.ht/sig>

--
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 post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/65568060-fa3f-f900-625c-a8f07f63440e%40redhat.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to