Playbook to add hosts to the known hosts list - Ansible

0 votes
How do I write Ansible Playbook to add hosts to the known host list?
Mar 26, 2019 in Ansible by Kiran
3,286 views

1 answer to this question.

0 votes

Hey @Kiran, try something like this:

- name: Add EC2 instances as known hosts
  known_hosts:
    name: "{{ item.public_ip }}"
    key: "{{ lookup('pipe', 'ssh-keyscan -t rsa ' + item.public_ip) }}"
  with_items: "{{ ec2_instances.tagged_instances }}"
answered Mar 26, 2019 by Haider

Related Questions In Ansible

0 votes
1 answer

How to list down all the hosts in Ansible?

Hi@akhtar, You can use the option --list-hosts. It will ...READ MORE

answered Jul 28, 2020 in Ansible by MD
• 95,460 points
47,856 views
0 votes
1 answer

Configuring SSH Access to the Ansible Hosts

Hey @Shakira, follow these steps: Execute the following ...READ MORE

answered Jan 17, 2019 in Ansible by Sam
1,201 views
+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 27, 2018 in DevOps & Agile by DragonLord999
• 8,450 points
3,987 views
+2 votes
1 answer
0 votes
1 answer
+1 vote
3 answers
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP