Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ec2_ami: Add support for params BootMode, TpmSupport, UefiData #1037

Conversation

mandar242
Copy link
Contributor

@mandar242 mandar242 commented Sep 19, 2022

SUMMARY

Depends-On: #1066

Added support for params BootMode, TpmSupport, UefiData in ec2_ami.

Fixes #944

ISSUE TYPE
  • Feature Pull Request
COMPONENT NAME

ec2_ami

ADDITIONAL INFORMATION

Example playbook

- name: abc
  hosts: localhost
  gather_facts: false
  tasks:
    - name: AMI Creation with boot_mode and tpm_support
      amazon.aws.ec2_ami:
        name: ami-create-test_legacy-bios
        state: present
        architecture: x86_64
        virtualization_type: hvm
        root_device_name: /dev/sda1
        device_mapping:
          - device_name: /dev/sda1
            snapshot_id: snap-xxxxxxxxx
        wait: yes
        region: us-east-2
        boot_mode: legacy-bios
        tpm_support: v2.0
        tags:
          name: ami-create-test

@github-actions

This comment was marked as outdated.

@ansibullbot
Copy link

@ansibullbot ansibullbot added WIP Work in progress feature This issue/PR relates to a feature request module module needs_triage plugins plugin (any type) labels Sep 19, 2022
@softwarefactory-project-zuul

This comment was marked as outdated.

@softwarefactory-project-zuul

This comment was marked as outdated.

@mandar242
Copy link
Contributor Author

recheck

@softwarefactory-project-zuul

This comment was marked as outdated.

@ansibullbot ansibullbot added integration tests/integration tests tests labels Sep 20, 2022
@softwarefactory-project-zuul

This comment was marked as outdated.

@mandar242
Copy link
Contributor Author

recheck

@softwarefactory-project-zuul

This comment was marked as outdated.

@softwarefactory-project-zuul

This comment was marked as outdated.

@mandar242 mandar242 force-pushed the ec2_ami-add-boot_mode-tpm-support branch from 279e82d to b001320 Compare September 21, 2022 06:05
@softwarefactory-project-zuul

This comment was marked as outdated.

@mandar242
Copy link
Contributor Author

recheck

@softwarefactory-project-zuul

This comment was marked as outdated.

plugins/modules/ec2_ami.py Show resolved Hide resolved
plugins/modules/ec2_ami.py Outdated Show resolved Hide resolved
- "result.image_id.startswith('ami-')"
- ami_facts_result_boot_tpm.images[0].image_id | length != 0
- ami_facts_result_boot_tpm.images[0].boot_mode == 'uefi'
- ami_facts_result_boot_tpm.images[0].tpm_support == 'v2.0'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you also test uefi_data?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

trying to figure out what a valid uefi_data_file would look like, currently boto is throwing error on below task

    - name: AMI Creation with boot_mode and tpm_support
      amazon.aws.ec2_ami:
        name: newtest-uefi-file-data
        state: present
        architecture: x86_64
        virtualization_type: hvm
        root_device_name: /dev/sda1
        device_mapping:
          - device_name: /dev/sda1
            snapshot_id: snap-0f00cba7123456
        wait: yes
        region: us-east-2
        boot_mode: uefi
        uefi_data: "{{ lookup('file', 'uefi_data_file') | b64encode }}"
        tpm_support: v2.0
        tags:
          name: test-ami
botocore.exceptions.ClientError: An error occurred (InvalidParameterValue)
when calling the RegisterImage operation: Invalid uefiData.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would suggest to use get_instance_uefi_data() https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/ec2.html#EC2.Client.get_instance_uefi_data to get a working uefidata file and you can send it back later in the tests.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tried that but turns out it throws unauthorized error for the operator GetInstanceUefiData.
Would need to open a PR to get the permissions added to terminator repository.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the permission issue has been resolved, currently trying to solve error

An error occurred (InvalidInstanceID.NotFound) when calling the GetInstanceUefiData operation: 
Unknown virtIds for owner 'xxxxxxx': [ i-xxxxxxxxxx ]"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@goneri, it appears that there are currently no provided AMIs with uefi boot mode support for linux, also none of our currently supported instance types for integration tests support uefi boot mode.
I can test the code for UEFI boot mode and UEFI data manually but not sure if it's possible to add to integration tests.

Relevant links:
https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/launch-instance-with-uefi-sb.html
https://docs.aws.amazon.com/AWSEC2/latest/WindowsGuide/enable-nitrotpm-prerequisites.html
https://aws.amazon.com/blogs/aws/amazon-ec2-now-supports-nitrotpm-and-uefi-secure-boot/

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will be a good candidate for an unit-test.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

plugins/modules/ec2_ami.py Show resolved Hide resolved
@softwarefactory-project-zuul

This comment was marked as outdated.

@mandar242 mandar242 force-pushed the ec2_ami-add-boot_mode-tpm-support branch from 545fd82 to 51260c5 Compare October 12, 2022 04:45
@softwarefactory-project-zuul

This comment was marked as outdated.

@softwarefactory-project-zuul

This comment was marked as outdated.

we don't really care about the whole string.
@mandar242 mandar242 force-pushed the ec2_ami-add-boot_mode-tpm-support branch from cd2fef3 to 2d1759e Compare October 12, 2022 17:20
@softwarefactory-project-zuul

This comment was marked as outdated.

@softwarefactory-project-zuul
Copy link
Contributor

Build failed.

✔️ ansible-galaxy-importer SUCCESS in 5m 05s
✔️ build-ansible-collection SUCCESS in 7m 19s
ansible-test-sanity-aws-ansible-python38 FAILURE in 14m 17s
ansible-test-sanity-aws-ansible-2.12-python38 FAILURE in 13m 19s
ansible-test-sanity-aws-ansible-2.13-python38 FAILURE in 12m 43s
✔️ ansible-test-units-amazon-aws-python36 SUCCESS in 8m 46s
✔️ ansible-test-units-amazon-aws-python38 SUCCESS in 9m 26s
✔️ ansible-test-units-amazon-aws-python39 SUCCESS in 8m 17s
✔️ cloud-tox-py3 SUCCESS in 5m 00s
✔️ ansible-test-splitter SUCCESS in 4m 48s
✔️ integration-amazon.aws-1 SUCCESS in 21m 26s
⚠️ integration-amazon.aws-2 SKIPPED
⚠️ integration-amazon.aws-3 SKIPPED
⚠️ integration-amazon.aws-4 SKIPPED
⚠️ integration-amazon.aws-5 SKIPPED
⚠️ integration-amazon.aws-6 SKIPPED
⚠️ integration-amazon.aws-7 SKIPPED
⚠️ integration-amazon.aws-8 SKIPPED
⚠️ integration-amazon.aws-9 SKIPPED
⚠️ integration-amazon.aws-10 SKIPPED
⚠️ integration-amazon.aws-11 SKIPPED
⚠️ integration-amazon.aws-12 SKIPPED
⚠️ integration-amazon.aws-13 SKIPPED
⚠️ integration-amazon.aws-14 SKIPPED
⚠️ integration-amazon.aws-15 SKIPPED
⚠️ integration-amazon.aws-16 SKIPPED
⚠️ integration-amazon.aws-17 SKIPPED
⚠️ integration-amazon.aws-18 SKIPPED
⚠️ integration-community.aws-1 SKIPPED
⚠️ integration-community.aws-2 SKIPPED
⚠️ integration-community.aws-3 SKIPPED
⚠️ integration-community.aws-4 SKIPPED
⚠️ integration-community.aws-5 SKIPPED
⚠️ integration-community.aws-6 SKIPPED
⚠️ integration-community.aws-7 SKIPPED
⚠️ integration-community.aws-8 SKIPPED
⚠️ integration-community.aws-9 SKIPPED
⚠️ integration-community.aws-10 SKIPPED
⚠️ integration-community.aws-11 SKIPPED
⚠️ integration-community.aws-12 SKIPPED
⚠️ integration-community.aws-13 SKIPPED
⚠️ integration-community.aws-14 SKIPPED
⚠️ integration-community.aws-15 SKIPPED
⚠️ integration-community.aws-16 SKIPPED
⚠️ integration-community.aws-17 SKIPPED
⚠️ integration-community.aws-18 SKIPPED
✔️ ansible-test-changelog SUCCESS in 3m 59s

@softwarefactory-project-zuul
Copy link
Contributor

Build succeeded.

✔️ ansible-galaxy-importer SUCCESS in 4m 51s
✔️ build-ansible-collection SUCCESS in 6m 11s
✔️ ansible-test-sanity-aws-ansible-python38 SUCCESS in 11m 11s
✔️ ansible-test-sanity-aws-ansible-2.12-python38 SUCCESS in 9m 56s
✔️ ansible-test-sanity-aws-ansible-2.13-python38 SUCCESS in 9m 10s
✔️ ansible-test-units-amazon-aws-python36 SUCCESS in 8m 30s
✔️ ansible-test-units-amazon-aws-python38 SUCCESS in 8m 18s
✔️ ansible-test-units-amazon-aws-python39 SUCCESS in 6m 49s
✔️ cloud-tox-py3 SUCCESS in 4m 06s
✔️ ansible-test-splitter SUCCESS in 2m 48s
✔️ integration-amazon.aws-1 SUCCESS in 20m 21s
⚠️ integration-amazon.aws-2 SKIPPED
⚠️ integration-amazon.aws-3 SKIPPED
⚠️ integration-amazon.aws-4 SKIPPED
⚠️ integration-amazon.aws-5 SKIPPED
⚠️ integration-amazon.aws-6 SKIPPED
⚠️ integration-amazon.aws-7 SKIPPED
⚠️ integration-amazon.aws-8 SKIPPED
⚠️ integration-amazon.aws-9 SKIPPED
⚠️ integration-amazon.aws-10 SKIPPED
⚠️ integration-amazon.aws-11 SKIPPED
⚠️ integration-amazon.aws-12 SKIPPED
⚠️ integration-amazon.aws-13 SKIPPED
⚠️ integration-amazon.aws-14 SKIPPED
⚠️ integration-amazon.aws-15 SKIPPED
⚠️ integration-amazon.aws-16 SKIPPED
⚠️ integration-amazon.aws-17 SKIPPED
⚠️ integration-amazon.aws-18 SKIPPED
⚠️ integration-community.aws-1 SKIPPED
⚠️ integration-community.aws-2 SKIPPED
⚠️ integration-community.aws-3 SKIPPED
⚠️ integration-community.aws-4 SKIPPED
⚠️ integration-community.aws-5 SKIPPED
⚠️ integration-community.aws-6 SKIPPED
⚠️ integration-community.aws-7 SKIPPED
⚠️ integration-community.aws-8 SKIPPED
⚠️ integration-community.aws-9 SKIPPED
⚠️ integration-community.aws-10 SKIPPED
⚠️ integration-community.aws-11 SKIPPED
⚠️ integration-community.aws-12 SKIPPED
⚠️ integration-community.aws-13 SKIPPED
⚠️ integration-community.aws-14 SKIPPED
⚠️ integration-community.aws-15 SKIPPED
⚠️ integration-community.aws-16 SKIPPED
⚠️ integration-community.aws-17 SKIPPED
⚠️ integration-community.aws-18 SKIPPED
✔️ ansible-test-changelog SUCCESS in 2m 38s

@mandar242 mandar242 added the mergeit Merge the PR (SoftwareFactory) label Oct 12, 2022
@softwarefactory-project-zuul
Copy link
Contributor

Build succeeded (gate pipeline).

✔️ ansible-galaxy-importer SUCCESS in 4m 19s
✔️ build-ansible-collection SUCCESS in 5m 40s
✔️ ansible-test-sanity-aws-ansible-python38 SUCCESS in 10m 13s
✔️ ansible-test-sanity-aws-ansible-2.12-python38 SUCCESS in 9m 06s
✔️ ansible-test-sanity-aws-ansible-2.13-python38 SUCCESS in 9m 17s
✔️ ansible-test-units-amazon-aws-python36 SUCCESS in 7m 04s
✔️ ansible-test-units-amazon-aws-python38 SUCCESS in 5m 35s
✔️ ansible-test-units-amazon-aws-python39 SUCCESS in 6m 34s
✔️ cloud-tox-py3 SUCCESS in 3m 28s
✔️ ansible-test-splitter SUCCESS in 3m 12s
✔️ integration-amazon.aws-1 SUCCESS in 19m 36s
⚠️ integration-amazon.aws-2 SKIPPED
⚠️ integration-amazon.aws-3 SKIPPED
⚠️ integration-amazon.aws-4 SKIPPED
⚠️ integration-amazon.aws-5 SKIPPED
⚠️ integration-amazon.aws-6 SKIPPED
⚠️ integration-amazon.aws-7 SKIPPED
⚠️ integration-amazon.aws-8 SKIPPED
⚠️ integration-amazon.aws-9 SKIPPED
⚠️ integration-amazon.aws-10 SKIPPED
⚠️ integration-amazon.aws-11 SKIPPED
⚠️ integration-amazon.aws-12 SKIPPED
⚠️ integration-amazon.aws-13 SKIPPED
⚠️ integration-amazon.aws-14 SKIPPED
⚠️ integration-amazon.aws-15 SKIPPED
⚠️ integration-amazon.aws-16 SKIPPED
⚠️ integration-amazon.aws-17 SKIPPED
⚠️ integration-amazon.aws-18 SKIPPED
⚠️ integration-community.aws-1 SKIPPED
⚠️ integration-community.aws-2 SKIPPED
⚠️ integration-community.aws-3 SKIPPED
⚠️ integration-community.aws-4 SKIPPED
⚠️ integration-community.aws-5 SKIPPED
⚠️ integration-community.aws-6 SKIPPED
⚠️ integration-community.aws-7 SKIPPED
⚠️ integration-community.aws-8 SKIPPED
⚠️ integration-community.aws-9 SKIPPED
⚠️ integration-community.aws-10 SKIPPED
⚠️ integration-community.aws-11 SKIPPED
⚠️ integration-community.aws-12 SKIPPED
⚠️ integration-community.aws-13 SKIPPED
⚠️ integration-community.aws-14 SKIPPED
⚠️ integration-community.aws-15 SKIPPED
⚠️ integration-community.aws-16 SKIPPED
⚠️ integration-community.aws-17 SKIPPED
⚠️ integration-community.aws-18 SKIPPED
✔️ ansible-test-changelog SUCCESS in 2m 50s

@softwarefactory-project-zuul softwarefactory-project-zuul bot merged commit 7d2528a into ansible-collections:main Oct 12, 2022
alinabuzachis pushed a commit to alinabuzachis/amazon.aws that referenced this pull request Apr 27, 2023
…le-collections#1037)

ec2_ami: Add support for params BootMode, TpmSupport, UefiData

SUMMARY
Depends-On: ansible-collections#1066

Added support for params BootMode, TpmSupport, UefiData in ec2_ami.

Fixes ansible-collections#944
ISSUE TYPE


Feature Pull Request

COMPONENT NAME

ec2_ami
ADDITIONAL INFORMATION



Example playbook
- name: abc
  hosts: localhost
  gather_facts: false
  tasks:
    - name: AMI Creation with boot_mode and tpm_support
      amazon.aws.ec2_ami:
        name: ami-create-test_legacy-bios
        state: present
        architecture: x86_64
        virtualization_type: hvm
        root_device_name: /dev/sda1
        device_mapping:
          - device_name: /dev/sda1
            snapshot_id: snap-xxxxxxxxx
        wait: yes
        region: us-east-2
        boot_mode: legacy-bios
        tpm_support: v2.0
        tags:
          name: ami-create-test

Reviewed-by: Gonéri Le Bouder <goneri@lebouder.net>
Reviewed-by: Mandar Kulkarni <mandar242@gmail.com>
Reviewed-by: Mike Graves <mgraves@redhat.com>
softwarefactory-project-zuul bot pushed a commit that referenced this pull request Apr 28, 2023
#1487)

[manual backport stable-5] ec2_ami: Add support for params BootMode, TpmSupport, UefiData (#1037)

ec2_ami: Add support for params BootMode, TpmSupport, UefiData
SUMMARY
Depends-On: #1066
Added support for params BootMode, TpmSupport, UefiData in ec2_ami.
Fixes #944
ISSUE TYPE
Feature Pull Request
COMPONENT NAME
ec2_ami
ADDITIONAL INFORMATION
Example playbook

name: abc hosts: localhost gather_facts: false tasks: - name: AMI Creation with boot_mode and tpm_support amazon.aws.ec2_ami: name: ami-create-test_legacy-bios state: present architecture: x86_64 virtualization_type: hvm root_device_name: /dev/sda1 device_mapping: - device_name: /dev/sda1 snapshot_id: snap-xxxxxxxxx wait: yes region: us-east-2 boot_mode: legacy-bios tpm_support: v2.0 tags: name: ami-create-test

Reviewed-by: Gonéri Le Bouder goneri@lebouder.net
Reviewed-by: Mandar Kulkarni mandar242@gmail.com
Reviewed-by: Mike Graves mgraves@redhat.com
SUMMARY


ISSUE TYPE


Bugfix Pull Request
Docs Pull Request
Feature Pull Request
New Module Pull Request

COMPONENT NAME

ADDITIONAL INFORMATION
@mandar242 mandar242 deleted the ec2_ami-add-boot_mode-tpm-support branch May 9, 2023 02:46
abikouo pushed a commit to abikouo/amazon.aws that referenced this pull request Sep 18, 2023
…-collections#1037)

networkfirewall_rule_group: Add support for "wait" parameter

SUMMARY
Add support for 'wait' to networkfirewall_rule_group to speed up the integration tests a little.
Note: Module not available in a release yet, so no changelog required.
ISSUE TYPE

Feature Pull Request

COMPONENT NAME
networkfirewall_rule_group
ADDITIONAL INFORMATION

Reviewed-by: Alina Buzachis <None>
abikouo pushed a commit to abikouo/amazon.aws that referenced this pull request Sep 18, 2023
…-collections#1037)

networkfirewall_rule_group: Add support for "wait" parameter

SUMMARY
Add support for 'wait' to networkfirewall_rule_group to speed up the integration tests a little.
Note: Module not available in a release yet, so no changelog required.
ISSUE TYPE

Feature Pull Request

COMPONENT NAME
networkfirewall_rule_group
ADDITIONAL INFORMATION

Reviewed-by: Alina Buzachis <None>
abikouo pushed a commit to abikouo/amazon.aws that referenced this pull request Oct 24, 2023
…-collections#1037)

networkfirewall_rule_group: Add support for "wait" parameter

SUMMARY
Add support for 'wait' to networkfirewall_rule_group to speed up the integration tests a little.
Note: Module not available in a release yet, so no changelog required.
ISSUE TYPE

Feature Pull Request

COMPONENT NAME
networkfirewall_rule_group
ADDITIONAL INFORMATION

Reviewed-by: Alina Buzachis <None>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
community_review feature This issue/PR relates to a feature request has_issue integration tests/integration mergeit Merge the PR (SoftwareFactory) module module needs_maintainer new_plugin New plugin plugins plugin (any type) tests tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Boot mode and TPM support for AMI creation
4 participants