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

State in ec2_instance is bypassed #2152

Closed
1 task done
rchassaigne opened this issue Jun 27, 2024 · 3 comments
Closed
1 task done

State in ec2_instance is bypassed #2152

rchassaigne opened this issue Jun 27, 2024 · 3 comments
Labels
needs_info This issue requires further information. Please answer any outstanding questions

Comments

@rchassaigne
Copy link

Summary

When I try to start, stop or restart an instance and set the state parameter, module want to create an instance

Issue Type

Bug Report

Component Name

ec2_instance

Ansible Version

$ ansible --version
ansible [core 2.15.12]
  config file = None
  configured module search path = ['/home/ec2-user/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/local/lib/python3.9/site-packages/ansible
  ansible collection location = /home/ec2-user/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/local/bin/ansible
  python version = 3.9.16 (main, Apr 24 2024, 00:00:00) [GCC 11.4.1 20230605 (Red Hat 11.4.1-2)] (/usr/bin/python3)
  jinja version = 3.1.4
  libyaml = True

Collection Versions

$ ansible-galaxy collection list
Collection                    Version
----------------------------- -------
amazon.aws                    8.0.1

AWS SDK versions

$ pip show boto boto3 botocore
Name: boto
Version: 2.49.0
Summary: Amazon Web Services Library
Home-page: https://github.com/boto/boto/
Author: Mitch Garnaat
Author-email: [email protected]
License: MIT
Location: /home/ec2-user/.local/lib/python3.9/site-packages
Requires:
Required-by:
---
Name: boto3
Version: 1.34.134
Summary: The AWS SDK for Python
Home-page: https://github.com/boto/boto3
Author: Amazon Web Services
Author-email:
License: Apache License 2.0
Location: /home/ec2-user/.local/lib/python3.9/site-packages
Requires: botocore, jmespath, s3transfer
Required-by:
---
Name: botocore
Version: 1.34.134
Summary: Low-level, data-driven core of boto 3.
Home-page: https://github.com/boto/botocore
Author: Amazon Web Services
Author-email:
License: Apache License 2.0
Location: /home/ec2-user/.local/lib/python3.9/site-packages
Requires: jmespath, python-dateutil, urllib3
Required-by: boto3, s3transfer

Configuration

$ ansible-config dump --only-changed
CONFIG_FILE() = None

OS / Environment

amazon linux 2023

Steps to Reproduce

---
- name: This playbook is used to stop the ec2 Instance
  hosts: localhost
  connection: local
  vars:
    instance_ids:
      - "i-***************"
  tasks:
    - name: restart a particular instance by its ID
      amazon.aws.ec2_instance:
        state: restarted
        instance_ids: "{{ instance_ids }}"

Expected Results

Execute the state I wanted on the specific instance set in instance_ids

Actual Results

fatal: [localhost]: FAILED! => {"changed": false, "msg": "You must include an image_id or image.id parameter to create an instance, or use a launch_template."}

Code of Conduct

  • I agree to follow the Ansible Code of Conduct
@gravesm gravesm added needs_verified Some one might want to take a look at this and reproduce it to confirm and removed needs_triage labels Jul 2, 2024
@abikouo
Copy link
Contributor

abikouo commented Jul 4, 2024

@rchassaigne this is reproducible when the instance id specified does not exist.
Please ensure the instance id is valid and give it another try.

@abikouo abikouo added needs_info This issue requires further information. Please answer any outstanding questions and removed needs_verified Some one might want to take a look at this and reproduce it to confirm labels Jul 4, 2024
@rchassaigne
Copy link
Author

@rchassaigne this is reproducible when the instance id specified does not exist. Please ensure the instance id is valid and give it another try.

I'm really sorry ! That should be the very first verification I needed to make. You are right, the instance ID I was trying on does not exist anymore.

Is the error message should return an exception like InvalidInstanceID.NotFound instead ? (reported from the AWS CLI)

@abikouo
Copy link
Contributor

abikouo commented Jul 4, 2024

@rchassaigne the ec2_instance module uses input parameters to retrieve the existing instances (using describe_instances, this does to raise an InvalidInstanceID.NotFound exception), if none is found a RunInstance operation is triggered

@abikouo abikouo closed this as completed Jul 4, 2024
abikouo added a commit to abikouo/amazon.aws that referenced this issue Oct 9, 2024
…#2152)

SUMMARY

Refactor module ec2_vpc_egress_igw to use shared code from amazon.aws.plugins.module_utils.ec2
ec2_vpc_egress_igw - add support for tagging

ISSUE TYPE

Feature Pull Request
New Module Pull Request

COMPONENT NAME

ec2_vpc_egress_igw

Reviewed-by: Alina Buzachis
Reviewed-by: Bikouo Aubin
Reviewed-by: GomathiselviS

This commit was initially merged in https://github.com/ansible-collections/community.aws
See: ansible-collections/community.aws@7b51659
abikouo added a commit to abikouo/amazon.aws that referenced this issue Oct 14, 2024
…#2152)

SUMMARY

Refactor module ec2_vpc_egress_igw to use shared code from amazon.aws.plugins.module_utils.ec2
ec2_vpc_egress_igw - add support for tagging

ISSUE TYPE

Feature Pull Request
New Module Pull Request

COMPONENT NAME

ec2_vpc_egress_igw

Reviewed-by: Alina Buzachis
Reviewed-by: Bikouo Aubin
Reviewed-by: GomathiselviS

This commit was initially merged in https://github.com/ansible-collections/community.aws
See: ansible-collections/community.aws@7b51659
abikouo added a commit to abikouo/amazon.aws that referenced this issue Oct 15, 2024
…#2152)

SUMMARY

Refactor module ec2_vpc_egress_igw to use shared code from amazon.aws.plugins.module_utils.ec2
ec2_vpc_egress_igw - add support for tagging

ISSUE TYPE

Feature Pull Request
New Module Pull Request

COMPONENT NAME

ec2_vpc_egress_igw

Reviewed-by: Alina Buzachis
Reviewed-by: Bikouo Aubin
Reviewed-by: GomathiselviS

This commit was initially merged in https://github.com/ansible-collections/community.aws
See: ansible-collections/community.aws@7b51659
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs_info This issue requires further information. Please answer any outstanding questions
Projects
None yet
Development

No branches or pull requests

3 participants