From 85f7d2b97af19a2e3f7bb8fd921afd9203fec8e1 Mon Sep 17 00:00:00 2001 From: Fabio Alessandro Locati Date: Sun, 8 Jan 2017 12:28:29 +0100 Subject: [PATCH] authorized_key: doc: Improve example description (#19209) --- lib/ansible/modules/system/authorized_key.py | 38 ++++++++++---------- 1 file changed, 18 insertions(+), 20 deletions(-) diff --git a/lib/ansible/modules/system/authorized_key.py b/lib/ansible/modules/system/authorized_key.py index 0b889d410d..b82b8e9f2d 100644 --- a/lib/ansible/modules/system/authorized_key.py +++ b/lib/ansible/modules/system/authorized_key.py @@ -95,28 +95,27 @@ author: "Ansible Core Team" ''' EXAMPLES = ''' -# Example using key data from a local file on the management machine -- authorized_key: +- name: Set authorized key took from file + authorized_key: user: charlie state: present key: "{{ lookup('file', '/home/charlie/.ssh/id_rsa.pub') }}" -# Using github url as key source -- authorized_key: +- name: Set authorized key took from url + authorized_key: user: charlie state: present key: https://github.com/charlie.keys -# Using alternate directory locations: -- authorized_key: +- name: Set authorized key in alternate location + authorized_key: user: charlie state: present key: "{{ lookup('file', '/home/charlie/.ssh/id_rsa.pub') }}" path: /etc/ssh/authorized_keys/charlie - manage_dir: no + manage_dir: False -# Using with_file -- name: Set up authorized_keys for the deploy user +- name: Set up multiple authorized keys authorized_key: user: deploy state: present @@ -125,35 +124,34 @@ EXAMPLES = ''' - public_keys/doe-jane - public_keys/doe-john -# Using key_options: -- authorized_key: +- name: Set authorized key defining key options + authorized_key: user: charlie state: present key: "{{ lookup('file', '/home/charlie/.ssh/id_rsa.pub') }}" key_options: 'no-port-forwarding,from="10.0.1.1"' -# Using validate_certs: -- authorized_key: +- name: Set authorized key without validating the TLS/SSL certificates + authorized_key: user: charlie state: present key: https://github.com/user.keys - validate_certs: no + validate_certs: False -# Set up authorized_keys exclusively with one key -- authorized_key: +- name: Set authorized key, removing all the authorized key already set + authorized_key: user: root key: '{{ item }}' state: present - exclusive: yes + exclusive: True with_file: - public_keys/doe-jane -# Copies the key from the user who is running ansible to the remote machine user ubuntu -- authorized_key: +- name: Set authorized key for user ubuntu copying it from current user + authorized_key: user: ubuntu state: present 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.