File: //usr/lib/python3.9/site-packages/ansible/modules/__pycache__/hostname.cpython-39.pyc
a
�)g{p � @ s d dl mZmZmZ eZdZdZd dlZd dl Z d dl
Z
d dlZd dlm
m mZ d dlmZmZmZ d dlmZ d dlmZ d dlmZmZ d d lmZmZ d d
lm Z m!Z! ddd
ddddddddddd�
Z"G dd� de#�Z$G dd� de$�Z%G dd� de$�Z&G dd� de$�Z'G dd� de'�Z(G d d!� d!e$�Z)G d"d#� d#e'�Z*G d$d%� d%e$�Z+G d&d'� d'e$�Z,G d(d)� d)e'�Z-G d*d+� d+e$�Z.G d,d-� d-e$�Z/G d.d/� d/e$�Z0G d0d1� d1e#�Z1G d2d3� d3e1�Z2G d4d5� d5e1�Z3G d6d7� d7e1�Z4G d8d9� d9e1�Z5G d:d;� d;e1�Z6G d<d=� d=e1�Z7G d>d?� d?e1�Z8G d@dA� dAe1�Z9G dBdC� dCe1�Z:G dDdE� dEe1�Z;G dFdG� dGe1�Z<G dHdI� dIe1�Z=G dJdK� dKe1�Z>G dLdM� dMe1�Z?G dNdO� dOe1�Z@G dPdQ� dQe1�ZAG dRdS� dSe1�ZBG dTdU� dUe1�ZCG dVdW� dWe1�ZDG dXdY� dYe1�ZEG dZd[� d[e1�ZFG d\d]� d]e1�ZGG d^d_� d_e1�ZHG d`da� dae1�ZIG dbdc� dce1�ZJG ddde� dee1�ZKG dfdg� dge1�ZLG dhdi� die1�ZMG djdk� dke1�ZNG dldm� dme1�ZOG dndo� doe1�ZPG dpdq� dqe1�ZQG drds� dse1�ZRG dtdu� due1�ZSG dvdw� 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 @ sL e Zd Zdd� Zdd� Zdd� Zdd� Zd d
� Zdd� Zd
d� Z dd� Z
dS )�BaseStrategyc C s || _ d| _d S )NF)�module�changed��selfr � r �</usr/lib/python3.9/site-packages/ansible/modules/hostname.py�__init__i s zBaseStrategy.__init__c C s | � � | �� | jS �N)�update_current_hostname�update_permanent_hostnamer �r r r r �%update_current_and_permanent_hostnamem s z2BaseStrategy.update_current_and_permanent_hostnamec C s8 | j jd }| �� }||kr4| j js.| �|� d| _d S �N�nameT)r �params�get_current_hostname�
check_mode�set_current_hostnamer )r r# Zcurrent_namer r r r r s
z$BaseStrategy.update_current_hostnamec C s8 | j jd }| �� }||kr4| j js.| �|� d| _d S r"