HEX
Server: LiteSpeed
System: Linux kapuas.iixcp.rumahweb.net 5.14.0-427.42.1.el9_4.x86_64 #1 SMP PREEMPT_DYNAMIC Fri Nov 1 14:58:02 EDT 2024 x86_64
User: mirz4654 (1666)
PHP: 8.1.33
Disabled: system,exec,escapeshellarg,escapeshellcmd,passthru,proc_close,proc_get_status,proc_nice,proc_open,proc_terminate,shell_exec,popen,pclose,dl,pfsockopen,leak,apache_child_terminate,posix_kill,posix_mkfifo,posix_setsid,posix_setuid,posix_setpgid,ini_alter,show_source,define_syslog_variables,symlink,syslog,openlog,openlog,closelog,ocinumcols,listen,chgrp,apache_note,apache_setenv,debugger_on,debugger_off,ftp_exec,dll,ftp,myshellexec,socket_bind,mail,posix_getwpuid
Upload Files
File: //usr/lib/python3.9/site-packages/ansible/modules/__pycache__/hostname.cpython-39.pyc
a

�)g{p�@sddlmZmZmZeZdZdZddlZddl	Z	ddl
Z
ddlZddlm
mmZddlmZmZmZddlmZddlmZddlmZmZdd	lmZmZdd
lm Z m!Z!ddd
ddddddddddd�
Z"Gdd�de#�Z$Gdd�de$�Z%Gdd�de$�Z&Gdd�de$�Z'Gdd�de'�Z(Gd d!�d!e$�Z)Gd"d#�d#e'�Z*Gd$d%�d%e$�Z+Gd&d'�d'e$�Z,Gd(d)�d)e'�Z-Gd*d+�d+e$�Z.Gd,d-�d-e$�Z/Gd.d/�d/e$�Z0Gd0d1�d1e#�Z1Gd2d3�d3e1�Z2Gd4d5�d5e1�Z3Gd6d7�d7e1�Z4Gd8d9�d9e1�Z5Gd:d;�d;e1�Z6Gd<d=�d=e1�Z7Gd>d?�d?e1�Z8Gd@dA�dAe1�Z9GdBdC�dCe1�Z:GdDdE�dEe1�Z;GdFdG�dGe1�Z<GdHdI�dIe1�Z=GdJdK�dKe1�Z>GdLdM�dMe1�Z?GdNdO�dOe1�Z@GdPdQ�dQe1�ZAGdRdS�dSe1�ZBGdTdU�dUe1�ZCGdVdW�dWe1�ZDGdXdY�dYe1�ZEGdZd[�d[e1�ZFGd\d]�d]e1�ZGGd^d_�d_e1�ZHGd`da�dae1�ZIGdbdc�dce1�ZJGddde�dee1�ZKGdfdg�dge1�ZLGdhdi�die1�ZMGdjdk�dke1�ZNGdldm�dme1�ZOGdndo�doe1�ZPGdpdq�dqe1�ZQGdrds�dse1�ZRGdtdu�due1�ZSGdvdw�dwe1�ZTdxdy�ZUeVdzk�r�eU�dS){�)�absolute_import�division�print_functiona�
---
module: hostname
author:
    - Adrian Likins (@alikins)
    - Hideki Saito (@saito-hideki)
version_added: "1.4"
short_description: Manage hostname
requirements: [ hostname ]
description:
    - Set system's hostname. Supports most OSs/Distributions including those using C(systemd).
    - Windows, HP-UX, and AIX are not currently supported.
notes:
    - This module does B(NOT) modify C(/etc/hosts). You need to modify it yourself using other modules such as M(ansible.builtin.template)
      or M(ansible.builtin.replace).
    - On macOS, this module uses C(scutil) to set C(HostName), C(ComputerName), and C(LocalHostName). Since C(LocalHostName)
      cannot contain spaces or most special characters, this module will replace characters when setting C(LocalHostName).
options:
    name:
        description:
            - Name of the host.
            - If the value is a fully qualified domain name that does not resolve from the given host,
              this will cause the module to hang for a few seconds while waiting for the name resolution attempt to timeout.
        type: str
        required: true
    use:
        description:
            - Which strategy to use to update the hostname.
            - If not set we try to autodetect, but this can be problematic, particularly with containers as they can present misleading information.
            - Note that 'systemd' should be specified for RHEL/EL/CentOS 7+. Older distributions should use 'redhat'.
        choices: ['alpine', 'debian', 'freebsd', 'generic', 'macos', 'macosx', 'darwin', 'openbsd', 'openrc', 'redhat', 'sles', 'solaris', 'systemd']
        type: str
        version_added: '2.9'
extends_documentation_fragment:
- action_common_attributes
- action_common_attributes.facts
attributes:
    check_mode:
        support: full
    diff_mode:
        support: full
    facts:
        support: full
    platform:
        platforms: posix
z�
- name: Set a hostname
  ansible.builtin.hostname:
    name: web01

- name: Set a hostname specifying strategy
  ansible.builtin.hostname:
    name: web01
    use: systemd
N)�
AnsibleModule�get_distribution�get_distribution_version)�get_platform_subclass)�ServiceMgrFactCollector)�get_file_lines�get_file_content)�	to_native�to_text)�PY3�	text_type�AlpineZSystemd�FreeBSDZBase�Darwin�OpenBSDZOpenRCZRedHatZSLESZSolaris)
ZalpineZdebianZfreebsdZgenericZmacosZmacosx�darwinZopenbsdZopenrcZredhatZslesZsolarisZsystemdc@sLeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dS)�BaseStrategycCs||_d|_dS)NF)�module�changed��selfr�r�</usr/lib/python3.9/site-packages/ansible/modules/hostname.py�__init__iszBaseStrategy.__init__cCs|��|��|jS�N)�update_current_hostname�update_permanent_hostnamer�rrrr�%update_current_and_permanent_hostnamemsz2BaseStrategy.update_current_and_permanent_hostnamecCs8|jjd}|��}||kr4|jjs.|�|�d|_dS�N�nameT)r�params�get_current_hostname�
check_mode�set_current_hostnamer)rr#Zcurrent_namerrrrrs
z$BaseStrategy.update_current_hostnamecCs8|jjd}|��}||kr4|jjs.|�|�d|_dSr")rr$�get_permanent_hostnamer&�set_permanent_hostnamer)rr#Zpermanent_namerrrrzs
z&BaseStrategy.update_permanent_hostnamecCs|��Sr)r(r rrrr%�sz!BaseStrategy.get_current_hostnamecCsdSrr�rr#rrrr'�sz!BaseStrategy.set_current_hostnamecCst�dSr��NotImplementedErrorr rrrr(�sz#BaseStrategy.get_permanent_hostnamecCst�dSrr+r*rrrr)�sz#BaseStrategy.set_permanent_hostnameN)�__name__�
__module__�__qualname__rr!rrr%r'r(r)rrrrrhsrc@sLeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dS)�UnimplementedStrategycCs|��dSr��unimplemented_errorr rrrr!�sz;UnimplementedStrategy.update_current_and_permanent_hostnamecCs|��dSrr1r rrrr�sz-UnimplementedStrategy.update_current_hostnamecCs|��dSrr1r rrrr�sz/UnimplementedStrategy.update_permanent_hostnamecCs|��dSrr1r rrrr%�sz*UnimplementedStrategy.get_current_hostnamecCs|��dSrr1r*rrrr'�sz*UnimplementedStrategy.set_current_hostnamecCs|��dSrr1r rrrr(�sz,UnimplementedStrategy.get_permanent_hostnamecCs|��dSrr1r*rrrr)�sz,UnimplementedStrategy.set_permanent_hostnamecCs>t��}t�}|dur$d||f}n|}|jjd|d�dS)Nz%s (%s)z-hostname module cannot be used on platform %s��msg)�platform�systemrr�	fail_json)rr6�distributionZmsg_platformrrrr2�s�z)UnimplementedStrategy.unimplemented_errorN)r-r.r/r!rrr%r'r(r)r2rrrrr0�sr0cs@eZdZdZ�fdd�Zdd�Zdd�Zdd	�Zd
d�Z�Z	S)�CommandStrategy�hostnamecs&tt|��|�|j�|jd�|_dS�NT)�superr9rr�get_bin_path�COMMAND�hostname_cmdr��	__class__rrr�szCommandStrategy.__init__cCsF|jg}|j�|�\}}}|dkr:|jjd|||fd�t|���S�Nr�$Command failed rc=%d, out=%s, err=%sr3�r?r�run_commandr7r�strip�r�cmd�rc�out�errrrrr%�s
z$CommandStrategy.get_current_hostnamecCs@|j|g}|j�|�\}}}|dkr<|jjd|||fd�dSrB�r?rrEr7�rr#rHrIrJrKrrrr'�s
z$CommandStrategy.set_current_hostnamecCsdS)NZUNKNOWNrr rrrr(�sz&CommandStrategy.get_permanent_hostnamecCsdSrrr*rrrr)�sz&CommandStrategy.set_permanent_hostname)
r-r.r/r>rr%r'r(r)�
__classcell__rrr@rr9�sr9c@s eZdZdZdd�Zdd�ZdS)�FileStrategy�
/etc/hostnamec
Csjtj�|j�sdSzt|jddd�WStyd}z(|jjdt|�t	�
�d�WYd}~n
d}~00dS)N�T)�defaultrF�failed to read hostname: %s�r4�	exception)�os�path�isfile�FILEr�	Exceptionrr7r�	traceback�
format_exc)r�errrr(�s
�z#FileStrategy.get_permanent_hostnamec
Cs�z>t|jd��}|�d|�Wd�n1s20YWn@ty~}z(|jjdt|�t��d�WYd}~n
d}~00dS)N�w+z%s
�failed to update hostname: %srT)	�openrY�writerZrr7rr[r\)rr#�fr]rrrr)�s0
�z#FileStrategy.set_permanent_hostnameN)r-r.r/rYr(r)rrrrrO�srOc@seZdZdZdZdS)�SLESStrategyzW
    This is a SLES Hostname strategy class - it edits the
    /etc/HOSTNAME file.
    z
/etc/HOSTNAMEN�r-r.r/�__doc__rYrrrrrc�srcc@s$eZdZdZdZdd�Zdd�ZdS)�RedHatStrategyzb
    This is a Redhat Hostname strategy class - it edits the
    /etc/sysconfig/network file.
    z/etc/sysconfig/networkc
Cs�zXt|j�D]6}t|���}|�d�r|�d�\}}|��WSq|j�d|j�Wn@ty�}z(|jjdt|�t	�
�d�WYd}~n
d}~00dS)N�HOSTNAME�=z%Unable to locate HOSTNAME entry in %srSrT)r
�NETWORK_FILErrF�
startswith�splitrr7rZr[r\)r�line�k�vr]rrrr(�s
�
�z%RedHatStrategy.get_permanent_hostnamec
Cs�z�g}d}t|jdd�pd}|�d�D]8}t|�}|���d�rT|�d|�d}q&|�|�q&|sr|�d|�t|jd��}|�|�Wd�n1s�0YWn@t	y�}z(|j
jdt|�t�
�d	�WYd}~n
d}~00dS)
NF�rFrQTrgzHOSTNAME=%s
r^r_rT)rri�
splitlinesrrFrj�appendr`�
writelinesrZrr7r[r\)rr#�lines�foundZcontentrlrbr]rrrr)s&,
�z%RedHatStrategy.set_permanent_hostnameN)r-r.r/rerir(r)rrrrrf�srfcs(eZdZdZdZdZ�fdd�Z�ZS)�AlpineStrategyz�
    This is a Alpine Linux Hostname manipulation strategy class - it edits
    the /etc/hostname file then run hostname -F /etc/hostname.
    rPr:csbtt|��|�|j�|jd�}|d|jg}|j�|�\}}}|dkr^|jjd|||fd�dS)NTz-FrrCr3)	r<rur'rr=r>rYrEr7)rr#r?rHrIrJrKr@rrr' sz#AlpineStrategy.set_current_hostname)r-r.r/rerYr>r'rNrrr@rrusrucsLeZdZdZdZ�fdd�Zdd�Zdd�Zd	d
�Zdd�Z	d
d�Z
�ZS)�SystemdStrategyzg
    This is a Systemd hostname manipulation strategy class - it uses
    the hostnamectl command.
    Zhostnamectlcs&tt|��|�|j�|jd�|_dSr;)r<rvrrr=r>�hostnamectl_cmdrr@rrr2szSystemdStrategy.__init__cCsJ|jddg}|j�|�\}}}|dkr>|jjd|||fd�t|���S)N�--transient�statusrrCr3�rwrrEr7rrFrGrrrr%6s
z$SystemdStrategy.get_current_hostnamecCs^t|�dkr|jjdd�|jdd|g}|j�|�\}}}|dkrZ|jjd|||fd�dS)N�@�Oname cannot be longer than 64 characters on systemd servers, try a shorter namer3rx�set-hostnamerrC��lenrr7rwrErMrrrr'=sz$SystemdStrategy.set_current_hostnamecCsJ|jddg}|j�|�\}}}|dkr>|jjd|||fd�t|���S)N�--staticryrrCr3rzrGrrrr(Es
z&SystemdStrategy.get_permanent_hostnamecCs`t|�dkr|jjdd�|jddd|g}|j�|�\}}}|dkr\|jjd|||fd�dS)	Nr{r|r3z--prettyr�r}rrCr~rMrrrr)Lsz&SystemdStrategy.set_permanent_hostnamecCs|��|��|jSr)rrrr rrrr!Tsz5SystemdStrategy.update_current_and_permanent_hostname)r-r.r/rer>rr%r'r(r)r!rNrrr@rrv*srvc@s$eZdZdZdZdd�Zdd�ZdS)�OpenRCStrategyzv
    This is a Gentoo (OpenRC) Hostname manipulation strategy class - it edits
    the /etc/conf.d/hostname file.
    z/etc/conf.d/hostnamec
Cs�tj�|j�sdSz>t|j�D].}|��}|�d�r|dd��d�WSqWn@ty�}z(|jj	dt
|�t��d�WYd}~n
d}~00dS�NrQ�	hostname=�
�"rSrT�
rVrWrXrYr
rFrjrZrr7rr[r\�rrlr]rrrr(ds

�z%OpenRCStrategy.get_permanent_hostnamec
Cs�z�dd�t|j�D�}t|�D]"\}}|�d�rd|||<qBqt|jd��$}|�d�|�d�Wd�n1sx0YWn@ty�}z(|jj	dt
|�t��d�WYd}~n
d}~00dS)	NcSsg|]}|���qSrro��.0�xrrr�
<listcomp>t�z9OpenRCStrategy.set_permanent_hostname.<locals>.<listcomp>r��
hostname="%s"�w�
r_rT)
r
rY�	enumeraterjr`ra�joinrZrr7rr[r\�rr#rs�irlrbr]rrrr)rs
6
�z%OpenRCStrategy.set_permanent_hostnameN)r-r.r/rerYr(r)rrrrr�\sr�c@seZdZdZdZdS)�OpenBSDStrategyzl
    This is a OpenBSD family Hostname manipulation strategy class - it edits
    the /etc/myname file.
    z/etc/mynameNrdrrrrr��sr�cs<eZdZdZdZ�fdd�Zdd�Zdd�Zd	d
�Z�Z	S)�SolarisStrategyzn
    This is a Solaris11 or later Hostname manipulation strategy class - it
    execute hostname command.
    r:cs&tt|��|�|j�|jd�|_dSr;)r<r�rrr=r>r?rr@rrr�szSolarisStrategy.__init__cCsFd}|j||g}|j�|�\}}}|dkrB|jjd|||fd�dS)Nz-trrCr3rL)rr#Z
cmd_optionrHrIrJrKrrrr'�s
z$SolarisStrategy.set_current_hostnamecCsVd}d}d||f}|jj|dd�\}}}|dkrJ|jjd|||fd�t|���S)	Nzsvc:/system/identity:nodezconfig/nodenamez+/usr/sbin/svccfg -s %s listprop -o value %sT)Zuse_unsafe_shellrrCr3)rrEr7rrF)rZfmri�patternrHrIrJrKrrrr(�sz&SolarisStrategy.get_permanent_hostnamecCs@|j|g}|j�|�\}}}|dkr<|jjd|||fd�dSrBrLrMrrrr)�s
z&SolarisStrategy.set_permanent_hostname)
r-r.r/rer>rr'r(r)rNrrr@rr��s	r�csHeZdZdZdZdZ�fdd�Zdd�Zdd	�Zd
d�Z	dd
�Z
�ZS)�FreeBSDStrategyzq
    This is a FreeBSD hostname manipulation strategy class - it edits
    the /etc/rc.conf.d/hostname file.
    z/etc/rc.conf.d/hostnamer:cs&tt|��|�|j�|jd�|_dSr;)r<r�rrr=r>r?rr@rrr�szFreeBSDStrategy.__init__cCsF|jg}|j�|�\}}}|dkr:|jjd|||fd�t|���SrBrDrGrrrr%�s
z$FreeBSDStrategy.get_current_hostnamecCs@|j|g}|j�|�\}}}|dkr<|jjd|||fd�dSrBrLrMrrrr'�s
z$FreeBSDStrategy.set_current_hostnamec
Cs�tj�|j�sdSz>t|j�D].}|��}|�d�r|dd��d�WSqWn@ty�}z(|jj	dt
|�t��d�WYd}~n
d}~00dSr�r�r�rrrr(�s

�z&FreeBSDStrategy.get_permanent_hostnamec
Cs�z�tj�|j�rRdd�t|j�D�}t|�D]"\}}|�d�r,d|||<q\q,n
d|g}t|jd��$}|�d�	|�d�Wd�n1s�0YWn@t
y�}z(|jjdt
|�t��d�WYd}~n
d}~00dS)	NcSsg|]}|���qSrror�rrrr��r�z:FreeBSDStrategy.set_permanent_hostname.<locals>.<listcomp>r�r�r�r�r_rT)rVrWrXrYr
r�rjr`rar�rZrr7rr[r\r�rrrr)�s

6
�z&FreeBSDStrategy.set_permanent_hostname)r-r.r/rerYr>rr%r'r(r)rNrrr@rr��sr�cs`eZdZdZ�fdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�Z�Z
S)�DarwinStrategya>
    This is a macOS hostname manipulation strategy class. It uses
    /usr/sbin/scutil to set ComputerName, HostName, and LocalHostName.

    HostName corresponds to what most platforms consider to be hostname.
    It controls the name used on the command line and SSH.

    However, macOS also has LocalHostName and ComputerName settings.
    LocalHostName controls the Bonjour/ZeroConf name, used by services
    like AirDrop. This class implements a method, _scrub_hostname(), that mimics
    the transformations macOS makes on hostnames when enterened in the Sharing
    preference pane. It replaces spaces with dashes and removes all special
    characters.

    ComputerName is the name used for user-facing GUI services, like the
    System Preferences/Sharing pane and when users connect to the Mac over the network.
    cs>tt|��|�|j�dd�|_d|_|�|jjd�|_	dS)N�scutilT)�HostName�ComputerName�
LocalHostNamer#)
r<r�rrr=r��
name_types�_scrub_hostnamer$�
scrubbed_namerr@rrr�szDarwinStrategy.__init__cCsxtrt�|||�St|t�r&t|t�s.td��t|�t|�krFtd��ttdd�|D�|��}|D]}d|t	|�<qb|S)Nz8replace_chars and replacement_chars must both be stringsz:replacement_chars must be the same length as replace_charscss|]}t|�VqdSr)�ord)r��crrr�	<genexpr>r�z3DarwinStrategy._make_translation.<locals>.<genexpr>)
r�str�	maketrans�
isinstancer�
ValueErrorr�dict�zipr�)r�
replace_charsZreplacement_chars�delete_chars�table�charrrr�_make_translationsz DarwinStrategy._make_translationcCsTt|�}d}d}|�|dt|�|�}|�|�}d|vrF|�dd�}q0|�d�}|S)z�
        LocalHostName only accepts valid DNS characters while HostName and ComputerName
        accept a much wider range of characters. This function aims to mimic how macOS
        translates a friendly name to the LocalHostName.
        z'"~`!@#$%^&*(){}[]/=?+\|-_ z.'�-z--rQ)r
r�r�	translate�replace�rstrip)rr#r�r�r�rrrr�s

zDarwinStrategy._scrub_hostnamecCsR|jddg}|j�|�\}}}|dkrFd|vrF|jjd|||fd�t|���S)N�--getr�rzHostName: not setz4Failed to get current hostname rc=%d, out=%s, err=%sr3�r�rrEr7rrFrGrrrr%)s
z#DarwinStrategy.get_current_hostnamecCsJ|jddg}|j�|�\}}}|dkr>|jjd|||fd�t|���S)Nr�r�rz6Failed to get permanent hostname rc=%d, out=%s, err=%sr3r�rGrrrr(1s
z%DarwinStrategy.get_permanent_hostnamecCs�|jD]x}|jd|g}|dkr0|�t|j��n|�t|��|j�|�\}}}|dkr|jjd�t|�t|�t|�|�d�qdS)Nz--setr�rz#Failed to set {3} to '{2}': {0} {1}r3)	r�r�rqrr�rrEr7�format)rr#Z
hostname_typerHrIrJrKrrrr)9s
z%DarwinStrategy.set_permanent_hostnamecCsdSrrr*rrrr'Dsz#DarwinStrategy.set_current_hostnamecCsdSrrr rrrrGsz&DarwinStrategy.update_current_hostnamecsb�jjd�t�fdd��jD��}t��fdd��jD��}||kr^�jjsX����d�_dS)Nr#c3s*|]"}�j��jd|g�d��VqdS)r��N)rrEr�rF)r�Z	name_typer rrr�Nr�z;DarwinStrategy.update_permanent_hostname.<locals>.<genexpr>c3s |]}|dkr�jn�VqdS)r�N)r�)r��n�r#rrrr�Qr�T)rr$�tupler�r&r)r)rZ	all_namesZexpected_namesrr�rrJs
z(DarwinStrategy.update_permanent_hostname)r-r.r/rerr�r�r%r(r)r'rrrNrrr@rr��sr�cs\eZdZdZdZdZeZ�fdd�Zdd�Z	dd	�Z
d
d�Zdd
�Zdd�Z
dd�Z�ZS)�Hostnamez�
    This is a generic Hostname manipulation class that is subclassed
    based on platform.

    A subclass may wish to set different strategy instance to self.strategy.

    All subclasses MUST define platform and distribution (which may be None).
    �GenericNcstt�}t||��|�Sr)rr�r<�__new__)�cls�args�kwargsZnew_clsr@rrr�hszHostname.__new__cCsz||_|jd|_|jd|_|jdurHt�dt|j}||�|_n.t��dkrjt	�
|�rjt|�|_n|�|�|_dS)Nr#�usez
%sStrategy�Linux)
rr$r#r��globals�STRATS�strategyr5r6r	Zis_systemd_managedrv�strategy_class)rrZstratrrrrls
zHostname.__init__cCs
|j��Sr)r�r!r rrrr!zsz.Hostname.update_current_and_permanent_hostnamecCs
|j��Sr)r�r%r rrrr%}szHostname.get_current_hostnamecCs|j�|�dSr)r�r'r*rrrr'�szHostname.set_current_hostnamecCs
|j��Sr)r�r(r rrrr(�szHostname.get_permanent_hostnamecCs|j�|�dSr)r�r)r*rrrr)�szHostname.set_permanent_hostname)r-r.r/rer5r8r0r�r�rr!r%r'r(r)rNrrr@rr�Zs	r�c@sbeZdZdZdZz6e�Zer>dee�kr4dkr>nneZ	ne
��Wne
y\eZ	Yn0dS)�SLESHostnamer�ZSlesr��N)r-r.r/r5r8rZdistribution_version�floatrcr�r�r0rrrrr��s 
r�c@seZdZdZdZeZdS)�RHELHostnamer�ZRedhatN�r-r.r/r5r8rfr�rrrrr��sr�c@seZdZdZdZeZdS)�CentOSHostnamer�ZCentosNr�rrrrr��sr�c@seZdZdZdZeZdS)�AnolisOSHostnamer�ZAnolisNr�rrrrr��sr�c@seZdZdZdZeZdS)�CloudlinuxserverHostnamer�ZCloudlinuxserverNr�rrrrr��sr�c@seZdZdZdZeZdS)�CloudlinuxHostnamer�Z
CloudlinuxNr�rrrrr��sr�c@seZdZdZdZeZdS)�AlinuxHostnamer�ZAlinuxNr�rrrrr��sr�c@seZdZdZdZeZdS)�ScientificHostnamer�Z
ScientificNr�rrrrr��sr�c@seZdZdZdZeZdS)�OracleLinuxHostnamer�ZOracleNr�rrrrr��sr�c@seZdZdZdZeZdS)�VirtuozzoLinuxHostnamer�Z	VirtuozzoNr�rrrrr��sr�c@seZdZdZdZeZdS)�AmazonLinuxHostnamer�ZAmazonNr�rrrrr��sr�c@seZdZdZdZeZdS)�DebianHostnamer�ZDebianN�r-r.r/r5r8rOr�rrrrr��sr�c@seZdZdZdZeZdS)�
KylinHostnamer�ZKylinNr�rrrrr��sr�c@seZdZdZdZeZdS)�CumulusHostnamer�z
Cumulus-linuxNr�rrrrr��sr�c@seZdZdZdZeZdS)�KaliHostnamer�ZKaliNr�rrrrr��sr�c@seZdZdZdZeZdS)�ParrotHostnamer�ZParrotNr�rrrrr��sr�c@seZdZdZdZeZdS)�UbuntuHostnamer�ZUbuntuNr�rrrrr��sr�c@seZdZdZdZeZdS)�LinuxmintHostnamer�Z	LinuxmintNr�rrrrr��sr�c@seZdZdZdZeZdS)�LinaroHostnamer�ZLinaroNr�rrrrr��sr�c@seZdZdZdZeZdS)�DevuanHostnamer�ZDevuanNr�rrrrr�sr�c@seZdZdZdZeZdS)�RaspbianHostnamer�ZRaspbianNr�rrrrr�
sr�c@seZdZdZdZeZdS)�UosHostnamer�ZUosNr�rrrrr�sr�c@seZdZdZdZeZdS)�DeepinHostnamer�ZDeepinNr�rrrrr�sr�c@seZdZdZdZeZdS)�GentooHostnamer�ZGentooN)r-r.r/r5r8r�r�rrrrr�sr�c@seZdZdZdZeZdS)�ALTLinuxHostnamer�ZAltlinuxNr�rrrrr�"sr�c@seZdZdZdZeZdS)�AlpineLinuxHostnamer�rN)r-r.r/r5r8rur�rrrrr�(sr�c@seZdZdZdZeZdS)�OpenBSDHostnamerN)r-r.r/r5r8r�r�rrrrr�.sr�c@seZdZdZdZeZdS)�SolarisHostnameZSunOSN)r-r.r/r5r8r�r�rrrrr�4sr�c@seZdZdZdZeZdS)�FreeBSDHostnamerN�r-r.r/r5r8r�r�rrrrr�:sr�c@seZdZdZdZeZdS)�NetBSDHostnameZNetBSDNr�rrrrr�@sr�c@seZdZdZdZeZdS)�NeonHostnamer�ZNeonNr�rrrrr�Fsr�c@seZdZdZdZeZdS)�DarwinHostnamerN)r-r.r/r5r8r�r�rrrrr�Lsr�c@seZdZdZdZeZdS)�VoidLinuxHostnamer�ZVoidNr�rrrrr�Rsr�c@seZdZdZdZeZdS)�PopHostnamer�ZPopNr�rrrrr�Xsr�c@seZdZdZdZeZdS)�EurolinuxHostnamer�Z	EurolinuxNr�rrrrr�^sr�cCs�tttddd�tdtt���d�d�dd�}t|�}|jd}|��}|��}|�	�}||krd|}n||krr|}n|}t||t|�
d�d	|t��d�
t���
d�d
d��d�d�}|r�d
|dd
|dd�|d<|jfi|��dS)Nr�T)�type�required)r��choices)r#r�)Z
argument_specZsupports_check_moder#�.rr�)Zansible_hostnameZansible_nodenameZansible_fqdnZansible_domain)rr#Z
ansible_factszhostname = r�)Zafter�before�diff)rr��listr��keysr�r$r%r(r!rk�socketZgetfqdnr�Z	exit_json)rr:r#Zcurrent_hostnameZpermanent_hostnamerZname_before�kwrrr�mainds:
��
��

�
r��__main__)WZ
__future__rrrr�Z
__metaclass__Z
DOCUMENTATIONZEXAMPLESrVr5r�r[Z"ansible.module_utils.compat.typingZmodule_utils�compat�typing�tZansible.module_utils.basicrrrZ$ansible.module_utils.common.sys_inforZ-ansible.module_utils.facts.system.service_mgrr	Z ansible.module_utils.facts.utilsr
rZansible.module_utils._textrr
Zansible.module_utils.sixrrr��objectrr0r9rOrcrfrurvr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r-rrrr�<module>s�/�'!,2'	#<o0'