403Webshell
Server IP : 80.87.202.40  /  Your IP : 216.73.216.169
Web Server : Apache
System : Linux rospirotorg.ru 5.14.0-539.el9.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Dec 5 22:26:13 UTC 2024 x86_64
User : bitrix ( 600)
PHP Version : 8.2.27
Disable Function : NONE
MySQL : OFF |  cURL : ON |  WGET : ON |  Perl : ON |  Python : OFF |  Sudo : ON |  Pkexec : ON
Directory :  /lib/python3.11/site-packages/ansible/modules/__pycache__/

Upload File :
current_dir [ Writeable] document_root [ Writeable]

 

Command :


[ Back ]     

Current File : /lib/python3.11/site-packages/ansible/modules/__pycache__/hostname.cpython-311.opt-1.pyc
�

���c{p��`�ddlmZmZmZeZdZdZddlZddl	Z	ddl
Z
ddlZddlm
cmcmZddlmZmZmZddlmZddlmZddlmZmZdd	lmZmZdd
lm Z m!Z!ddd
ddddddddddd�
Z"Gd�de#��Z$Gd�de$��Z%Gd�de$��Z&Gd�de$��Z'Gd�de'��Z(Gd �d!e$��Z)Gd"�d#e'��Z*Gd$�d%e$��Z+Gd&�d'e$��Z,Gd(�d)e'��Z-Gd*�d+e$��Z.Gd,�d-e$��Z/Gd.�d/e$��Z0Gd0�d1e#��Z1Gd2�d3e1��Z2Gd4�d5e1��Z3Gd6�d7e1��Z4Gd8�d9e1��Z5Gd:�d;e1��Z6Gd<�d=e1��Z7Gd>�d?e1��Z8Gd@�dAe1��Z9GdB�dCe1��Z:GdD�dEe1��Z;GdF�dGe1��Z<GdH�dIe1��Z=GdJ�dKe1��Z>GdL�dMe1��Z?GdN�dOe1��Z@GdP�dQe1��ZAGdR�dSe1��ZBGdT�dUe1��ZCGdV�dWe1��ZDGdX�dYe1��ZEGdZ�d[e1��ZFGd\�d]e1��ZGGd^�d_e1��ZHGd`�dae1��ZIGdb�dce1��ZJGdd�dee1��ZKGdf�dge1��ZLGdh�die1��ZMGdj�dke1��ZNGdl�dme1��ZOGdn�doe1��ZPGdp�dqe1��ZQGdr�dse1��ZRGdt�due1��ZSGdv�dwe1��ZTdx�ZUeVdykreU��dSdS)z�)�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�Alpine�Systemd�FreeBSD�Base�Darwin�OpenBSD�OpenRC�RedHat�SLES�Solaris)
�alpine�debian�freebsd�generic�macos�macosx�darwin�openbsd�openrc�redhat�sles�solaris�systemdc�>�eZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	S)
�BaseStrategyc�"�||_d|_dS)NF)�module�changed)�selfr+s  �=/usr/lib/python3.11/site-packages/ansible/modules/hostname.py�__init__zBaseStrategy.__init__is����������c�`�|���|���|jS�N)�update_current_hostname�update_permanent_hostnamer,�r-s r.�%update_current_and_permanent_hostnamez2BaseStrategy.update_current_and_permanent_hostnamems.���$�$�&�&�&��&�&�(�(�(��|�r0c��|jjd}|���}||kr*|jjs|�|��d|_dSdS�N�nameT)r+�params�get_current_hostname�
check_mode�set_current_hostnamer,)r-r9�current_names   r.r3z$BaseStrategy.update_current_hostnamersa���{�!�&�)���0�0�2�2���4����;�)�
0��)�)�$�/�/�/��D�L�L�L� �r0c��|jjd}|���}||kr*|jjs|�|��d|_dSdSr8)r+r:�get_permanent_hostnamer<�set_permanent_hostnamer,)r-r9�permanent_names   r.r4z&BaseStrategy.update_permanent_hostnamezsa���{�!�&�)���4�4�6�6���T�!�!��;�)�
2��+�+�D�1�1�1��D�L�L�L�"�!r0c�*�|���Sr2)r@r5s r.r;z!BaseStrategy.get_current_hostname�s���*�*�,�,�,r0c��dSr2��r-r9s  r.r=z!BaseStrategy.set_current_hostname�����r0c��t�r2��NotImplementedErrorr5s r.r@z#BaseStrategy.get_permanent_hostname����!�!r0c��t�r2rIrFs  r.rAz#BaseStrategy.set_permanent_hostname�rKr0N)�__name__�
__module__�__qualname__r/r6r3r4r;r=r@rArEr0r.r)r)hs�������������
 � � � � � �-�-�-�
�
�
�"�"�"�"�"�"�"�"r0r)c�>�eZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	S)
�UnimplementedStrategyc�.�|���dSr2��unimplemented_errorr5s r.r6z;UnimplementedStrategy.update_current_and_permanent_hostname����� � �"�"�"�"�"r0c�.�|���dSr2rSr5s r.r3z-UnimplementedStrategy.update_current_hostname�rUr0c�.�|���dSr2rSr5s r.r4z/UnimplementedStrategy.update_permanent_hostname�rUr0c�.�|���dSr2rSr5s r.r;z*UnimplementedStrategy.get_current_hostname�rUr0c�.�|���dSr2rSrFs  r.r=z*UnimplementedStrategy.set_current_hostname�rUr0c�.�|���dSr2rSr5s r.r@z,UnimplementedStrategy.get_permanent_hostname�rUr0c�.�|���dSr2rSrFs  r.rAz,UnimplementedStrategy.set_permanent_hostname�rUr0c��tj��}t��}|�	|�d|�d�}n|}|j�d|z���dS)Nz (�)z-hostname module cannot be used on platform %s��msg)�platform�systemrr+�	fail_json)r-ra�distribution�msg_platforms    r.rTz)UnimplementedStrategy.unimplemented_error�so����"�"��'�)�)���#�(.������=�L�L�!�L�����?�,�N�	�	P�	P�	P�	P�	Pr0N)rMrNrOr6r3r4r;r=r@rArTrEr0r.rQrQ�s�������#�#�#�#�#�#�#�#�#�#�#�#�#�#�#�#�#�#�#�#�#�P�P�P�P�Pr0rQc�:��eZdZdZ�fd�Zd�Zd�Zd�Zd�Z�xZ	S)�CommandStrategy�hostnamec���tt|���|��|j�|jd��|_dS�NT)�superrfr/r+�get_bin_path�COMMAND�hostname_cmd�r-r+�	__class__s  �r.r/zCommandStrategy.__init__��C���
�o�t�$�$�-�-�f�5�5�5� �K�4�4�T�\�4�H�H����r0c���|jg}|j�|��\}}}|dkr!|j�d|||fz���t	|�����S�Nr�$Command failed rc=%d, out=%s, err=%sr^�rmr+�run_commandrbr
�strip�r-�cmd�rc�out�errs     r.r;z$CommandStrategy.get_current_hostname��q��� �!���{�.�.�s�3�3���C��
��7�7��K�!�!�&L�PR�TW�Y\�~�&]�!�^�^�^���~�~�#�#�%�%�%r0c��|j|g}|j�|��\}}}|dkr#|j�d|||fz���dSdSrr�rmr+rurb�r-r9rxryrzr{s      r.r=z$CommandStrategy.set_current_hostname��h��� �$�'���{�.�.�s�3�3���C��
��7�7��K�!�!�&L�PR�TW�Y\�~�&]�!�^�^�^�^�^��7r0c��dS)N�UNKNOWNrEr5s r.r@z&CommandStrategy.get_permanent_hostname�s���yr0c��dSr2rErFs  r.rAz&CommandStrategy.set_permanent_hostname�rGr0)
rMrNrOrlr/r;r=r@rA�
__classcell__�ros@r.rfrf�s���������G�I�I�I�I�I�&�&�&�_�_�_����
�
�
�
�
�
�
r0rfc��eZdZdZd�Zd�ZdS)�FileStrategy�
/etc/hostnamec�(�tj�|j��sdS	t	|jdd���S#t
$rH}|j�dt|��ztj
�����Yd}~dSd}~wwxYw)N�T)�defaultrv�failed to read hostname: %s�r_�	exception)�os�path�isfile�FILEr�	Exceptionr+rbr
�	traceback�
format_exc)r-�es  r.r@z#FileStrategy.get_permanent_hostname�s����w�~�~�d�i�(�(�	��2�	2�#�D�I�r��F�F�F�F���	2�	2�	2��K�!�!�1�I�a�L�L�@�#�.�0�0�
"�
2�
2�
2�
2�
2�
2�
2�
2�
2�����	2���s�?�
B�	=B�Bc�>�	t|jd��5}|�d|z��ddd��dS#1swxYwYdS#t$rH}|j�dt
|��ztj�����Yd}~dSd}~wwxYw)N�w+z%s
�failed to update hostname: %sr�)	�openr��writer�r+rbr
r�r�)r-r9�fr�s    r.rAz#FileStrategy.set_permanent_hostname�s��	2��d�i��&�&�
'�!������
�&�&�&�
'�
'�
'�
'�
'�
'�
'�
'�
'�
'�
'�
'����
'�
'�
'�
'�
'�
'���	2�	2�	2��K�!�!�3�i��l�l�B�#�.�0�0�
"�
2�
2�
2�
2�
2�
2�
2�
2�
2�����	2���s7�A
�=�A
�A�A
�A�A
�

B�=B�BN)rMrNrOr�r@rArEr0r.r�r��s7�������D�	2�	2�	2�2�2�2�2�2r0r�c��eZdZdZdZdS)�SLESStrategyzW
    This is a SLES Hostname strategy class - it edits the
    /etc/HOSTNAME file.
    z
/etc/HOSTNAMEN�rMrNrO�__doc__r�rEr0r.r�r��s���������D�D�Dr0r�c�"�eZdZdZdZd�Zd�ZdS)�RedHatStrategyzb
    This is a Redhat Hostname strategy class - it edits the
    /etc/sysconfig/network file.
    z/etc/sysconfig/networkc���	t|j��D]f}t|�����}|�d��r.|�d��\}}|���cS�g|j�d|jz��dS#t$rH}|j�dt|��ztj
�����Yd}~dSd}~wwxYw)N�HOSTNAME�=z%Unable to locate HOSTNAME entry in %sr�r�)r�NETWORK_FILEr
rv�
startswith�splitr+rbr�r�r�)r-�line�k�vr�s     r.r@z%RedHatStrategy.get_permanent_hostname�s!��	2�&�t�'8�9�9�
%�
%�� ����,�,�.�.���?�?�:�.�.�%��:�:�c�?�?�D�A�q��7�7�9�9�$�$�$�%�
�K�!�!�7�$�:K�K�
�
�
�
�
���	2�	2�	2��K�!�!�1�I�a�L�L�@�#�.�0�0�
"�
2�
2�
2�
2�
2�
2�
2�
2�
2�����	2���s�A9B!�<#B!�!
C3�+=C.�.C3c��	g}d}t|jd���pd}|�d��D]h}t|��}|����d��r|�d|z��d}�S|�|���i|s|�d|z��t|jd��5}|�|��ddd��dS#1swxYwYdS#t$rH}|j
�dt|��ztj
���	��Yd}~dSd}~wwxYw)
NF�rvr�Tr�zHOSTNAME=%s
r�r�r�)rr��
splitlinesr
rvr��appendr��
writelinesr�r+rbr�r�)r-r9�lines�found�contentr�r�r�s        r.rAz%RedHatStrategy.set_permanent_hostnames���	2��E��E�&�t�'8��F�F�F�L�"�G��*�*�4�0�0�
'�
'�� ������:�:�<�<�*�*�:�6�6�'��L�L��4�!7�8�8�8� �E�E��L�L��&�&�&�&��
5����_�t�3�4�4�4��d�'��.�.�
$�!����U�#�#�#�
$�
$�
$�
$�
$�
$�
$�
$�
$�
$�
$�
$����
$�
$�
$�
$�
$�
$���	2�	2�	2��K�!�!�3�i��l�l�B�#�.�0�0�
"�
2�
2�
2�
2�
2�
2�
2�
2�
2�����	2���s<�C	C;�C.�!C;�.C2�2C;�5C2�6C;�;
E
�=E�E
N)rMrNrOr�r�r@rArEr0r.r�r��sC��������,�L�
2�
2�
2�2�2�2�2�2r0r�c�*��eZdZdZdZdZ�fd�Z�xZS)�AlpineStrategyz�
    This is a Alpine Linux Hostname manipulation strategy class - it edits
    the /etc/hostname file then run hostname -F /etc/hostname.
    r�rgc�:��tt|���|��|j�|jd��}|d|jg}|j�|��\}}}|dkr#|j�d|||fz���dSdS)NTz-Frrsr^)	rjr�r=r+rkrlr�rurb)r-r9rmrxryrzr{ros       �r.r=z#AlpineStrategy.set_current_hostname s����
�n�d�#�#�8�8��>�>�>��{�/�/���d�C�C���T�4�9�-���{�.�.�s�3�3���C��
��7�7��K�!�!�&L�PR�TW�Y\�~�&]�!�^�^�^�^�^��7r0)rMrNrOr�r�rlr=r�r�s@r.r�r�sW���������
�D��G�_�_�_�_�_�_�_�_�_r0r�c�D��eZdZdZdZ�fd�Zd�Zd�Zd�Zd�Z	d�Z
�xZS)	�SystemdStrategyzg
    This is a Systemd hostname manipulation strategy class - it uses
    the hostnamectl command.
    �hostnamectlc���tt|���|��|j�|jd��|_dSri)rjr�r/r+rkrl�hostnamectl_cmdrns  �r.r/zSystemdStrategy.__init__2sC���
�o�t�$�$�-�-�f�5�5�5�#�{�7�7���d�K�K����r0c���|jddg}|j�|��\}}}|dkr!|j�d|||fz���t	|�����S)N�--transient�statusrrsr^�r�r+rurbr
rvrws     r.r;z$SystemdStrategy.get_current_hostname6su���#�]�H�=���{�.�.�s�3�3���C��
��7�7��K�!�!�&L�PR�TW�Y\�~�&]�!�^�^�^���~�~�#�#�%�%�%r0c��t|��dkr|j�d���|jdd|g}|j�|��\}}}|dkr#|j�d|||fz���dSdS)N�@�Oname cannot be longer than 64 characters on systemd servers, try a shorter namer^r��set-hostnamerrs��lenr+rbr�rurs      r.r=z$SystemdStrategy.set_current_hostname=s����t�9�9�r�>�>��K�!�!�&w�!�x�x�x��#�]�N�D�I���{�.�.�s�3�3���C��
��7�7��K�!�!�&L�PR�TW�Y\�~�&]�!�^�^�^�^�^��7r0c���|jddg}|j�|��\}}}|dkr!|j�d|||fz���t	|�����S)N�--staticr�rrsr^r�rws     r.r@z&SystemdStrategy.get_permanent_hostnameEsu���#�Z��:���{�.�.�s�3�3���C��
��7�7��K�!�!�&L�PR�TW�Y\�~�&]�!�^�^�^���~�~�#�#�%�%�%r0c��t|��dkr|j�d���|jddd|g}|j�|��\}}}|dkr#|j�d|||fz���dSdS)	Nr�r�r^z--prettyr�r�rrsr�rs      r.rAz&SystemdStrategy.set_permanent_hostnameLs����t�9�9�r�>�>��K�!�!�&w�!�x�x�x��#�Z��^�T�R���{�.�.�s�3�3���C��
��7�7��K�!�!�&L�PR�TW�Y\�~�&]�!�^�^�^�^�^��7r0c�`�|���|���|jSr2)r4r3r,r5s r.r6z5SystemdStrategy.update_current_and_permanent_hostnameTs0��	
�&�&�(�(�(��$�$�&�&�&��|�r0)rMrNrOr�rlr/r;r=r@rAr6r�r�s@r.r�r�*s����������
�G�L�L�L�L�L�&�&�&�_�_�_�&�&�&�_�_�_�������r0r�c�"�eZdZdZdZd�Zd�ZdS)�OpenRCStrategyzv
    This is a Gentoo (OpenRC) Hostname manipulation strategy class - it edits
    the /etc/conf.d/hostname file.
    z/etc/conf.d/hostnamec��tj�|j��sdS	t	|j��D]J}|���}|�d��r|dd��d��cS�KdS#t$rH}|j�	dt|��ztj�����Yd}~dSd}~wwxYw�Nr��	hostname=�
�"r�r��
r�r�r�r�rrvr�r�r+rbr
r�r��r-r�r�s   r.r@z%OpenRCStrategy.get_permanent_hostnamed����w�~�~�d�i�(�(�	��2�	2�&�t�y�1�1�
0�
0���z�z�|�|���?�?�;�/�/�0�����9�?�?�3�/�/�/�/�/�0�
0�
0���	2�	2�	2��K�!�!�1�I�a�L�L�@�#�.�0�0�
"�
2�
2�
2�
2�
2�
2�
2�
2�
2�����	2�����AB	�B	�	
C�=C�Cc��	d�t|j��D��}t|��D]$\}}|�d��r
d|z||<n�%t	|jd��5}|�d�|��dz��ddd��dS#1swxYwYdS#t$rH}|j�	dt|��ztj�����Yd}~dSd}~wwxYw)Nc�6�g|]}|�����SrEr���.0�xs  r.�
<listcomp>z9OpenRCStrategy.set_permanent_hostname.<locals>.<listcomp>ts ��B�B�B�1�Q�W�W�Y�Y�B�B�Br0r��
hostname="%s"�w�
r�r�)
rr��	enumerater�r�r��joinr�r+rbr
r�r��r-r9r��ir�r�r�s       r.rAz%OpenRCStrategy.set_permanent_hostnamersy��
	2�B�B��t�y�(A�(A�B�B�B�E�$�U�+�+�
�
���4��?�?�;�/�/��.��5�E�!�H��E���d�i��%�%�
1������	�	�%�(�(�4�/�0�0�0�
1�
1�
1�
1�
1�
1�
1�
1�
1�
1�
1�
1����
1�
1�
1�
1�
1�
1���	2�	2�	2��K�!�!�3�i��l�l�B�#�.�0�0�
"�
2�
2�
2�
2�
2�
2�
2�
2�
2�����	2���s<�A'B/�),B"�B/�"B&�&B/�)B&�*B/�/
D�9=C<�<DN)rMrNrOr�r�r@rArEr0r.r�r�\sC��������
"�D�2�2�2�2�2�2�2�2r0r�c��eZdZdZdZdS)�OpenBSDStrategyzl
    This is a OpenBSD family Hostname manipulation strategy class - it edits
    the /etc/myname file.
    z/etc/mynameNr�rEr0r.r�r��s��������
�D�D�Dr0r�c�8��eZdZdZdZ�fd�Zd�Zd�Zd�Z�xZ	S)�SolarisStrategyzn
    This is a Solaris11 or later Hostname manipulation strategy class - it
    execute hostname command.
    rgc���tt|���|��|j�|jd��|_dSri)rjr�r/r+rkrlrmrns  �r.r/zSolarisStrategy.__init__�rpr0c��d}|j||g}|j�|��\}}}|dkr#|j�d|||fz���dSdS)Nz-trrsr^r~)r-r9�
cmd_optionrxryrzr{s       r.r=z$SolarisStrategy.set_current_hostname�so���
�� �*�d�3���{�.�.�s�3�3���C��
��7�7��K�!�!�&L�PR�TW�Y\�~�&]�!�^�^�^�^�^��7r0c���d}d}d|�d|��}|j�|d���\}}}|dkr!|j�d|||fz�	��t|�����S)
Nzsvc:/system/identity:nodezconfig/nodenamez/usr/sbin/svccfg -s z listprop -o value T)�use_unsafe_shellrrsr^)r+rurbr
rv)r-�fmri�patternrxryrzr{s       r.r@z&SolarisStrategy.get_permanent_hostname�s���*��#���?C�t�t�W�W�M���{�.�.�s�T�.�J�J���C��
��7�7��K�!�!�&L�PR�TW�Y\�~�&]�!�^�^�^���~�~�#�#�%�%�%r0c��|j|g}|j�|��\}}}|dkr#|j�d|||fz���dSdSrrr~rs      r.rAz&SolarisStrategy.set_permanent_hostname�r�r0)
rMrNrOr�rlr/r=r@rAr�r�s@r.r�r��s����������
�G�I�I�I�I�I�_�_�_�&�&�&�_�_�_�_�_�_�_r0r�c�B��eZdZdZdZdZ�fd�Zd�Zd�Zd�Z	d�Z
�xZS)	�FreeBSDStrategyzq
    This is a FreeBSD hostname manipulation strategy class - it edits
    the /etc/rc.conf.d/hostname file.
    z/etc/rc.conf.d/hostnamergc���tt|���|��|j�|jd��|_dSri)rjr�r/r+rkrlrmrns  �r.r/zFreeBSDStrategy.__init__�rpr0c���|jg}|j�|��\}}}|dkr!|j�d|||fz���t	|�����Srrrtrws     r.r;z$FreeBSDStrategy.get_current_hostname�r|r0c��|j|g}|j�|��\}}}|dkr#|j�d|||fz���dSdSrrr~rs      r.r=z$FreeBSDStrategy.set_current_hostname�r�r0c��tj�|j��sdS	t	|j��D]J}|���}|�d��r|dd��d��cS�KdS#t$rH}|j�	dt|��ztj�����Yd}~dSd}~wwxYwr�r�r�s   r.r@z&FreeBSDStrategy.get_permanent_hostname�r�r�c�^�	tj�|j��rSd�t	|j��D��}t|��D]$\}}|�d��r
d|z||<n�%nd|zg}t|jd��5}|�d�	|��dz��ddd��dS#1swxYwYdS#t$rH}|j�dt|��ztj�����Yd}~dSd}~wwxYw)Nc�6�g|]}|�����SrEr�r�s  r.r�z:FreeBSDStrategy.set_permanent_hostname.<locals>.<listcomp>�s ��F�F�F�q������F�F�Fr0r�r�r�r�r�r�)r�r�r�r�rr�r�r�r�r�r�r+rbr
r�r�r�s       r.rAz&FreeBSDStrategy.set_permanent_hostname�s���	2��w�~�~�d�i�(�(�
1�F�F�N�4�9�,E�,E�F�F�F��(��/�/���G�A�t����{�3�3��#2�T�#9��a������)�4�/�0���d�i��%�%�
1������	�	�%�(�(�4�/�0�0�0�
1�
1�
1�
1�
1�
1�
1�
1�
1�
1�
1�
1����
1�
1�
1�
1�
1�
1���	2�	2�	2��K�!�!�3�i��l�l�B�#�.�0�0�
"�
2�
2�
2�
2�
2�
2�
2�
2�
2�����	2���s<�BC�,C
�C�
C�C�C�C�
D,�$=D'�'D,)rMrNrOr�r�rlr/r;r=r@rAr�r�s@r.r�r��s����������
%�D��G�I�I�I�I�I�&�&�&�_�_�_�2�2�2�2�2�2�2�2�2�2r0r�c�R��eZdZdZ�fd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Z�xZ
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.
    c���tt|���|��|j�dd��|_d|_|�|jjd��|_	dS)N�scutilT)�HostName�ComputerName�
LocalHostNamer9)
rjr�r/r+rkr��
name_types�_scrub_hostnamer:�
scrubbed_namerns  �r.r/zDarwinStrategy.__init__�sg���
�n�d�#�#�,�,�V�4�4�4��k�.�.�x��>�>���G���!�1�1�$�+�2D�V�2L�M�M����r0c��trt�|||��St|t��rt|t��std���t
|��t
|��krtd���ttd�|D��|����}|D]}d|t|��<�|S)Nz8replace_chars and replacement_chars must both be stringsz:replacement_chars must be the same length as replace_charsc3�4K�|]}t|��V��dSr2)�ord)r��cs  r.�	<genexpr>z3DarwinStrategy._make_translation.<locals>.<genexpr>s(����8�8�Q�#�a�&�&�8�8�8�8�8�8r0)
r�str�	maketrans�
isinstancer�
ValueErrorr��dict�zipr)r-�
replace_chars�replacement_chars�delete_chars�table�chars      r.�_make_translationz DarwinStrategy._make_translations����	Q��=�=��0A�<�P�P�P��-��3�3�	Y�:�FW�Yb�;c�;c�	Y��W�X�X�X��}����%6�!7�!7�7�7��Y�Z�Z�Z��S�8�8�-�8�8�8�:K�L�L�M�M�� �	$�	$�D�#�E�#�d�)�)����r0c�
�t|��}d}d}|�|dt|��z|��}|�|��}d|vr|�dd��}d|v�|�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--r�)rrr��	translate�replace�rstrip)r-r9rr
rs     r.r�zDarwinStrategy._scrub_hostnames����t�}�}��8�
����&�&�}�d�S��=O�=O�6O�Q]�^�^���~�~�e�$�$����o�o��<�<���,�,�D���o�o��{�{�3�����r0c���|jddg}|j�|��\}}}|dkr%d|vr!|j�d|||fz���t	|�����S)N�--getr�rzHostName: not setz4Failed to get current hostname rc=%d, out=%s, err=%sr^�r�r+rurbr
rvrws     r.r;z#DarwinStrategy.get_current_hostname)s����{�G�Z�0���{�.�.�s�3�3���C��
��7�7�*�#�5�5��K�!�!�&\�`b�dg�il�_m�&m�!�n�n�n���~�~�#�#�%�%�%r0c���|jddg}|j�|��\}}}|dkr!|j�d|||fz���t	|�����S)Nrr�rz6Failed to get permanent hostname rc=%d, out=%s, err=%sr^rrws     r.r@z%DarwinStrategy.get_permanent_hostname1su���{�G�^�4���{�.�.�s�3�3���C��
��7�7��K�!�!�&^�bd�fi�kn�ao�&o�!�p�p�p���~�~�#�#�%�%�%r0c
���|jD]�}|jd|g}|dkr(|�t|j����n"|�t|����|j�|��\}}}|dkrX|j�d�t|��t|��t|��|�������dS)Nz--setr�rz#Failed to set {3} to '{2}': {0} {1}r^)	r�r�r�r
r�r+rurb�format)r-r9�
hostname_typerxryrzr{s       r.rAz%DarwinStrategy.set_permanent_hostname9s��!�_�	X�	X�M��;���7�C���/�/��
�
�9�T�%7�8�8�9�9�9�9��
�
�9�T�?�?�+�+�+��;�2�2�3�7�7�L�B��S��Q�w�w���%�%�*O�*V�*V�W`�ad�We�We�gp�qt�gu�gu�xA�BF�xG�xG�IV�+W�+W�%�X�X�X��	X�	Xr0c��dSr2rErFs  r.r=z#DarwinStrategy.set_current_hostnameDrGr0c��dSr2rEr5s r.r3z&DarwinStrategy.update_current_hostnameGrGr0c�����jjd�t�fd��jD����}t��fd��jD����}||kr*�jjs�����d�_dSdS)Nr9c3��K�|]>}�j��jd|g��d���V��?dS)r�N)r+rur�rv)r��	name_typer-s  �r.rz;DarwinStrategy.update_permanent_hostname.<locals>.<genexpr>Nsg�����B�B�dm�$�+�1�1�4�;���2S�T�T�UV�W�]�]�_�_�B�B�B�B�B�Br0c3�6�K�|]}|dkr�jn�V��dS)r�N)r�)r��nr9r-s  ��r.rz;DarwinStrategy.update_permanent_hostname.<locals>.<genexpr>Qs6�����m�m�XY�Q�/�5I�5I�t�1�1�t�m�m�m�m�m�mr0T)r+r:�tupler�r<rAr,)r-�	all_names�expected_namesr9s`  @r.r4z(DarwinStrategy.update_permanent_hostnameJs������{�!�&�)���B�B�B�B�qu�rA�B�B�B�B�B�	��m�m�m�m�m�]a�]l�m�m�m�m�m����&�&��;�)�
2��+�+�D�1�1�1��D�L�L�L�'�&r0)rMrNrOr�r/rr�r;r@rAr=r3r4r�r�s@r.r�r��s����������$N�N�N�N�N�
�
�
����*&�&�&�&�&�&�	X�	X�	X�
�
�
�
�
�
�
 �
 �
 �
 �
 �
 �
 r0r�c�R��eZdZdZdZdZeZ�fd�Zd�Z	d�Z
d�Zd�Zd	�Z
d
�Z�xZS)�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).
    �GenericNc�r��tt��}t||���|��Sr2)r	r)rj�__new__)�cls�args�kwargs�new_clsros    �r.r,zHostname.__new__hs.���'��1�1���S�'�"�"�*�*�7�3�3�3r0c��||_|jd|_|jd|_|j�9t	��dt
|jz}||��|_dStj��dkr*tj
|��rt|��|_dS|�|��|_dS)Nr9�usez
%sStrategy�Linux)
r+r:r9r2�globals�STRATS�strategyr`rar
�is_systemd_managedr��strategy_class)r-r+�strats   r.r/zHostname.__init__ls�������M�&�)��	��=��'����8���I�I�l�V�D�H�-=�=�>�E�!�E�&�M�M�D�M�M�M�
�_�
�
�'�
)�
)�.E�.X�Y_�.`�.`�
)�+�F�3�3�D�M�M�M� �/�/��7�7�D�M�M�Mr0c�4�|j���Sr2)r6r6r5s r.r6z.Hostname.update_current_and_permanent_hostnamezs���}�B�B�D�D�Dr0c�4�|j���Sr2)r6r;r5s r.r;zHostname.get_current_hostname}s���}�1�1�3�3�3r0c�:�|j�|��dSr2)r6r=rFs  r.r=zHostname.set_current_hostname�s���
�*�*�4�0�0�0�0�0r0c�4�|j���Sr2)r6r@r5s r.r@zHostname.get_permanent_hostname�s���}�3�3�5�5�5r0c�:�|j�|��dSr2)r6rArFs  r.rAzHostname.set_permanent_hostname�s���
�,�,�T�2�2�2�2�2r0)rMrNrOr�r`rcrQr8r,r/r6r;r=r@rAr�r�s@r.r)r)Zs�����������H��L�*�N�4�4�4�4�4�8�8�8�E�E�E�4�4�4�1�1�1�6�6�6�3�3�3�3�3�3�3r0r)c��eZdZdZdZ	e��Zerdee��cxkrdkrnneZ	dSe
���#e
$reZ	YdSwxYw)�SLESHostnamer3�Slesr��N)rMrNrOr`rcr�distribution_version�floatr�r8rrQrEr0r.r@r@�s��������H��L�/�7�7�9�9���	�B�%�%�0D�*E�*E�$K�$K�$K�$K��$K�$K�$K�$K�$K�)�N�N�N��*�,�,����/�/�/�.�����/���s�'=�
=�A�Ar@c��eZdZdZdZeZdS)�RHELHostnamer3�RedhatN�rMrNrOr`rcr�r8rEr0r.rFrF���������H��L�#�N�N�Nr0rFc��eZdZdZdZeZdS)�CentOSHostnamer3�CentosNrHrEr0r.rKrK�rIr0rKc��eZdZdZdZeZdS)�AnolisOSHostnamer3�AnolisNrHrEr0r.rNrN�rIr0rNc��eZdZdZdZeZdS)�CloudlinuxserverHostnamer3�CloudlinuxserverNrHrEr0r.rQrQ�s�������H�%�L�#�N�N�Nr0rQc��eZdZdZdZeZdS)�CloudlinuxHostnamer3�
CloudlinuxNrHrEr0r.rTrT���������H��L�#�N�N�Nr0rTc��eZdZdZdZeZdS)�AlinuxHostnamer3�AlinuxNrHrEr0r.rXrX�rIr0rXc��eZdZdZdZeZdS)�ScientificHostnamer3�
ScientificNrHrEr0r.r[r[�rVr0r[c��eZdZdZdZeZdS)�OracleLinuxHostnamer3�OracleNrHrEr0r.r^r^�rIr0r^c��eZdZdZdZeZdS)�VirtuozzoLinuxHostnamer3�	VirtuozzoNrHrEr0r.rara���������H��L�#�N�N�Nr0rac��eZdZdZdZeZdS)�AmazonLinuxHostnamer3�AmazonNrHrEr0r.rere�rIr0rec��eZdZdZdZeZdS)�DebianHostnamer3�DebianN�rMrNrOr`rcr�r8rEr0r.rhrh���������H��L�!�N�N�Nr0rhc��eZdZdZdZeZdS)�
KylinHostnamer3�KylinNrjrEr0r.rmrm�s�������H��L�!�N�N�Nr0rmc��eZdZdZdZeZdS)�CumulusHostnamer3z
Cumulus-linuxNrjrEr0r.rprp�s�������H�"�L�!�N�N�Nr0rpc��eZdZdZdZeZdS)�KaliHostnamer3�KaliNrjrEr0r.rrrr���������H��L�!�N�N�Nr0rrc��eZdZdZdZeZdS)�ParrotHostnamer3�ParrotNrjrEr0r.rvrv�rkr0rvc��eZdZdZdZeZdS)�UbuntuHostnamer3�UbuntuNrjrEr0r.ryry�rkr0ryc��eZdZdZdZeZdS)�LinuxmintHostnamer3�	LinuxmintNrjrEr0r.r|r|�s�������H��L�!�N�N�Nr0r|c��eZdZdZdZeZdS)�LinaroHostnamer3�LinaroNrjrEr0r.rr�rkr0rc��eZdZdZdZeZdS)�DevuanHostnamer3�DevuanNrjrEr0r.r�r�rkr0r�c��eZdZdZdZeZdS)�RaspbianHostnamer3�RaspbianNrjrEr0r.r�r�
s�������H��L�!�N�N�Nr0r�c��eZdZdZdZeZdS)�UosHostnamer3�UosNrjrEr0r.r�r���������H��L�!�N�N�Nr0r�c��eZdZdZdZeZdS)�DeepinHostnamer3�DeepinNrjrEr0r.r�r�rkr0r�c��eZdZdZdZeZdS)�GentooHostnamer3�GentooN)rMrNrOr`rcr�r8rEr0r.r�r�rIr0r�c��eZdZdZdZeZdS)�ALTLinuxHostnamer3�AltlinuxNrHrEr0r.r�r�"s�������H��L�#�N�N�Nr0r�c��eZdZdZdZeZdS)�AlpineLinuxHostnamer3rN)rMrNrOr`rcr�r8rEr0r.r�r�(rIr0r�c��eZdZdZdZeZdS)�OpenBSDHostnamerN)rMrNrOr`rcr�r8rEr0r.r�r�.��������H��L�$�N�N�Nr0r�c��eZdZdZdZeZdS)�SolarisHostname�SunOSN)rMrNrOr`rcr�r8rEr0r.r�r�4s�������H��L�$�N�N�Nr0r�c��eZdZdZdZeZdS)�FreeBSDHostnamerN�rMrNrOr`rcr�r8rEr0r.r�r�:r�r0r�c��eZdZdZdZeZdS)�NetBSDHostname�NetBSDNr�rEr0r.r�r�@s�������H��L�$�N�N�Nr0r�c��eZdZdZdZeZdS)�NeonHostnamer3�NeonNrjrEr0r.r�r�Frtr0r�c��eZdZdZdZeZdS)�DarwinHostnamerN)rMrNrOr`rcr�r8rEr0r.r�r�Ls�������H��L�#�N�N�Nr0r�c��eZdZdZdZeZdS)�VoidLinuxHostnamer3�VoidNrjrEr0r.r�r�Rrtr0r�c��eZdZdZdZeZdS)�PopHostnamer3�PopNrjrEr0r.r�r�Xr�r0r�c��eZdZdZdZeZdS)�EurolinuxHostnamer3�	EurolinuxNrHrEr0r.r�r�^rcr0r�c��tttdd���tdtt�����������d���}t|��}|jd}|���}|���}|�	��}||kr|}n||kr|}n|}t||t|�
d��d	|tj��d�
tj���
d��d
d���������}|rd
|zdzd
|zdzd�|d<|jdi|��dS)NrT)�type�required)r��choices)r9r2)�
argument_spec�supports_check_moder9�.rr!)�ansible_hostname�ansible_nodename�ansible_fqdn�ansible_domain)r,r9�
ansible_factszhostname = r�)�after�before�diffrE)rr	�listr5�keysr)r:r;r@r6r��socket�getfqdnr��	exit_json)r+rgr9�current_hostname�permanent_hostnamer,�name_before�kws        r.�mainr�ds���
���5�4�0�0�0��%��f�k�k�m�m�)<�)<�=�=�=�
�
�
�!����F�����H��=�� �D��4�4�6�6��!�8�8�:�:���<�<�>�>�G�����&���	
�#�	#�	#�(���(��
�g�D� �$�*�*�S�/�/�!�2D�26�.4�n�.>�.>�03�����9I�9I�9O�9O�PS�9T�9T�UV�UW�UW�9X�0Y�0Y�[�[�[�
\�
\�
\�B��D�,�t�3�d�:� -�� ;�d� B�D�D��6�
��F����r�����r0�__main__)W�
__future__rrrr��
__metaclass__�
DOCUMENTATION�EXAMPLESr�r`r�r��"ansible.module_utils.compat.typing�module_utils�compat�typing�t�ansible.module_utils.basicrrr�$ansible.module_utils.common.sys_infor	�-ansible.module_utils.facts.system.service_mgrr
� ansible.module_utils.facts.utilsrr�ansible.module_utils._textr
r�ansible.module_utils.sixrrr5�objectr)rQrfr�r�r�r�r�r�r�r�r�r�r)r@rFrKrNrQrTrXr[r^rarerhrmrprrrvryr|rr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rMrEr0r.�<module>r�s�	��A�@�@�@�@�@�@�@�@�@��
�-�
�^	��
�	�	�	�����
�
�
�
�����.�.�.�.�.�.�.�.�.�.�.�.�����������
G�F�F�F�F�F�Q�Q�Q�Q�Q�Q�M�M�M�M�M�M�M�M�9�9�9�9�9�9�9�9�3�3�3�3�3�3�3�3�����
���������
�
��"$"�$"�$"�$"�$"�6�$"�$"�$"�NP�P�P�P�P�L�P�P�P�B
�
�
�
�
�l�
�
�
�62�2�2�2�2�<�2�2�2�0�����<����)2�)2�)2�)2�)2�\�)2�)2�)2�X_�_�_�_�_�\�_�_�_�&/�/�/�/�/�l�/�/�/�d$2�$2�$2�$2�$2�\�$2�$2�$2�N�����l���� _� _� _� _� _�l� _� _� _�F92�92�92�92�92�l�92�92�92�xl �l �l �l �l �\�l �l �l �^-3�-3�-3�-3�-3�v�-3�-3�-3�`/�/�/�/�/�8�/�/�/�$�$�$�$�$�8�$�$�$�$�$�$�$�$�X�$�$�$�$�$�$�$�$�x�$�$�$�$�$�$�$�$�x�$�$�$�$�$�$�$�$��$�$�$�$�$�$�$�$�X�$�$�$�$�$�$�$�$��$�$�$�$�$�$�$�$�(�$�$�$�$�$�$�$�$�X�$�$�$�$�$�$�$�$�(�$�$�$�"�"�"�"�"�X�"�"�"�"�"�"�"�"�H�"�"�"�"�"�"�"�"�h�"�"�"�"�"�"�"�"�8�"�"�"�"�"�"�"�"�X�"�"�"�"�"�"�"�"�X�"�"�"�"�"�"�"�"��"�"�"�"�"�"�"�"�X�"�"�"�"�"�"�"�"�X�"�"�"�"�"�"�"�"�x�"�"�"�"�"�"�"�"�(�"�"�"�"�"�"�"�"�X�"�"�"�$�$�$�$�$�X�$�$�$�$�$�$�$�$�x�$�$�$�$�$�$�$�$�(�$�$�$�%�%�%�%�%�h�%�%�%�%�%�%�%�%�h�%�%�%�%�%�%�%�%�h�%�%�%�%�%�%�%�%�X�%�%�%�"�"�"�"�"�8�"�"�"�$�$�$�$�$�X�$�$�$�"�"�"�"�"��"�"�"�"�"�"�"�"�(�"�"�"�$�$�$�$�$��$�$�$�$�$�$�N�z����D�F�F�F�F�F��r0

Youez - 2016 - github.com/yon3zu
LinuXploit