forked from ansible-collections/amazon.aws
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ec2_launch_template: implement missing metadata options (ansible-coll…
…ections#917) ec2_launch_template: implement missing metadata options SUMMARY Add missing metadata options instance_metadata_tags http_protocol_ipv6 ISSUE TYPE Feature Pull Request COMPONENT NAME ec2_launch_template Reviewed-by: Markus Bergholz <[email protected]> Reviewed-by: Mark Woolley <[email protected]> Reviewed-by: Alina Buzachis <None>
- Loading branch information
Showing
4 changed files
with
119 additions
and
24 deletions.
There are no files selected for viewing
2 changes: 2 additions & 0 deletions
2
changelogs/fragments/917-add-launch-template-metadata-parameters.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
minor_changes: | ||
- ec2_launch_template - Add metadata options parameter ``http_protocol_ipv6`` and ``instance_metadata_tags`` (https://github.com/ansible-collections/community.aws/pull/917). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
100 changes: 77 additions & 23 deletions
100
tests/integration/targets/ec2_launch_template/tasks/instance-metadata.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,78 @@ | ||
- block: | ||
- name: metadata_options | ||
ec2_launch_template: | ||
name: "{{ resource_prefix }}-test-metadata" | ||
metadata_options: | ||
http_put_response_hop_limit: 1 | ||
http_tokens: required | ||
state: present | ||
register: metadata_options_launch_template | ||
- name: instance with metadata_options created with the right options | ||
assert: | ||
that: | ||
- metadata_options_launch_template is changed | ||
- "metadata_options_launch_template.latest_template.launch_template_data.metadata_options.http_put_response_hop_limit == 1" | ||
- "metadata_options_launch_template.latest_template.launch_template_data.metadata_options.http_tokens == 'required'" | ||
--- | ||
- name: test with older boto3 version that does not support instance_metadata_tags | ||
block: | ||
- name: fail metadata_options | ||
ec2_launch_template: | ||
name: "{{ resource_prefix }}-test-metadata" | ||
metadata_options: | ||
http_put_response_hop_limit: 1 | ||
http_tokens: required | ||
http_protocol_ipv6: enabled | ||
instance_metadata_tags: enabled | ||
state: present | ||
register: metadata_options_launch_template | ||
ignore_errors: yes | ||
- name: verify fail with usefull error message | ||
assert: | ||
that: | ||
- metadata_options_launch_template.failed | ||
- metadata_options_launch_template is not changed | ||
- "'This is required to set instance_metadata_tags' in metadata_options_launch_template.msg" | ||
|
||
- name: success metadata_options | ||
ec2_launch_template: | ||
name: "{{ resource_prefix }}-test-metadata" | ||
metadata_options: | ||
http_put_response_hop_limit: 1 | ||
http_tokens: required | ||
state: present | ||
register: metadata_options_launch_template | ||
- name: instance with metadata_options created with the right options | ||
assert: | ||
that: | ||
- metadata_options_launch_template is changed | ||
- "metadata_options_launch_template.latest_template.launch_template_data.metadata_options.http_put_response_hop_limit == 1" | ||
- "metadata_options_launch_template.latest_template.launch_template_data.metadata_options.http_tokens == 'required'" | ||
- "metadata_options_launch_template.latest_template.launch_template_data.metadata_options.http_protocol_ipv6 is not defined" | ||
- "metadata_options_launch_template.latest_template.launch_template_data.metadata_options.instance_metadata_tags is not defined" | ||
always: | ||
- name: delete the template | ||
ec2_launch_template: | ||
name: "{{ resource_prefix }}-test-metadata" | ||
state: absent | ||
register: del_lt | ||
retries: 10 | ||
until: del_lt is not failed | ||
ignore_errors: true | ||
- name: delete the template | ||
ec2_launch_template: | ||
name: "{{ resource_prefix }}-test-metadata" | ||
state: absent | ||
register: del_lt | ||
retries: 10 | ||
until: del_lt is not failed | ||
ignore_errors: true | ||
|
||
- name: test with boto3 version that supports instance_metadata_tags | ||
vars: | ||
ansible_python_interpreter: "{{ botocore_virtualenv_interpreter }}" | ||
block: | ||
- name: metadata_options | ||
ec2_launch_template: | ||
name: "{{ resource_prefix }}-test-metadata" | ||
metadata_options: | ||
http_put_response_hop_limit: 1 | ||
http_tokens: required | ||
http_protocol_ipv6: enabled | ||
instance_metadata_tags: enabled | ||
state: present | ||
register: metadata_options_launch_template | ||
- name: instance with metadata_options created with the right options | ||
assert: | ||
that: | ||
- metadata_options_launch_template is changed | ||
- "metadata_options_launch_template.latest_template.launch_template_data.metadata_options.http_put_response_hop_limit == 1" | ||
- "metadata_options_launch_template.latest_template.launch_template_data.metadata_options.http_tokens == 'required'" | ||
- "metadata_options_launch_template.latest_template.launch_template_data.metadata_options.http_protocol_ipv6 == 'enabled'" | ||
- "metadata_options_launch_template.latest_template.launch_template_data.metadata_options.instance_metadata_tags == 'enabled'" | ||
always: | ||
- name: delete the template | ||
ec2_launch_template: | ||
name: "{{ resource_prefix }}-test-metadata" | ||
state: absent | ||
register: del_lt | ||
retries: 10 | ||
until: del_lt is not failed | ||
ignore_errors: true |