# SSH Host disconnects during hostname module

**URL:** <https://forum.ansible.com/t/ssh-host-disconnects-during-hostname-module/4117>\
**Category:** Get Help\
**Tags:** playbook, ubuntu, ansible-core\
**Created:** [February 28, 2024, 5:26pm UTC](https://forum.ansible.com/t/ssh-host-disconnects-during-hostname-module/4117 "2024-02-28T17:26:32Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![nbodewitz](https://avatars.discourse-cdn.com/v4/letter/n/bc79bd/32.png) [@nbodewitz](https://forum.ansible.com/u/nbodewitz)\
**Post date:** [February 28, 2024, 5:26pm UTC](https://forum.ansible.com/t/ssh-host-disconnects-during-hostname-module/4117/1 "2024-02-28T17:26:32Z")

</div>

I am trying to do simple host renames against Ubuntu 20.04 endpoints and always get ssh disconnect whenever trying to run the module. Connecting with sshagent loaded key.  
Below is the basic playbook

```auto
---
  - hosts: azagents
    tasks:
      - name: set hostname
        ansible.builtin.hostname:
          name: "{{ inventory_hostname }}"

```

Inventory.yaml file

```auto
azagents:
  hosts:
    test1:
      ansible_host: x.x.x.x (Masked out for post)

```

Error output even with -vv.

```auto
TASK [set hostname] **********************************************************************************************************************
task path: /etc/ansible/playbooks/agents.yml:4
fatal: [test1]: FAILED! => {"changed": false, "msg": "Command failed rc=1, out=, err=\u001b[0;1;31mCould not set property: Connection timed out\u001b[0m\n"}

PLAY RECAP *******************************************************************************************************************************
test1 : ok=1 changed=0 unreachable=0 failed=1 skipped=0 rescued=0 ignored=0

```

---

<div class="post-metadata">

**Author:** ![nbodewitz](https://avatars.discourse-cdn.com/v4/letter/n/bc79bd/32.png) [@nbodewitz](https://forum.ansible.com/u/nbodewitz)\
**Post date:** [February 28, 2024, 11:32pm UTC](https://forum.ansible.com/t/ssh-host-disconnects-during-hostname-module/4117/2 "2024-02-28T23:32:57Z")

</div>

setting become: true resolved the issue.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/ansible/original/1X/1882d9a01da5d8996a862359b0913cc568a39b84.svg) [@system](https://forum.ansible.com/u/system)\
**Post date:** [March 29, 2024, 11:33pm UTC](https://forum.ansible.com/t/ssh-host-disconnects-during-hostname-module/4117/3 "2024-03-29T23:33:31Z")

</div>

Closed on March 29, 2024, 11:33pm UTC

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
