# Ansible core rhel linux - how do I do the equivalent of 'nmcli general hostname' and set the hostname in ansible?

**URL:** <https://forum.ansible.com/t/ansible-core-rhel-linux-how-do-i-do-the-equivalent-of-nmcli-general-hostname-and-set-the-hostname-in-ansible/269>\
**Category:** Get Help\
**Tags:** rhel\
**Created:** [September 5, 2023, 2:51pm UTC](https://forum.ansible.com/t/ansible-core-rhel-linux-how-do-i-do-the-equivalent-of-nmcli-general-hostname-and-set-the-hostname-in-ansible/269 "2023-09-05T14:51:22Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nesbit7](https://avatars.discourse-cdn.com/v4/letter/n/53a042/32.png) [@Nesbit7](https://forum.ansible.com/u/Nesbit7)\
**Post date:** [September 5, 2023, 2:51pm UTC](https://forum.ansible.com/t/ansible-core-rhel-linux-how-do-i-do-the-equivalent-of-nmcli-general-hostname-and-set-the-hostname-in-ansible/269/1 "2023-09-05T14:51:23Z")

</div>

ansible core rhel linux - how do I do the equivalent of ‘nmcli general hostname’ and set the hostname in ansible?

normally when building a server, I update the hostname using the ‘nmcli general hostname’ command.

I can’ t find where to set this using ansible, is it possible, if so how ?

---

<div class="post-metadata">

**Author:** ![gotmax23](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/gotmax23/32/106_2.png) [@gotmax23](https://forum.ansible.com/u/gotmax23)\
**Post date:** [September 5, 2023, 3:27pm UTC](https://forum.ansible.com/t/ansible-core-rhel-linux-how-do-i-do-the-equivalent-of-nmcli-general-hostname-and-set-the-hostname-in-ansible/269/2 "2023-09-05T15:27:56Z")

</div>

Welcome to the forum, @Nesbit7! Ansible has a [builtin hostname module](https://docs.ansible.com/ansible/latest/collections/ansible/builtin/hostname_module.html). Does that work for your usecase?

---

<div class="post-metadata">

**Author:** ![Nesbit7](https://avatars.discourse-cdn.com/v4/letter/n/53a042/32.png) [@Nesbit7](https://forum.ansible.com/u/Nesbit7)\
**Post date:** [September 6, 2023, 10:00am UTC](https://forum.ansible.com/t/ansible-core-rhel-linux-how-do-i-do-the-equivalent-of-nmcli-general-hostname-and-set-the-hostname-in-ansible/269/3 "2023-09-06T10:00:43Z")

</div>

sorry, I was naive in expecting all the nmcli commands to be mapped across directly to ansible nmcli module.

thanks for your excellent suggestion, it works.

thanks,
