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_asg] fail when update tags inside ASG with KeyError; 'LaunchTemplate #2118

Closed
1 task done
Akasurde opened this issue May 30, 2024 · 6 comments
Closed
1 task done
Assignees
Labels
jira needs_info This issue requires further information. Please answer any outstanding questions

Comments

@Akasurde
Copy link
Member

Summary

`trying to add new tag inside my current ASG created before seems apply changes but appears this error and break

Issue Type

Bug Report

Component Name

ec2_asg

Ansible Version

$ ansible --version
ansible [core 2.16.6]
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/home/user/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/user/.local/lib/python3.10/site-packages/ansible
  ansible collection location = /home/user/.ansible/collections:/usr/share/ansible/collections
  executable location = /home/user/.local/bin/ansible
  python version = 3.10.12 (main, Nov 20 2023, 15:14:05) [GCC 11.4.0] (/usr/bin/python3)
  jinja version = 3.1.4
  libyaml = True

Configuration

# if using a version older than ansible-core 2.12 you should omit the '-t all'
$ ansible-config dump --only-changed -t all
# Since Ansible 2.12 (core):
# To generate an example config file (a "disabled" one with all default settings, commented out):
#               $ ansible-config init --disabled > ansible.cfg
#
# Also you can now have a more complete file by including existing plugins:
# ansible-config init --disabled -t all > ansible.cfg

# For previous versions of Ansible you can check for examples in the 'stable' branches of each version
# Note that this file was always incomplete  and lagging changes to configuration settings

# for example, for 2.9: https://github.com/ansible/ansible/blob/stable-2.9/examples/ansible.cfg

OS / Environment

Ubuntu 22.04 WSL

Steps to Reproduce

    name: Get Auto Scaling Groups for EKS cluster
      amazon.aws.autoscaling_group_info:
        tags:
          eks:cluster-name: add-tags-asg
      register: asg_info
   
   name: Add new tag to Auto Scaling Groups
      amazon.aws.autoscaling_group:
        name: "{{ item.auto_scaling_group_name }}"
        tags:
          - Product: new tag
            propagate_at_launch: true
      loop: "{{ asg_info.results }}"
      register: asg_update
   
   debug: msg="{{ asg_update.stderr }}"`

Expected Results

New tag added to ASG

Actual Results

` 
Traceback (most recent call last):
  File "/tmp/ansible_amazon.aws.autoscaling_group_payload_s3ziqwd6/ansible_amazon.aws.autoscaling_group_payload.zip/ansible_collections/amazon/aws/plugins/modules/autoscaling_group.py", line 1399, in create_autoscaling_group
KeyError: 'LaunchConfigurationName'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/user/.ansible/tmp/ansible-tmp-1717076495.9101698-178940-110762071316883/AnsiballZ_autoscaling_group.py", line 107, in <module>
    _ansiballz_main()
  File "/home/user/.ansible/tmp/ansible-tmp-1717076495.9101698-178940-110762071316883/AnsiballZ_autoscaling_group.py", line 99, in _ansiballz_main
    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)
  File "/home/user/.ansible/tmp/ansible-tmp-1717076495.9101698-178940-110762071316883/AnsiballZ_autoscaling_group.py", line 47, in invoke_module
    runpy.run_module(mod_name='ansible_collections.amazon.aws.plugins.modules.autoscaling_group', init_globals=dict(_module_fqn='ansible_collections.amazon.aws.plugins.modules.autoscaling_group', _modlib_path=modlib_path),
  File "/usr/lib/python3.10/runpy.py", line 224, in run_module
    return _run_module_code(code, init_globals, run_name, mod_spec)
  File "/usr/lib/python3.10/runpy.py", line 96, in _run_module_code
    _run_code(code, mod_globals, init_globals,
  File "/usr/lib/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/tmp/ansible_amazon.aws.autoscaling_group_payload_s3ziqwd6/ansible_amazon.aws.autoscaling_group_payload.zip/ansible_collections/amazon/aws/plugins/modules/autoscaling_group.py", line 2005, in <module>
  File "/tmp/ansible_amazon.aws.autoscaling_group_payload_s3ziqwd6/ansible_amazon.aws.autoscaling_group_payload.zip/ansible_collections/amazon/aws/plugins/modules/autoscaling_group.py", line 1977, in main
  File "/tmp/ansible_amazon.aws.autoscaling_group_payload_s3ziqwd6/ansible_amazon.aws.autoscaling_group_payload.zip/ansible_collections/amazon/aws/plugins/modules/autoscaling_group.py", line 1401, in create_autoscaling_group
KeyError: 'LaunchTemplate'
`

Code of Conduct

  • I agree to follow the Ansible Code of Conduct
@Akasurde
Copy link
Member Author

cc @thinkopensource

@Akasurde
Copy link
Member Author

@thinkopensource This code is only to add new tags to and existing ASG, so there is no template or launchconfig. The objective is to replicate this command in ansible module
aws autoscaling create-or-update-tags --tags ResourceId=my-eks,ResourceType=auto-scaling-group,Key=New tag,Value=New Value,PropagateAtLaunch=true

@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 Jun 4, 2024
@gravesm
Copy link
Member

gravesm commented Jun 4, 2024

@thinkopensource can you provide the version of the collection you are using?

@thinkopensource
Copy link

thinkopensource commented Jun 4, 2024

.local/lib/python3.10/site-packages/ansible_collections
Collection Version


amazon.aws 7.5.0
community.aws 7.2.0

/usr/lib/python3/dist-packages/ansible_collections

Collection Version


amazon.aws 7.6.0
community.aws 7.2.0

But is true that appears 2 times, can affect this?

@GomathiselviS GomathiselviS self-assigned this Jul 2, 2024
@GomathiselviS
Copy link
Collaborator

Hi @Akasurde @thinkopensource,

I tried adding a tag to the existing ASG and didn't encounter any issues with both the latest amazon.aws collection and amazon.aws 7.5.0. From the module code, it appears that if the ASG exists, the launch template for the ASG will be available and won't result in the error mentioned above. Could you please share the output of asg_info from the playbook above? Additionally, please refer to a similar task used for testing this module.

@GomathiselviS GomathiselviS 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 2, 2024
@GomathiselviS
Copy link
Collaborator

Hi @Akasurde @thinkopensource , since the issue is not reproducible from our end, I am closing this issue. If you happen to reencounter the issue, please feel free to reopen it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
jira needs_info This issue requires further information. Please answer any outstanding questions
Projects
None yet
Development

No branches or pull requests

4 participants