I would write an Ansible module from the Python script and do the rest in Ansible. Anyways, check https://docs.ansible.com/ansible/latest/reference_appendices/special_variables.html#magic-variables for ansible_play_hosts and ansible_play_hosts_all
On Tue, Jun 20, 2023 at 8:25 PM Prady A <[email protected]> wrote: > Thank Dick..Thank you for your kindness.. > Sorry if I confused. My intention is to run the playbook and get all the > hostnames in a variable . > > Like : > var=hostvars[ansible_hostname][‘ansible_hostname’] > > With the above command I can fetch the hostname but how to append all the > hostnames in an array so that finally I can pass that array to python > script. > > Regards > > On Wed, Jun 21, 2023 at 12:18, Dick Visser <[email protected]> wrote: > >> https://docs.ansible.com/ansible/latest/cli/ansible-inventory.html >> >> >> On Wed, 21 Jun 2023 at 04:49, Prady A <[email protected]> wrote: >> >>> Hi all >>> >>> Pls help.. need to collect all the hostnames in an array and pass that >>> are art finally to an python script as an argument..so that I can process >>> that python file with all hostname in a loop. >>> >>> If any other way to doing it that would be certainly great.. >>> >>> Regards.. >>> Prady >>> >>> -- >>> 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 view this discussion on the web visit >>> https://groups.google.com/d/msgid/ansible-project/CAEuB3ApQPotWX84oyr57a7qkE6B43yaKPxbCfP5Prw5kVvTwMQ%40mail.gmail.com >>> <https://groups.google.com/d/msgid/ansible-project/CAEuB3ApQPotWX84oyr57a7qkE6B43yaKPxbCfP5Prw5kVvTwMQ%40mail.gmail.com?utm_medium=email&utm_source=footer> >>> . >> >> >>> -- >> Sent from Gmail Mobile >> >> -- >> 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 view this discussion on the web visit >> https://groups.google.com/d/msgid/ansible-project/CAF8BbLbz0ostA9w48RkWLVaSZzF0phz6mzpqQaS1FiTy1cfCeQ%40mail.gmail.com >> <https://groups.google.com/d/msgid/ansible-project/CAF8BbLbz0ostA9w48RkWLVaSZzF0phz6mzpqQaS1FiTy1cfCeQ%40mail.gmail.com?utm_medium=email&utm_source=footer> >> . >> > -- > 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 view this discussion on the web visit > https://groups.google.com/d/msgid/ansible-project/CAEuB3Ap82Q%2BJyoaQpBTbE5O7OF3pDP2EVH%2BR181gpYM-_dThyQ%40mail.gmail.com > <https://groups.google.com/d/msgid/ansible-project/CAEuB3Ap82Q%2BJyoaQpBTbE5O7OF3pDP2EVH%2BR181gpYM-_dThyQ%40mail.gmail.com?utm_medium=email&utm_source=footer> > . > -- Thanks, Abhijeet Kasurde -- 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 view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CAFwWkHoLMCmi30mutdBD9b7c4iq2nT4UoAZAc%2BebW5Y5O%3DLRGA%40mail.gmail.com.
