Skip to content

Commit

Permalink
Merge pull request #130 from hakbailey/udpate-ec2-pattern
Browse files Browse the repository at this point in the history
Small updates to ec2 pattern
  • Loading branch information
hakbailey authored Dec 13, 2024
2 parents c7c6737 + 793d851 commit 1c2b0e9
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 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 @@ -16,7 +16,7 @@ spec:

- type: text
question_name: Key Pair Name
question_description: Name of key pair for instance, include to delete key pair created with other instance resources. Defaults to '{{ instance_name }}-key'
question_description: Name of key pair for instance, include to delete key pair created with other instance resources.
variable: key_name
required: false

Expand Down
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 1c2b0e9

Please sign in to comment.