1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

authorized_key: doc: Improve example description (#19209)

This commit is contained in:
Fabio Alessandro Locati 2017-01-08 12:28:29 +01:00 committed by René Moser
parent 07c68571b6
commit 85f7d2b97a

View file

@ -95,28 +95,27 @@ author: "Ansible Core Team"
''' '''
EXAMPLES = ''' EXAMPLES = '''
# Example using key data from a local file on the management machine - name: Set authorized key took from file
- authorized_key: authorized_key:
user: charlie user: charlie
state: present state: present
key: "{{ lookup('file', '/home/charlie/.ssh/id_rsa.pub') }}" key: "{{ lookup('file', '/home/charlie/.ssh/id_rsa.pub') }}"
# Using github url as key source - name: Set authorized key took from url
- authorized_key: authorized_key:
user: charlie user: charlie
state: present state: present
key: https://github.com/charlie.keys key: https://github.com/charlie.keys
# Using alternate directory locations: - name: Set authorized key in alternate location
- authorized_key: authorized_key:
user: charlie user: charlie
state: present state: present
key: "{{ lookup('file', '/home/charlie/.ssh/id_rsa.pub') }}" key: "{{ lookup('file', '/home/charlie/.ssh/id_rsa.pub') }}"
path: /etc/ssh/authorized_keys/charlie path: /etc/ssh/authorized_keys/charlie
manage_dir: no manage_dir: False
# Using with_file - name: Set up multiple authorized keys
- name: Set up authorized_keys for the deploy user
authorized_key: authorized_key:
user: deploy user: deploy
state: present state: present
@ -125,35 +124,34 @@ EXAMPLES = '''
- public_keys/doe-jane - public_keys/doe-jane
- public_keys/doe-john - public_keys/doe-john
# Using key_options: - name: Set authorized key defining key options
- authorized_key: authorized_key:
user: charlie user: charlie
state: present state: present
key: "{{ lookup('file', '/home/charlie/.ssh/id_rsa.pub') }}" key: "{{ lookup('file', '/home/charlie/.ssh/id_rsa.pub') }}"
key_options: 'no-port-forwarding,from="10.0.1.1"' key_options: 'no-port-forwarding,from="10.0.1.1"'
# Using validate_certs: - name: Set authorized key without validating the TLS/SSL certificates
- authorized_key: authorized_key:
user: charlie user: charlie
state: present state: present
key: https://github.com/user.keys key: https://github.com/user.keys
validate_certs: no validate_certs: False
# Set up authorized_keys exclusively with one key - name: Set authorized key, removing all the authorized key already set
- authorized_key: authorized_key:
user: root user: root
key: '{{ item }}' key: '{{ item }}'
state: present state: present
exclusive: yes exclusive: True
with_file: with_file:
- public_keys/doe-jane - public_keys/doe-jane
# Copies the key from the user who is running ansible to the remote machine user ubuntu - name: Set authorized key for user ubuntu copying it from current user
- authorized_key: authorized_key:
user: ubuntu user: ubuntu
state: present state: present
key: "{{ lookup('file', lookup('env','HOME') + '/.ssh/id_rsa.pub') }}" key: "{{ lookup('file', lookup('env','HOME') + '/.ssh/id_rsa.pub') }}"
become: yes
''' '''
# Makes sure the public key line is present or absent in the user's .ssh/authorized_keys. # Makes sure the public key line is present or absent in the user's .ssh/authorized_keys.