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 25 in Ansible by Kiran
141 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 25 by Haider

Related Questions In Ansible

0 votes
1 answer

Configuring SSH Access to the Ansible Hosts

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

answered Jan 17 in Ansible by Sam
108 views
0 votes
1 answer
0 votes
1 answer

devops , how to create user using ansible playbook

root doesn't need a password to switch ...READ MORE

answered Jul 16, 2018 in Ansible by Kalgi
• 2,620 points
131 views
+13 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 26, 2018 in DevOps & Agile by DragonLord999
• 8,380 points
215 views
0 votes
1 answer
0 votes
1 answer
0 votes
3 answers