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

Errors removing instances from classic ELB with ec2_elb #384

Closed
jonesetc opened this issue Feb 2, 2021 · 6 comments · Fixed by #768
Closed

Errors removing instances from classic ELB with ec2_elb #384

jonesetc opened this issue Feb 2, 2021 · 6 comments · Fixed by #768
Labels
bug This issue/PR relates to a bug module module plugins plugin (any type) python3 traceback waiting_on_contributor Needs help. Feel free to engage to get things unblocked

Comments

@jonesetc
Copy link

jonesetc commented Feb 2, 2021

SUMMARY

When attempting to use the ec2_elb task to deregister an EC2 instance from a classic ELB there is an error in the task that causes a failure. I believe that this is because of an attempt to sort the load balancer objects returned from boto here:

lbs = sorted(lb for lb in elbs if lb.name in ec2_elbs)

I'm not sure how this has ever worked if this is the issue though. This was stumbled upon while attempting to upgrade from an older version of ansible that packaged this task in its release.

ISSUE TYPE
  • Bug Report
COMPONENT NAME

ec2_elb

ANSIBLE VERSION
ansible 2.10.5
  config file = None
  configured module search path = ['/var/lib/jenkins/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/local/lib/python3.9/site-packages/ansible
  executable location = /usr/local/bin/ansible
  python version = 3.9.1 (default, Jan 12 2021, 16:45:25) [GCC 8.3.0]
CONFIGURATION

OS / ENVIRONMENT

Running a local action in a docker python:3 container

STEPS TO REPRODUCE

Have an instance in 2 classic ELBs in us-east-1

create and run dummy playbook:

---
- hosts: omitted_instance

  tasks:
    - name: Gathering ec2 facts
      action: amazon.aws.ec2_metadata_facts

    - name: Deregister from ELBs
      local_action:
        module: community.aws.ec2_elb
        region: us-east-1
        instance_id: "<instance_id_here>"
        state: absent
EXPECTED RESULTS

instance is removed from ELBs and those names are added as a fact as described in the docs for this task.

ACTUAL RESULTS

an internal error is thrown pointing to a comparison of incomparable objects TypeError: '<' not supported between instances of 'LoadBalancer' and 'LoadBalancer'

The full traceback is:
Traceback (most recent call last):
  File "/var/lib/jenkins/.ansible/tmp/ansible-tmp-1612291327.547425-179-279051715647782/AnsiballZ_ec2_elb.py", line 102, in <module>
    _ansiballz_main()
  File "/var/lib/jenkins/.ansible/tmp/ansible-tmp-1612291327.547425-179-279051715647782/AnsiballZ_ec2_elb.py", line 94, in _ansiballz_main
    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)
  File "/var/lib/jenkins/.ansible/tmp/ansible-tmp-1612291327.547425-179-279051715647782/AnsiballZ_ec2_elb.py", line 40, in invoke_module
    runpy.run_module(mod_name='ansible_collections.community.aws.plugins.modules.ec2_elb', init_globals=None, run_name='__main__', alter_sys=True)
  File "/usr/local/lib/python3.9/runpy.py", line 210, in run_module
    return _run_module_code(code, init_globals, run_name, mod_spec)
  File "/usr/local/lib/python3.9/runpy.py", line 97, in _run_module_code
    _run_code(code, mod_globals, init_globals,
  File "/usr/local/lib/python3.9/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/tmp/ansible_community.aws.ec2_elb_payload_q8xjxrxt/ansible_community.aws.ec2_elb_payload.zip/ansible_collections/community/aws/plugins/modules/ec2_elb.py", line 367, in <module>
  File "/tmp/ansible_community.aws.ec2_elb_payload_q8xjxrxt/ansible_community.aws.ec2_elb_payload.zip/ansible_collections/community/aws/plugins/modules/ec2_elb.py", line 346, in main
  File "/tmp/ansible_community.aws.ec2_elb_payload_q8xjxrxt/ansible_community.aws.ec2_elb_payload.zip/ansible_collections/community/aws/plugins/modules/ec2_elb.py", line 107, in __init__
  File "/tmp/ansible_community.aws.ec2_elb_payload_q8xjxrxt/ansible_community.aws.ec2_elb_payload.zip/ansible_collections/community/aws/plugins/modules/ec2_elb.py", line 269, in _get_instance_lbs
TypeError: '<' not supported between instances of 'LoadBalancer' and 'LoadBalancer'
fatal: [hostname_omitted]: FAILED! => {
    "changed": false,
    "module_stderr": "Traceback (most recent call last):\n  File \"/var/lib/jenkins/.ansible/tmp/ansible-tmp-1612291327.547425-179-279051715647782/AnsiballZ_ec2_elb.py\", line 102, in <module>\n    _ansiballz_main()\n  File \"/var/lib/jenkins/.ansible/tmp/ansible-tmp-1612291327.547425-179-279051715647782/AnsiballZ_ec2_elb.py\", line 94, in _ansiballz_main\n    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\n  File \"/var/lib/jenkins/.ansible/tmp/ansible-tmp-1612291327.547425-179-279051715647782/AnsiballZ_ec2_elb.py\", line 40, in invoke_module\n    runpy.run_module(mod_name='ansible_collections.community.aws.plugins.modules.ec2_elb', init_globals=None, run_name='__main__', alter_sys=True)\n  File \"/usr/local/lib/python3.9/runpy.py\", line 210, in run_module\n    return _run_module_code(code, init_globals, run_name, mod_spec)\n  File \"/usr/local/lib/python3.9/runpy.py\", line 97, in _run_module_code\n    _run_code(code, mod_globals, init_globals,\n  File \"/usr/local/lib/python3.9/runpy.py\", line 87, in _run_code\n    exec(code, run_globals)\n  File \"/tmp/ansible_community.aws.ec2_elb_payload_q8xjxrxt/ansible_community.aws.ec2_elb_payload.zip/ansible_collections/community/aws/plugins/modules/ec2_elb.py\", line 367, in <module>\n  File \"/tmp/ansible_community.aws.ec2_elb_payload_q8xjxrxt/ansible_community.aws.ec2_elb_payload.zip/ansible_collections/community/aws/plugins/modules/ec2_elb.py\", line 346, in main\n  File \"/tmp/ansible_community.aws.ec2_elb_payload_q8xjxrxt/ansible_community.aws.ec2_elb_payload.zip/ansible_collections/community/aws/plugins/modules/ec2_elb.py\", line 107, in __init__\n  File \"/tmp/ansible_community.aws.ec2_elb_payload_q8xjxrxt/ansible_community.aws.ec2_elb_payload.zip/ansible_collections/community/aws/plugins/modules/ec2_elb.py\", line 269, in _get_instance_lbs\nTypeError: '<' not supported between instances of 'LoadBalancer' and 'LoadBalancer'\n",
    "module_stdout": "",
    "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error",
    "rc": 1
}
@ansibullbot
Copy link

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
Copy link

@ansibullbot ansibullbot added bug This issue/PR relates to a bug module module needs_triage plugins plugin (any type) python3 traceback labels Feb 2, 2021
@jonesetc
Copy link
Author

jonesetc commented Feb 2, 2021

this appears to be a continuation of this closed, but never addressed issue from before this was split out into a collection: ansible/ansible#50367

@gravesm gravesm added waiting_on_contributor Needs help. Feel free to engage to get things unblocked and removed needs_triage labels Mar 19, 2021
@gravesm
Copy link
Member

gravesm commented Mar 19, 2021

@jonesetc Which version of ansible did this work in?

@jonesetc
Copy link
Author

@gravesm It works in every version when using python 2, but has never worked in python 3. If you look at the PR i linked above it fully explains and attempts to address the issue.

ansible-zuul bot pushed a commit that referenced this issue Oct 20, 2021
elb_instance - initial integration tests

SUMMARY
Rewrite elb_instance (ec2_elb) for boto3
ISSUE TYPE

Feature Pull Request

COMPONENT NAME
elb_instance
ADDITIONAL INFORMATION
fixes: #384

Reviewed-by: Markus Bergholz <[email protected]>
Reviewed-by: Alina Buzachis <None>
Reviewed-by: None <None>
@tremble
Copy link
Contributor

tremble commented Oct 20, 2021

Hi @jonesetc sorry it's taken so long.

The original fix you linked to has been merged, and as such a fix should be in place for the next release of this collection.

Hopefully we'll also get this module rewritten using the more recent AWS SDK (boto3).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue/PR relates to a bug module module plugins plugin (any type) python3 traceback waiting_on_contributor Needs help. Feel free to engage to get things unblocked
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants