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

one_host fails when allocating or updating host with ID of 0 #1199

Open
andybro19 opened this issue Oct 30, 2020 · 4 comments · May be fixed by #8907
Open

one_host fails when allocating or updating host with ID of 0 #1199

andybro19 opened this issue Oct 30, 2020 · 4 comments · May be fixed by #8907
Labels
bug This issue/PR relates to a bug cloud module module needs_triage plugins plugin (any type) python3

Comments

@andybro19
Copy link

SUMMARY

The community.general.one_host module fails when allocating the first host (ID: 0) in OpenNebula.
It also fails when updating the template/attributes of the host with an ID of 0.
This occurs even though it appears the host has been allocated or updated successfully in OpenNebula.

I think the problem is that the allocate() and update() functions used on lines 141 and 254 of one_host.py return the ID of the OpenNebula host allocated or updated. The result of these function calls is checked by an if statement, and if the result is 0 then self.fail() is called. Therefore, when updating or allocating the host with an ID of 0 in OpenNebula, ansible needlessly fails when it was actually successful.

ISSUE TYPE
  • Bug Report
COMPONENT NAME

one_host

ANSIBLE VERSION
ansible 2.10.2
  config file = $ANSIBLE_PROJECT/ansible.cfg
  configured module search path = ['$HOME/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = $HOME/.ansible/venv/lib/python3.5/site-packages/ansible
  executable location = $HOME/.ansible/venv/bin/ansible
  python version = 3.5.2 (default, Oct  7 2020, 17:19:02) [GCC 5.4.0 20160609]
CONFIGURATION

OS / ENVIRONMENT

OS: Debian 10

Collection: community.general shipped with ansible 2.10

Packages:

  • OpenNebula 5.12.0.3
  • pyone 5.12.0.3
STEPS TO REPRODUCE

Setup environment:

  1. Create python virtual environment and install ansible + pyone.
  2. Provision OpenNebula front-end.
  3. Provision OpenNebula host.

Steps:

  1. Run example playbook from below.
  2. Verify that the host was successfully added to OpenNebula.
  3. Run example playbook again.
- name: Example
  hosts: localhost
  connection: local
  become: false
  gather_facts: false
  tasks:
    - name: Add host to OpenNebula
      community.general.one_host:
        api_url: "{{ one_api_url }}"
        api_username: "{{ one_api_username }}"
        api_password: "{{ one_api_password }}"
        name: "{{ one_host }}"
        im_mad_name: kvm
        vmm_mad_name: kvm
        template:
          TYPE: "testing"
        state: present
EXPECTED RESULTS

First play:

TASK [Add host to OpenNebula] ********************
changed: [localhost]

Second play:

TASK [Add host to OpenNebula] ********************
ok: [localhost]
ACTUAL RESULTS

First play:

TASK [Add host to OpenNebula] ********************
fatal: [localhost]: FAILED! => {"changed": false, "msg": "could not allocate host"}

Second play:

TASK [Add host to OpenNebula] ********************
fatal: [localhost]: FAILED! => {"changed": false, "msg": "failed to update the host template"}

Third play:

TASK [Add host to OpenNebula] ********************
ok: [localhost]
@ansibullbot
Copy link
Collaborator

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
Collaborator

@ansibullbot ansibullbot added affects_2.10 bug This issue/PR relates to a bug cloud module module needs_triage plugins plugin (any type) python3 labels Oct 30, 2020
@ansibullbot
Copy link
Collaborator

@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

@abakanovskii abakanovskii linked a pull request Sep 24, 2024 that will close this issue
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 cloud module module needs_triage plugins plugin (any type) python3
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants