Co-authored-by: MKletz <michael.kletz.27@gmail.com> Co-authored-by: Ajay Chenampara <ajay.chenampara@gmail.com> Co-authored-by: dlemons-redhat <69318976+dlemons-redhat@users.noreply.github.com> Co-authored-by: Nicolas Leiva <nicolasleiva@gmail.com> Co-authored-by: benblasco <42140583+benblasco@users.noreply.github.com> Co-authored-by: Benjamin Blasco <bblasco@redhat.com> Co-authored-by: calvingsmith <4283930+calvingsmith@users.noreply.github.com> Co-authored-by: Calvin Smith <calvingsmith@users.noreply.github.com> Co-authored-by: Hicham Mourad <43329991+HichamMourad@users.noreply.github.com>
26 lines
663 B
YAML
26 lines
663 B
YAML
---
|
|
- name: Create AWS keypair
|
|
hosts: localhost
|
|
vars:
|
|
aws_key_name: aws-test-key
|
|
aws_keypair_owner: undef
|
|
|
|
tasks:
|
|
- name: Fail if variables not defined
|
|
ansible.builtin.assert:
|
|
that:
|
|
- aws_key_name is defined
|
|
- aws_region is defined
|
|
- aws_public_key is defined
|
|
- aws_keypair_owner is defined
|
|
fail_msg: "Required variables not set"
|
|
|
|
- name: Create AWS keypair
|
|
amazon.aws.ec2_key:
|
|
name: "{{ aws_key_name }}"
|
|
region: "{{ aws_region }}"
|
|
key_material: "{{ aws_public_key }}"
|
|
state: present
|
|
tags:
|
|
owner: "{{ aws_keypair_owner }}"
|