%PDF- %PDF-
| Direktori : /lib/python3.9/site-packages/ansible/modules/__pycache__/ |
| Current File : //lib/python3.9/site-packages/ansible/modules/__pycache__/known_hosts.cpython-39.pyc |
a
�)g�5 � @ s� d dl mZmZmZ eZdZdZd dlZd dl Z d dl
Z
d dlZd dlZd dl
Zd dlZd dlZd dlmZ d dlmZmZ dd� Zd d
� Zdd� Zd
d� Zdd� Zdd� Zdd� Zedkr�e� dS )� )�absolute_import�division�print_functiona�
---
module: known_hosts
short_description: Add or remove a host from the C(known_hosts) file
description:
- The C(known_hosts) module lets you add or remove a host keys from the C(known_hosts) file.
- Starting at Ansible 2.2, multiple entries per host are allowed, but only one for each key type supported by ssh.
This is useful if you're going to want to use the M(ansible.builtin.git) module over ssh, for example.
- If you have a very large number of host keys to manage, you will find the M(ansible.builtin.template) module more useful.
version_added: "1.9"
options:
name:
aliases: [ 'host' ]
description:
- The host to add or remove (must match a host specified in key). It will be converted to lowercase so that ssh-keygen can find it.
- Must match with <hostname> or <ip> present in key attribute.
- For custom SSH port, C(name) needs to specify port as well. See example section.
type: str
required: true
key:
description:
- The SSH public host key, as a string.
- Required if C(state=present), optional when C(state=absent), in which case all keys for the host are removed.
- The key must be in the right format for SSH (see sshd(8), section "SSH_KNOWN_HOSTS FILE FORMAT").
- Specifically, the key should not match the format that is found in an SSH pubkey file, but should rather have the hostname prepended to a
line that includes the pubkey, the same way that it would appear in the known_hosts file. The value prepended to the line must also match
the value of the name parameter.
- Should be of format C(<hostname[,IP]> ssh-rsa <pubkey>).
- For custom SSH port, C(key) needs to specify port as well. See example section.
type: str
path:
description:
- The known_hosts file to edit.
- The known_hosts file will be created if needed. The rest of the path must exist prior to running the module.
default: "~/.ssh/known_hosts"
type: path
hash_host:
description:
- Hash the hostname in the known_hosts file.
type: bool
default: "no"
version_added: "2.3"
state:
description:
- I(present) to add the host key.
- I(absent) to remove it.
choices: [ "absent", "present" ]
default: "present"
type: str
attributes:
check_mode:
support: full
diff_mode:
support: full
platform:
platforms: posix
extends_documentation_fragment:
- action_common_attributes
author:
- Matthew Vernon (@mcv21)
a�
- name: Tell the host about our servers it might want to ssh to
ansible.builtin.known_hosts:
path: /etc/ssh/ssh_known_hosts
name: foo.com.invalid
key: "{{ lookup('ansible.builtin.file', 'pubkeys/foo.com.invalid') }}"
- name: Another way to call known_hosts
ansible.builtin.known_hosts:
name: host1.example.com # or 10.9.8.77
key: host1.example.com,10.9.8.77 ssh-rsa ASDeararAIUHI324324 # some key gibberish
path: /etc/ssh/ssh_known_hosts
state: present
- name: Add host with custom SSH port
ansible.builtin.known_hosts:
name: '[host1.example.com]:2222'
key: '[host1.example.com]:2222 ssh-rsa ASDeararAIUHI324324' # some key gibberish
path: /etc/ssh/ssh_known_hosts
state: present
N)�
AnsibleModule)�to_bytes� to_nativec
C s� |d � � }|�dd�}|�d�}|�d�}|�d�}| �dd�}|sZ|d krZ| jd
d� |rl|rlt||�}|r�|�d�s�|d7 }t| |||� t| ||||�\}} }
t||
| ||�|d
<