From d5e247243f1252c0de53cb8cb7c3efe39a2f96d1 Mon Sep 17 00:00:00 2001 From: Prasad Katti Date: Wed, 15 Nov 2017 04:51:46 -0800 Subject: [PATCH] ec2_key - clean up examples (#32714) * ec2_key - clean up examples * ec2_key: remove unnecessary example --- lib/ansible/modules/cloud/amazon/ec2_key.py | 43 ++++++++------------- 1 file changed, 16 insertions(+), 27 deletions(-) diff --git a/lib/ansible/modules/cloud/amazon/ec2_key.py b/lib/ansible/modules/cloud/amazon/ec2_key.py index a37dbd3b29e..1497d6d31cb 100644 --- a/lib/ansible/modules/cloud/amazon/ec2_key.py +++ b/lib/ansible/modules/cloud/amazon/ec2_key.py @@ -62,44 +62,33 @@ author: "Vincent Viallet (@zbal)" ''' EXAMPLES = ''' -# Note: None of these examples set aws_access_key, aws_secret_key, or region. -# It is assumed that their matching environment variables are set. +# Note: These examples do not set authentication details, see the AWS Guide for details. -# Creates a new ec2 key pair named `example` if not present, returns generated -# private key -- name: example ec2 key +- name: create a new ec2 key pair, returns generated private key ec2_key: - name: example + name: my_keypair -# Creates a new ec2 key pair named `example` if not present using provided key -# material. This could use the 'file' lookup plugin to pull this off disk. -- name: example2 ec2 key +- name: create key pair using provided key_material ec2_key: - name: example2 + name: my_keypair key_material: 'ssh-rsa AAAAxyz...== me@example.com' - state: present -# Given example2 is already existing, the key will not be replaced because the -# force flag was set to `false` -- name: example2 ec2 key +- name: create key pair using key_material obtained using 'file' lookup plugin ec2_key: - name: example2 + name: my_keypair + key_material: "{{ lookup('file', '/path/to/public_key/id_rsa.pub') }}" + +# try creating a key pair with the name of an already existing keypair +# but don't overwrite it even if the key is different (force=false) +- name: try creating a key pair with name of an already existing keypair + ec2_key: + name: my_existing_keypair key_material: 'ssh-rsa AAAAxyz...== me@example.com' force: false - state: present -# Creates a new ec2 key pair named `example` if not present using provided key -# material -- name: example3 ec2 key +- name: remove key pair by name ec2_key: - name: example3 - key_material: "{{ item }}" - with_file: /path/to/public_key.id_rsa.pub - -# Removes ec2 key pair by name -- name: remove example key - ec2_key: - name: example + name: my_keypair state: absent '''