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: Change logic of deleting resources #279

Merged
merged 1 commit into from
Jan 22, 2025

Conversation

klaphi
Copy link
Contributor

@klaphi klaphi commented Oct 8, 2024

This PR changes the logic of deleting resources of the EC2 driver. Without that change security groups and keypairs will stay because the tasks will be skipped.

The tasks Write Molecule instance configs changes the when condition of the block immediately. This will skip the following tasks regardless of their when conditions. Moving the tasks Write Molecule instance configs to the end of the block will execute the cleanup of Security groups and keypairs according to their own when condition.

@klaphi
Copy link
Contributor Author

klaphi commented Oct 8, 2024

This will fix: #280

@apatard
Copy link
Member

apatard commented Dec 20, 2024

While the change looks fine (the cleanup should always be done in the end imho), some questions for you:

  • I've given a brief look and I'm having hard time to understand how it's solving your issue. Can you please give more details ?
  • Which version of molecule are you using ? iirc, the cookiecutter stuff is not used anymore theses days.

@apatard apatard added bug Something isn't working ec2 Amazon EC2 labels Dec 20, 2024
@bparry02
Copy link

bparry02 commented Jan 18, 2025

I was running into this issue as well (ephemeral security groups not being deleted during destroy), and this change resolved the issue. Thank you @klaphi !

I've given a brief look and I'm having hard time to understand how it's solving your issue. Can you please give more details ?

I assume there is some lazy loading of the platform variable going on, and when the backing file is updated it affects usage of that variable in later code.

Which version of molecule are you using ? iirc, the cookiecutter stuff is not used anymore theses days.

The scenario init with ec2 driver did not provide a working configuration for me, so I had to manually copy down create.yml and destroy.yml from GitHub. Ansible and molecule versions are below:

ansible                   8.7.0
ansible-compat            24.10.0
ansible-core              2.15.13
ansible-lint              24.12.2
molecule                  24.12.0
molecule-plugins          23.6.0
$ molecule --version
molecule 24.12.0 using python 3.12 
    ansible:2.15.13
    gce:23.6.0 from molecule_plugins requiring collections: google.cloud>=1.0.2 community.crypto>=1.8.0
    podman:23.6.0 from molecule_plugins requiring collections: containers.podman>=1.7.0 ansible.posix>=1.3.0
    ec2:23.6.0 from molecule_plugins
    default:24.12.0 from molecule
    vagrant:23.6.0 from molecule_plugins
    docker:23.6.0 from molecule_plugins requiring collections: community.docker>=3.4.11 ansible.posix>=1.4.0
    containers:23.6.0 from molecule_plugins requiring collections: ansible.posix>=1.3.0 community.docker>=1.9.1 containers.podman>=1.8.1
    openstack:23.6.0 from molecule_plugins requiring collections: openstack.cloud>=2.1.0
    azure:23.6.0 from molecule_plugins

@apatard
Copy link
Member

apatard commented Jan 22, 2025

I was running into this issue as well (ephemeral security groups not being deleted during destroy), and this change resolved the issue. Thank you @klaphi !

Thanks for confirming it's working for someone else. It's helping me making a decision :)

I've given a brief look and I'm having hard time to understand how it's solving your issue. Can you please give more details ?

I assume there is some lazy loading of the platform variable going on, and when the backing file is updated it affects usage of that variable in later code.

hm. I see...

Which version of molecule are you using ? iirc, the cookiecutter stuff is not used anymore theses days.

The scenario init with ec2 driver did not provide a working configuration for me, so I had to manually copy down create.yml and destroy.yml from GitHub. Ansible and molecule versions are below:

Ok, so the files were manually copied. That's confirming what I've suspected.

@apatard apatard enabled auto-merge (rebase) January 22, 2025 10:54
Copy link
Member

@apatard apatard left a comment

Choose a reason for hiding this comment

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

Not sure how it's working but someone else confirmed the issue and that the fix is solving it, so I'm approving

…, because this task changes the when condition of the block immediately and following tasks will be skipped regardless ot their when condition.
@apatard apatard force-pushed the bug/fix-aws-delete-logic branch from e8b4f00 to 223119b Compare January 22, 2025 16:57
@apatard apatard merged commit 613b885 into ansible-community:main Jan 22, 2025
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working ec2 Amazon EC2
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants