Creating inventory file not manually

I dont want to manually create inventory file .

How can i generate inventory file as well using playbook or any other means ?

As i launch instance and then i want to perform operation on that IP ?It is also using another port as well not 22 I mean .

Please help someone .

Hello Satyam,

thanks for writing to us.

have you gone through the lecture of Dynamic inventory in Ansible course? it simply works as per your requirement, in that you dont have to create the inventory manually rather it is done via CMDB

add_host can solve the purpose what I was interested in.

- name: Add instances to inventory

ignore_errors: yes


name: “{{ }}”

groups: “****”

ansible_host: “{{ item.mgt0ipaddress }}”

loop: “{{ *****_nodes }}”

no_log: True