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

community.general.consul add_service failing with 'method' object is not iterable #4680

Closed
1 task done
pritpal-sabharwal opened this issue May 16, 2022 · 3 comments · Fixed by #4712
Closed
1 task done
Labels
bug This issue/PR relates to a bug clustering module module plugins plugin (any type) traceback

Comments

@pritpal-sabharwal
Copy link

Summary

When trying to add a service using community.general.consul, the following error is thrown:

The full traceback is:
  File "/tmp/ansible_community.general.consul_payload_6vojovp1/ansible_community.general.consul_payload.zip/ansible_collections/community/general/plugins/modules/consul.py", line 597, in main
  File "/tmp/ansible_community.general.consul_payload_6vojovp1/ansible_community.general.consul_payload.zip/ansible_collections/community/general/plugins/modules/consul.py", line 246, in register_with_consul
  File "/tmp/ansible_community.general.consul_payload_6vojovp1/ansible_community.general.consul_payload.zip/ansible_collections/community/general/plugins/modules/consul.py", line 262, in add
  File "/tmp/ansible_community.general.consul_payload_6vojovp1/ansible_community.general.consul_payload.zip/ansible_collections/community/general/plugins/modules/consul.py", line 336, in add_service
fatal: [webserver00]: FAILED! => {
    "changed": false,
    "invocation": {
        "module_args": {
            "check_host": null,
            "check_id": null,
            "check_name": null,
            "check_node": null,
            "host": "localhost",
            "http": null,
            "interval": null,
            "notes": null,
            "port": 8500,
            "scheme": "http",
            "script": null,
            "service_address": null,
            "service_id": null,
            "service_name": "nginx",
            "service_port": 80,
            "state": "present",
            "tags": null,
            "tcp": null,
            "timeout": null,
            "token": null,
            "ttl": null,
            "validate_certs": true
        }
    },
    "msg": "'method' object is not iterable"
}

I think this was related to the changes in #4590. Specifically, it looks like it is failing due to this line https://github.com/ansible-collections/community.general/blob/main/plugins/modules/clustering/consul/consul.py#L336

I believe that line needs changing to:

checks=[check.to_dict() for check in service.checks()],

I would have opened a PR with this change, but I don't know enough about the inner workings of Ansible, happy to open a PR once this issue has been reviewed and if the suggested changes seem reasonable.

Issue Type

Bug Report

Component Name

community.general.consul

Ansible Version

ansible 2.10.6
  config file = /home/deploy/ansible_user/ansible/ansible.cfg
  configured module search path = ['/home/deploy/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/deploy/.virtualenvs/python3/lib/python3.6/site-packages/ansible
  executable location = /home/deploy/.virtualenvs/python3/bin/ansible
  python version = 3.6.9 (default, Nov  7 2019, 10:44:02) [GCC 8.3.0]

Community.general Version

$ # /home/deploy/.ansible/collections/ansible_collections
Collection        Version
----------------- -------
community.general 4.8.1

Configuration

ANSIBLE_PIPELINING(/home/deploy/ansible_user/ansible/ansible.cfg) = False
ANSIBLE_SSH_ARGS(/home/deploy/ansible_user/ansible/ansible.cfg) = -o ControlMaster=auto -o ControlPersist=15m -o ForwardAgent=yes
ANSIBLE_SSH_CONTROL_PATH(/home/deploy/ansible_user/ansible/ansible.cfg) = /tmp/%%h-%%r
DEFAULT_BECOME_FLAGS(/home/deploy/ansible_user/ansible/ansible.cfg) = -HE
DEFAULT_MANAGED_STR(/home/deploy/ansible_user/ansible/ansible.cfg) = Ansible managed file, do not edit directly
DEFAULT_ROLES_PATH(/home/deploy/ansible_user/ansible/ansible.cfg) = ['/home/deploy/ansible_user/ansible/roles-galaxy', '/home/deploy/ansible_user/ansible/roles']
DEFAULT_SCP_IF_SSH(/home/deploy/ansible_user/ansible/ansible.cfg) = True
HOST_KEY_CHECKING(/home/deploy/ansible_user/ansible/ansible.cfg) = False
TRANSFORM_INVALID_GROUP_CHARS(/home/deploy/ansible_user/ansible/ansible.cfg) = never

OS / Environment

Ubuntu - 18.04.2 LTS

Steps to Reproduce

- name: Register nginx service with the local consul agent
  community.general.consul:
    service_name: nginx
    service_port: 80

Expected Results

The service to be successfully registered with Consul.

Actual Results

The full traceback is:
  File "/tmp/ansible_community.general.consul_payload_6vojovp1/ansible_community.general.consul_payload.zip/ansible_collections/community/general/plugins/modules/consul.py", line 597, in main
  File "/tmp/ansible_community.general.consul_payload_6vojovp1/ansible_community.general.consul_payload.zip/ansible_collections/community/general/plugins/modules/consul.py", line 246, in register_with_consul
  File "/tmp/ansible_community.general.consul_payload_6vojovp1/ansible_community.general.consul_payload.zip/ansible_collections/community/general/plugins/modules/consul.py", line 262, in add
  File "/tmp/ansible_community.general.consul_payload_6vojovp1/ansible_community.general.consul_payload.zip/ansible_collections/community/general/plugins/modules/consul.py", line 336, in add_service
fatal: [webserver00]: FAILED! => {
    "changed": false,
    "invocation": {
        "module_args": {
            "check_host": null,
            "check_id": null,
            "check_name": null,
            "check_node": null,
            "host": "localhost",
            "http": null,
            "interval": null,
            "notes": null,
            "port": 8500,
            "scheme": "http",
            "script": null,
            "service_address": null,
            "service_id": null,
            "service_name": "nginx",
            "service_port": 80,
            "state": "present",
            "tags": null,
            "tcp": null,
            "timeout": null,
            "token": null,
            "ttl": null,
            "validate_certs": true
        }
    },
    "msg": "'method' object is not iterable"
}

Code of Conduct

  • I agree to follow the Ansible Code of Conduct
@ansibullbot
Copy link
Collaborator

Files identified in the description:

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

click here for bot help

@ansibullbot
Copy link
Collaborator

@ansibullbot ansibullbot added bug This issue/PR relates to a bug clustering module module plugins plugin (any type) traceback labels May 16, 2022
@felixfontein
Copy link
Collaborator

CC @russoz since it's about your change

This was referenced Nov 20, 2022
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 clustering module module plugins plugin (any type) traceback
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants