ansible-collections / community.aws

Ansible Collection for Community AWS
GNU General Public License v3.0
189 stars 399 forks source link

ec2_asg fails when switching between ec2 and elb health_check_type #929

Closed anjo-swe closed 2 years ago

anjo-swe commented 2 years ago

Summary

When the ec2_asg module tries to switch an ASG from EC2 to ELB health check type it fails because it expects the instances to be part of the ELB and healthy before it can complete the deploy.

Copied https://github.com/ansible/ansible/issues/55884

Issue Type

Bug Report

Component Name

ec2_asg

Ansible Version

$ ansible --version

ansible [core 2.12.2]
  config file = /Users/<USER>/Source/dataintelligence-ansible/ansible.cfg
  configured module search path = ['/Users/<USER>/Source/dataintelligence-ansible/library']
  ansible python module location = /Users/<USER>/Source/dataintelligence-ansible/.runtime/.pyvenv/lib/python3.9/site-packages/ansible
  ansible collection location = /Users/<USER>/.ansible/collections:/usr/share/ansible/collections
  executable location = /Users/<USER>/Source/dataintelligence-ansible/.runtime/.pyvenv/bin/ansible
  python version = 3.9.8 (main, Nov 18 2021, 16:08:04) [Clang 12.0.5 (clang-1205.0.22.9)]
  jinja version = 3.0.3
  libyaml = True

Collection Versions

$ ansible-galaxy collection list

# /Users/<USER>/Source/dataintelligence-ansible/.runtime/.pyvenv/lib/python3.9/site-packages/ansible_collections
Collection                    Version
----------------------------- -------
amazon.aws                    2.1.0
ansible.netcommon             2.5.0
ansible.posix                 1.3.0
ansible.utils                 2.4.3
ansible.windows               1.9.0
arista.eos                    3.1.0
awx.awx                       19.4.0
azure.azcollection            1.11.0
check_point.mgmt              2.2.2
chocolatey.chocolatey         1.1.0
cisco.aci                     2.1.0
cisco.asa                     2.1.0
cisco.intersight              1.0.18
cisco.ios                     2.6.0
cisco.iosxr                   2.6.0
cisco.ise                     1.2.1
cisco.meraki                  2.6.0
cisco.mso                     1.3.0
cisco.nso                     1.0.3
cisco.nxos                    2.8.2
cisco.ucs                     1.6.0
cloud.common                  2.1.0
cloudscale_ch.cloud           2.2.0
community.aws                 2.2.0
community.azure               1.1.0
community.ciscosmb            1.0.4
community.crypto              2.2.0
community.digitalocean        1.15.0
community.dns                 2.0.6
community.docker              2.1.1
community.fortios             1.0.0
community.general             4.4.0
community.google              1.0.0
community.grafana             1.3.0
community.hashi_vault         2.2.0
community.hrobot              1.2.2
community.kubernetes          2.0.1
community.kubevirt            1.0.0
community.libvirt             1.0.2
community.mongodb             1.3.2
community.mysql               2.3.3
community.network             3.0.0
community.okd                 2.1.0
community.postgresql          1.6.1
community.proxysql            1.3.1
community.rabbitmq            1.1.0
community.routeros            2.0.0
community.skydive             1.0.0
community.sops                1.2.0
community.vmware              1.17.1
community.windows             1.9.0
community.zabbix              1.5.1
containers.podman             1.9.1
cyberark.conjur               1.1.0
cyberark.pas                  1.0.13
dellemc.enterprise_sonic      1.1.0
dellemc.openmanage            4.4.0
dellemc.os10                  1.1.1
dellemc.os6                   1.0.7
dellemc.os9                   1.0.4
f5networks.f5_modules         1.14.0
fortinet.fortimanager         2.1.4
fortinet.fortios              2.1.3
frr.frr                       1.0.3
gluster.gluster               1.0.2
google.cloud                  1.0.2
hetzner.hcloud                1.6.0
hpe.nimble                    1.1.4
ibm.qradar                    1.0.3
infinidat.infinibox           1.3.3
infoblox.nios_modules         1.2.1
inspur.sm                     1.3.0
junipernetworks.junos         2.8.0
kubernetes.core               2.2.3
mellanox.onyx                 1.0.0
netapp.aws                    21.7.0
netapp.azure                  21.10.0
netapp.cloudmanager           21.13.0
netapp.elementsw              21.7.0
netapp.ontap                  21.15.1
netapp.storagegrid            21.9.0
netapp.um_info                21.8.0
netapp_eseries.santricity     1.2.13
netbox.netbox                 3.5.1
ngine_io.cloudstack           2.2.2
ngine_io.exoscale             1.0.0
ngine_io.vultr                1.1.0
openstack.cloud               1.6.0
openvswitch.openvswitch       2.1.0
ovirt.ovirt                   1.6.6
purestorage.flasharray        1.12.1
purestorage.flashblade        1.9.0
sensu.sensu_go                1.13.0
servicenow.servicenow         1.0.6
splunk.es                     1.0.2
t_systems_mms.icinga_director 1.27.0
theforeman.foreman            2.2.0
vyos.vyos                     2.6.0
wti.remote                    1.0.3

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: /Users/<USER>/Source/dataintelligence-ansible/.runtime/.pyvenv/lib/python3.9/site-packages
Requires:
Required-by:
---
Name: boto3
Version: 1.20.47
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: /Users/<USER>/Source/dataintelligence-ansible/.runtime/.pyvenv/lib/python3.9/site-packages
Requires: botocore, jmespath, s3transfer
Required-by:
---
Name: botocore
Version: 1.23.48
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: /Users/<USER>/Source/dataintelligence-ansible/.runtime/.pyvenv/lib/python3.9/site-packages
Requires: jmespath, python-dateutil, urllib3
Required-by: boto3, s3transfer

Configuration

$ ansible-config dump --only-changed

OS / Environment

N/A

Steps to Reproduce

Create an AWS ASG with health check type set to EC2. Then use ansible to change ASG from EC2 to ELB health check.

Expected Results

The AWS ASG to switch from EC2 health check type to ELB health check type.

Actual Results

The ec2_asg call fails because the instances in the ASG are not in the ELB and the call to check instance health fails. This results in the elb_healthy and tg_healthy calls returning None. wait_for_elb tries to compare the results with the min cluster size and because it cannot compare None and Int with < operator.

TASK [ec2_asg] *******************************************************************************************************************************************************
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: TypeError: '<' not supported between instances of 'NoneType' and 'int'
fatal: [localhost]: FAILED! => changed=false
  module_stderr: |-
    Traceback (most recent call last):
      File "/tmp/<USER>/.ansible/ansible-tmp-1644022263.6125782-5453-102898479739037/AnsiballZ_ec2_asg.py", line 107, in <module>
        _ansiballz_main()
      File "/tmp/<USER>/.ansible/ansible-tmp-1644022263.6125782-5453-102898479739037/AnsiballZ_ec2_asg.py", line 99, in _ansiballz_main
        invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)
      File "/tmp/<USER>/.ansible/ansible-tmp-1644022263.6125782-5453-102898479739037/AnsiballZ_ec2_asg.py", line 47, in invoke_module
        runpy.run_module(mod_name='ansible_collections.community.aws.plugins.modules.ec2_asg', init_globals=dict(_module_fqn='ansible_collections.community.aws.plugins.modules.ec2_asg', _modlib_path=modlib_path),
      File "/Users/<USER>/.zinit/plugins/pyenv---pyenv/versions/3.9.8/lib/python3.9/runpy.py", line 210, in run_module
        return _run_module_code(code, init_globals, run_name, mod_spec)
      File "/Users/<USER>/.zinit/plugins/pyenv---pyenv/versions/3.9.8/lib/python3.9/runpy.py", line 97, in _run_module_code
        _run_code(code, mod_globals, init_globals,
      File "/Users/<USER>/.zinit/plugins/pyenv---pyenv/versions/3.9.8/lib/python3.9/runpy.py", line 87, in _run_code
        exec(code, run_globals)
      File "/var/folders/tg/xnhm2vz535sfbxwn_vkggxpm0000gq/T/ansible_ec2_asg_payload_yj4jb1aa/ansible_ec2_asg_payload.zip/ansible_collections/community/aws/plugins/modules/ec2_asg.py", line 1857, in <module>
      File "/var/folders/tg/xnhm2vz535sfbxwn_vkggxpm0000gq/T/ansible_ec2_asg_payload_yj4jb1aa/ansible_ec2_asg_payload.zip/ansible_collections/community/aws/plugins/modules/ec2_asg.py", line 1837, in main
      File "/var/folders/tg/xnhm2vz535sfbxwn_vkggxpm0000gq/T/ansible_ec2_asg_payload_yj4jb1aa/ansible_ec2_asg_payload.zip/ansible_collections/community/aws/plugins/modules/ec2_asg.py", line 1342, in create_autoscaling_group
      File "/var/folders/tg/xnhm2vz535sfbxwn_vkggxpm0000gq/T/ansible_ec2_asg_payload_yj4jb1aa/ansible_ec2_asg_payload.zip/ansible_collections/community/aws/plugins/modules/ec2_asg.py", line 1008, in wait_for_elb
    TypeError: '<' not supported between instances of 'NoneType' and 'int'
  module_stdout: ''
  msg: |-
    MODULE FAILURE
    See stdout/stderr for the exact error
  rc: 1

Code of Conduct

ansibullbot commented 2 years ago

Files identified in the description:

If these files are inaccurate, please update the component name section of the description or use the !component bot command.

click here for bot help

ansibullbot commented 2 years ago

cc @garethr @jillr @markuman @s-hertel @tremble click here for bot help

mandar242 commented 2 years ago

Hi @anjo-swe , thank you for reporting this. You still seem to be on collection version 2.2.0 for community.aws, with the latest version of community.aws the issue does not seem to be present. Could you please upgrade (https://docs.ansible.com/ansible/latest/galaxy/user_guide.html#installing-a-collection-from-galaxy) the community.aws version and check if the issue still persist? Thanks!

tremble commented 2 years ago

@anjo-swe

Based on @mandar242's comment I believe this issue has been fixed in recent releases. As such I'm going to close it. If you're still experiencing this issue with the latest releases, feel free to reopen the issue.