mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Update facts when hostname is changed
ansible_hostname contains the unqualified hostname
This commit is contained in:
parent
a848d06a04
commit
7aa57219f6
1 changed files with 6 additions and 1 deletions
|
@ -42,6 +42,7 @@ EXAMPLES = '''
|
||||||
- hostname: name=web01
|
- hostname: name=web01
|
||||||
'''
|
'''
|
||||||
|
|
||||||
|
import socket
|
||||||
from distutils.version import LooseVersion
|
from distutils.version import LooseVersion
|
||||||
|
|
||||||
# import module snippets
|
# import module snippets
|
||||||
|
@ -549,6 +550,10 @@ def main():
|
||||||
hostname.set_permanent_hostname(name)
|
hostname.set_permanent_hostname(name)
|
||||||
changed = True
|
changed = True
|
||||||
|
|
||||||
module.exit_json(changed=changed, name=name, ansible_facts=dict(ansible_hostname=name))
|
module.exit_json(changed=changed, name=name,
|
||||||
|
ansible_facts=dict(ansible_hostname=name.split('.')[0],
|
||||||
|
ansible_nodename=name,
|
||||||
|
ansible_fqdn=socket.getfqdn(),
|
||||||
|
ansible_domain='.'.join(socket.getfqdn().split('.')[1:])))
|
||||||
|
|
||||||
main()
|
main()
|
||||||
|
|
Loading…
Reference in a new issue