# Python invocation from Ansible

**URL:** <https://forum.ansible.com/t/python-invocation-from-ansible/34487>\
**Category:** Ansible Developer\
**Created:** [January 21, 2021, 8:33am UTC](https://forum.ansible.com/t/python-invocation-from-ansible/34487 "2021-01-21T08:33:13Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Heman\_Malve](https://avatars.discourse-cdn.com/v4/letter/h/eb8c5e/32.png) [@Heman\_Malve](https://forum.ansible.com/u/Heman_Malve)\
**Post date:** [January 21, 2021, 8:33am UTC](https://forum.ansible.com/t/python-invocation-from-ansible/34487/1 "2021-01-21T08:33:13Z")

</div>

Hi Team,

One of the file contains list of servers(centralized server) and related to Dev environment .  
Requirement is that connect each and every server remotely , execute stop command(s )of respective services and do manipulation of 2 or 3 conf files( add & remove lines) , start the services accordingly .

Is it something achievable in ansible/python/ansible & python ? if some one already worked on this scenario , please share the details

Thanks in Advance !!

---

<div class="post-metadata">

**Author:** ![Db0](https://avatars.discourse-cdn.com/v4/letter/d/9f8e36/32.png) [@Db0](https://forum.ansible.com/u/Db0)\
**Post date:** [January 21, 2021, 10:41am UTC](https://forum.ansible.com/t/python-invocation-from-ansible/34487/2 "2021-01-21T10:41:11Z")

</div>

Not sure what you mean by “one of the file” but connecting to a bunch of servers, changing a few files and restarting their services is the bread & butter of ansible and definitely doable without needing to use python at all.

---

<div class="post-metadata">

**Author:** ![Heman\_Malve](https://avatars.discourse-cdn.com/v4/letter/h/eb8c5e/32.png) [@Heman\_Malve](https://forum.ansible.com/u/Heman_Malve)\
**Post date:** [January 21, 2021, 12:42pm UTC](https://forum.ansible.com/t/python-invocation-from-ansible/34487/3 "2021-01-21T12:42:09Z")

</div>

Thanks for your anticipation !!

mean to say , bunch of servers name maintaining under hosts file.

Do you have any sample implementation/web link or info related to this topic ;

---

<div class="post-metadata">

**Author:** ![Db0](https://avatars.discourse-cdn.com/v4/letter/d/9f8e36/32.png) [@Db0](https://forum.ansible.com/u/Db0)\
**Post date:** [January 21, 2021, 2:02pm UTC](https://forum.ansible.com/t/python-invocation-from-ansible/34487/4 "2021-01-21T14:02:41Z")

</div>

[https://docs.ansible.com/ansible/latest/collections/ansible/builtin/lineinfile\_module.html](https://docs.ansible.com/ansible/latest/collections/ansible/builtin/lineinfile_module.html)  
[https://docs.ansible.com/ansible/latest/collections/ansible/builtin/service\_module.html](https://docs.ansible.com/ansible/latest/collections/ansible/builtin/service_module.html)

These are generally very basic ansible concepts. A simple google search should find all the info you need.
