Skip to content

Commit

Permalink
Small updates to ec2 pattern
Browse files Browse the repository at this point in the history
  • Loading branch information
hakbailey committed Dec 13, 2024
1 parent c7c6737 commit b0acfee
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@
amazon.aws.ec2_key_info:
names:
- "{{ key_name }}"
register: key_info_result
register: pattern_key_info_result

- name: Set manage_ec2_instance_key_name role var
ansible.builtin.set_fact:
manage_ec2_instance_key_name: "{{ key_name }}"
when: key_info_result.keypairs | length > 0
when: pattern_key_info_result.keypairs | length > 0

- name: Get RHEL 9 AMI ID if needed
when: ami_id | default("", true) == ""
Expand Down Expand Up @@ -73,5 +73,5 @@

- name: Warn if key does not exist
ansible.builtin.debug:
msg: "Warning: The key '{{ key_name }}' does not exist!"
when: key_name is defined and key_info_result.keypairs | length == 0
msg: "Warning: The provided key '{{ key_name }}' does not exist!"
when: key_name is defined and pattern_key_info_result.keypairs | length == 0
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
names:
- "{{ manage_ec2_instance_key_name }}"
register: key_info_result
no_log: true

- name: Create new key pair
amazon.aws.ec2_key:
Expand Down

0 comments on commit b0acfee

Please sign in to comment.