# How to use Ansible to change hostgroup information

**URL:** <https://community.dynatrace.com/t/how-to-use-ansible-to-change-hostgroup-information/38923>\
**Category:** Open Q&A\
**Tags:** hosts-classic\
**Created:** [March 21, 2023, 9:51am UTC](https://community.dynatrace.com/t/how-to-use-ansible-to-change-hostgroup-information/38923 "2023-03-21T09:51:41Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Chayaphot](https://avatars.discourse-cdn.com/v4/letter/c/c2a13f/32.png) [@Chayaphot](https://community.dynatrace.com/u/Chayaphot)\
**Post date:** [March 21, 2023, 9:51am UTC](https://community.dynatrace.com/t/how-to-use-ansible-to-change-hostgroup-information/38923/1 "2023-03-21T09:51:41Z")

</div>

Because wanting to change host groups for several hosts at once. Can we use Ansible to help change it?

If possible, please share the playbook and how to.

---

<div class="post-metadata">

**Author:** ![radek\_jasinski](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/radek_jasinski/32/10432_2.png) [@radek\_jasinski](https://community.dynatrace.com/u/radek_jasinski)\
**Post date:** [March 21, 2023, 12:08pm UTC](https://community.dynatrace.com/t/how-to-use-ansible-to-change-hostgroup-information/38923/2 "2023-03-21T12:08:48Z")

</div>

Hi,

As much as possible you can use Ansible for this. I don’t have the playbooks ready. However, use OneAgent CLI ([OneAgent configuration via command-line interface — Dynatrace Docs](https://www.dynatrace.com/support/help/shortlink/oneagentctl#host-groups)) to create and manage host groups.

Remember that you can set the host group at installation or change it using the CLI. There is no other option.

Radek

---

<div class="post-metadata">

**Author:** ![Yosi\_Neuman](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/yosi_neuman/32/9845_2.png) [@Yosi\_Neuman](https://community.dynatrace.com/u/Yosi_Neuman)\
**Post date:** [March 21, 2023, 6:08pm UTC](https://community.dynatrace.com/t/how-to-use-ansible-to-change-hostgroup-information/38923/3 "2023-03-21T18:08:58Z")

</div>

Hi [@radek\_jasinski](https://community.dynatrace.com/user/16832)&nbsp; & [@Chayaphot](https://community.dynatrace.com/user/51114)&nbsp;,

You can utilize&nbsp;[Remote configuration management using UI](https://www.dynatrace.com/support/help/shortlink/remote-configuration#remote-configuration-management-using-ui)

 ![Yosi_Neuman_0-1679422040955.png](https://global.discourse-cdn.com/dynatrace/original/3X/0/0/000faa5d4db202d2ec832cf18a9bad961ea593a0.png)

HTH

Yos

---

<div class="post-metadata">

**Author:** ![radek\_jasinski](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/radek_jasinski/32/10432_2.png) [@radek\_jasinski](https://community.dynatrace.com/u/radek_jasinski)\
**Post date:** [March 21, 2023, 6:25pm UTC](https://community.dynatrace.com/t/how-to-use-ansible-to-change-hostgroup-information/38923/4 "2023-03-21T18:25:15Z")

</div>

Thanks, I didn’t notice that Dynatrace added this feature.  
This will be useful, but if you need to add 100 agents to a host group, it will be cumbersome.

CLI is the best at this point.

Radek

---

<div class="post-metadata">

**Author:** ![Yosi\_Neuman](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/yosi_neuman/32/9845_2.png) [@Yosi\_Neuman](https://community.dynatrace.com/u/Yosi_Neuman)\
**Post date:** [March 21, 2023, 7:36pm UTC](https://community.dynatrace.com/t/how-to-use-ansible-to-change-hostgroup-information/38923/5 "2023-03-21T19:36:40Z")

</div>

Not quite agree with you [@radek\_jasinski](https://community.dynatrace.com/user/16832),&nbsp;you can filter the oneagent deployment (let’s say by tag) and then switch on the check box for all the hosts and you are all set.

If you have a tool to run the CLI on 100 hosts go for it!

Yos

---

<div class="post-metadata">

**Author:** ![radek\_jasinski](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/radek_jasinski/32/10432_2.png) [@radek\_jasinski](https://community.dynatrace.com/u/radek_jasinski)\
**Post date:** [March 21, 2023, 7:41pm UTC](https://community.dynatrace.com/t/how-to-use-ansible-to-change-hostgroup-information/38923/6 "2023-03-21T19:41:33Z")

</div>

I agree with you:)

---

<div class="post-metadata">

**Author:** ![Chayaphot](https://avatars.discourse-cdn.com/v4/letter/c/c2a13f/32.png) [@Chayaphot](https://community.dynatrace.com/u/Chayaphot)\
**Post date:** [March 28, 2023, 9:49am UTC](https://community.dynatrace.com/t/how-to-use-ansible-to-change-hostgroup-information/38923/7 "2023-03-28T09:49:57Z")

</div>

Hi&nbsp;[@radek\_jasinski](https://community.dynatrace.com/user/16832)&nbsp;and&nbsp;[@Yosi\_Neuman](https://community.dynatrace.com/user/6931)

I understand it’s much easier to edit via the web, just tick a checkbox.&nbsp;But the dynatrace version of the customer is very old. Therefore, only about 70 out of 200 devices can use that feature.

If using the CLI, it should take quite a long time. If you have a more convenient way, please suggest.

Chayaphot

---

<div class="post-metadata">

**Author:** ![radek\_jasinski](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/radek_jasinski/32/10432_2.png) [@radek\_jasinski](https://community.dynatrace.com/u/radek_jasinski)\
**Post date:** [March 28, 2023, 9:56am UTC](https://community.dynatrace.com/t/how-to-use-ansible-to-change-hostgroup-information/38923/8 "2023-03-28T09:56:20Z")

</div>

I think we have described with Yosi all the possibilities of host group configuration.

Radek
