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
41 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
62 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
72 views
0 votes
1 answer

stopping different hosts from reading the same value when usign ansible in loop

Try using this. Create a new directory ...READ MORE

answered Jul 27, 2018 in Ansible by DareDev
• 6,810 points
29 views
+13 votes
2 answers
0 votes
1 answer
0 votes
1 answer
0 votes
3 answers