ansible-collections / amazon.aws

Ansible Collection for Amazon AWS

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

amazon.aws.ec2_instance using *Pascal Case* for "instances" array in output instead of ansible documented snake case in version 7.0.0

life5ign opened this issue · comments

Summary

amazon.aws.ec2_instance using Pascal Case (some might search for "Camel Case" so I'll add that search term here) for "instances" array in output instead of ansible documented snake case as documented here: https://docs.ansible.com/ansible/latest/collections/amazon/aws/ec2_instance_module.html

Issue Type

Bug Report

Component Name

amazon.aws.ec2_instance

Ansible Version

$ ansible --version
ansible [core 2.14.3]
  config file = /home/bryant/src/api_guys/ansible-deploy-vst/config/machines/localhost_owsus_aws.ansible.cfg
  configured module search path = ['/home/bryant/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/bryant/.pyenv/versions/3.10.0/envs/ansible-deploy-vst/lib/python3.10/site-packages/ansible
  ansible collection location = /home/bryant/.ansible/collections:/usr/share/ansible/collections
  executable location = /home/bryant/.pyenv/versions/ansible-deploy-vst/bin/ansible
  python version = 3.10.0 (default, Nov  2 2021, 13:53:11) [GCC 9.3.0] (/home/bryant/.pyenv/versions/3.10.0/envs/ansible-deploy-vst/bin/python3.10)
  jinja version = 3.1.2
  libyaml = False

Collection Versions

$ ansible-galaxy collection list

# /home/bryant/.ansible/collections/ansible_collections
Collection           Version
-------------------- -------
amazon.aws           7.0.0  
ansible.netcommon    1.5.0  
ansible.posix        1.5.4  
community.aws        6.0.0  
community.crypto     2.14.0 
community.docker     3.4.7  
community.general    7.1.0  
community.kubernetes 2.0.1  
community.mysql      3.7.2  
kubernetes.core      2.4.0  

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: mitch@garnaat.com
License: MIT
Location: /home/bryant/.pyenv/versions/3.10.0/envs/ansible-deploy-vst/lib/python3.10/site-packages
Requires: 
Required-by: 
---
Name: boto3
Version: 1.28.30
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/bryant/.pyenv/versions/3.10.0/envs/ansible-deploy-vst/lib/python3.10/site-packages
Requires: botocore, jmespath, s3transfer
Required-by: 
---
Name: botocore
Version: 1.31.30
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/bryant/.pyenv/versions/3.10.0/envs/ansible-deploy-vst/lib/python3.10/site-packages
Requires: jmespath, python-dateutil, urllib3
Required-by: boto3, s3transfer

Configuration

$ ansible-config dump --only-changed
�[0;33mANSIBLE_FORCE_COLOR(/home/bryant/src/api_guys/ansible-deploy-vst/config/machines/localhost_owsus_aws.ansible.cfg) = True�[0m
�[0;33mCACHE_PLUGIN(/home/bryant/src/api_guys/ansible-deploy-vst/config/machines/localhost_owsus_aws.ansible.cfg) = jsonfile�[0m
�[0;33mCACHE_PLUGIN_CONNECTION(/home/bryant/src/api_guys/ansible-deploy-vst/config/machines/localhost_owsus_aws.ansible.cfg) = ~/.ansible/fact_cache�[0m
�[0;33mCACHE_PLUGIN_TIMEOUT(/home/bryant/src/api_guys/ansible-deploy-vst/config/machines/localhost_owsus_aws.ansible.cfg) = 86400�[0m
�[0;33mCALLBACKS_ENABLED(/home/bryant/src/api_guys/ansible-deploy-vst/config/machines/localhost_owsus_aws.ansible.cfg) = ['ansible.posix.profile_tasks']�[0m
�[0;33mCONFIG_FILE() = /home/bryant/src/api_guys/ansible-deploy-vst/config/machines/localhost_owsus_aws.ansible.cfg�[0m
�[0;33mDEFAULT_PRIVATE_KEY_FILE(/home/bryant/src/api_guys/ansible-deploy-vst/config/machines/localhost_owsus_aws.ansible.cfg) = /home/bryant/.ssh/ansible-control-node_rsa�[0m
�[0;33mDEFAULT_REMOTE_USER(/home/bryant/src/api_guys/ansible-deploy-vst/config/machines/localhost_owsus_aws.ansible.cfg) = ubuntu�[0m
�[0;33mDEFAULT_ROLES_PATH(/home/bryant/src/api_guys/ansible-deploy-vst/config/machines/localhost_owsus_aws.ansible.cfg) = ['/home/bryant/.ansible/roles', '/home/bryant/src/api_guys/ansible-deploy-vst/roles']�[0m
�[0;33mDEFAULT_STDOUT_CALLBACK(/home/bryant/src/api_guys/ansible-deploy-vst/config/machines/localhost_owsus_aws.ansible.cfg) = debug�[0m
�[0;33mDEFAULT_TIMEOUT(/home/bryant/src/api_guys/ansible-deploy-vst/config/machines/localhost_owsus_aws.ansible.cfg) = 10�[0m
�[0;33mDEFAULT_VAULT_IDENTITY(/home/bryant/src/api_guys/ansible-deploy-vst/config/machines/localhost_owsus_aws.ansible.cfg) = prod�[0m
�[0;33mDEFAULT_VAULT_PASSWORD_FILE(/home/bryant/src/api_guys/ansible-deploy-vst/config/machines/localhost_owsus_aws.ansible.cfg) = /home/bryant/src/api_guys/ansible-deploy-vst/vault_pass_from_env.sh�[0m
�[0;33mHOST_KEY_CHECKING(/home/bryant/src/api_guys/ansible-deploy-vst/config/machines/localhost_owsus_aws.ansible.cfg) = False�[0m
�[0;33mTRANSFORM_INVALID_GROUP_CHARS(/home/bryant/src/api_guys/ansible-deploy-vst/config/machines/localhost_owsus_aws.ansible.cfg) = always�[0m

OS / Environment

Ubuntu 22.04 (PopOS)

Steps to Reproduce

        - name: Create the template instance without duplicating it
          amazon.aws.ec2_instance:
            profile: "{{ boto_profile }}" 
            state: running
            key_name: "{{ keypair }}"
            security_groups: "{{ security_groups_ids }}"
            instance_type: "{{ instance_type }}"
            # use image_id if defined; if not, use the results from the image lookup above
            image_id: "{{ image_id | default(ubuntu_ami.image_id) }}"
            wait: yes
            region: "{{ region }}"
            # if "subnet_id" is not defined, choose randomly from the list set in the extra vars
            # files
            vpc_subnet_id: "{{ subnet_id | default(subnet_ids | random) }}"
            # use the default setting of the subnet instead of forcing a public ip to be assigned 
            #network:
            #  assign_public_ip: yes
            volumes: '{{ volumes }}'
            purge_tags: no
            tags: "{{ instance_tags }}"
            exact_count: 1
            filters: 
              "tag:Name": "{{ instance_name }}"
          register: exact_count_ec2_instance_result
        
        - name: Wait for a short amount of time
          # to allow the next task to succeed, when the instance was just created
          ansible.builtin.pause:
            seconds: 10

        - name: Debug amazon.aws.ec2_instance registered output
          debug:
            var: exact_count_ec2_instance_result

Expected Results

snake case in the instances array, as documented

Actual Results

ok: [localhost] => {
    "exact_count_ec2_instance_result": {
        "changed": true,
        "failed": false,
        "instance_ids": [
            "i-bar",
            "i-foo"
        ],
        "instances": [
            {
                "AmiLaunchIndex": 0,
                "Architecture": "x86_64",
                "BlockDeviceMappings": [],
                "CapacityReservationSpecification": {
                    "CapacityReservationPreference": "open"
                },
                "ClientToken": "foo",
                "CpuOptions": {
                    "CoreCount": 1,
                    "ThreadsPerCore": 2
                },
                "CurrentInstanceBootMode": "legacy-bios",

Code of Conduct

  • I agree to follow the Ansible Code of Conduct

I don't really want to refactor all of my code...

Hi @life5ign, does the issue still persist for you?
From my testing on 7.0.0, I am unable to reproduce the behavior mentioned in the issue

Closing the issue as unable to reproduce/verify. Please feel free to reopen if required.