Skip to content

one_template only returns templates owned by user but not by group membership #9278

Closed
@skropf

Description

Summary

When I try to instantiate a VM by using a template which is not owned/created by my user, the execution fails by reporting that the template can not be found, although this is possible by using the web interface (thus the permissions/ACLs should be set correctly).

I think I have found the corresponding code lines:

# one_template.py
209    def get_template(self, predicate):
210       # -3 means "Resources belonging to the user"
211       # the other two parameters are used for pagination, -1 for both essentially means "return all"
212       pool = self.one.templatepool.info(-3, -1, -1)
213
214       for template in pool.VMTEMPLATE:
215           if predicate(template):
216               return template
217
218       return None

I can see here that it is intended to only return templates which are owned by the user.

So my question here is if that's how it should be, because I would like to get all templates which are usable by my user and group, so that I can create VMs by using templates where I have access according to groups/ACLs.

Beside the Ansible versions which are stated below the OpenNebula version is 6.8.2

Any help/input is appreciated! Thanks!

Issue Type

Bug Report

Component Name

one_template

Ansible Version

$ ansible --version
ansible [core 2.18.1]
  config file = None
  configured module search path = ['/home/skropf/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/skropf/Work/projects/ansible-playbooks/venv/lib/python3.11/site-packages/ansible
  ansible collection location = /home/skropf/.ansible/collections:/usr/share/ansible/collections
  executable location = /home/skropf/Work/projects/ansible-playbooks/venv/bin/ansible
  python version = 3.11.2 (main, Sep 14 2024, 03:00:30) [GCC 12.2.0] (/home/skropf/Work/projects/ansible-playbooks/venv/bin/python3)
  jinja version = 3.1.4
  libyaml = True

Community.general Version

$ ansible-galaxy collection list community.general

# /home/skropf/.ansible/collections/ansible_collections
Collection        Version
----------------- -------
community.general 10.1.0 

# /home/skropf/Work/projects/ansible-playbooks/venv/lib/python3.11/site-packages/ansible_collections
Collection        Version
----------------- -------
community.general 10.1.0

Configuration

$ ansible-config dump --only-changed
CONFIG_FILE() = None

GALAXY_SERVERS:

OS / Environment

Debian 12

Steps to Reproduce

---
- name: Minimal reproduction playbook
  hosts: localhost
  vars_prompt:
    - name: username
      prompt: Username
      private: no
    - name: password
      prompt: Password
      private: yes
  vars:
    instance: ion2
    domain: example.com
    template_id: 1
  tasks:
    - name: "[Check login] - OpenNebula login + template"
      community.general.one_template:
        api_url: "https://api.{{ instance }}.{{ domain }}"
        api_username: "{{ username }}"
        api_password: "{{ password }}"
        id: "{{ template_id }}"
        #name: "{{ template_name }}"
        template: ""
      check_mode: true # very important, otherwise the template will be overwritten
      changed_when: false

Expected Results

With a template which was created by my user:

[WARNING]: No inventory was parsed, only implicit localhost is available
[WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does not match 'all'
Username: skropf
Password: 

PLAY [Minimal reproduction playbook] *******************************************************************************************************************************************************************************

TASK [Gathering Facts] *********************************************************************************************************************************************************************************************
ok: [localhost]

TASK [[Check login] - OpenNebula login + template] *****************************************************************************************************************************************************************
ok: [localhost]

PLAY RECAP *********************************************************************************************************************************************************************************************************
localhost                  : ok=2    changed=0    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0

Actual Results

With a template which was not created by my user but I have appropriate access according to the ACLs.

[WARNING]: No inventory was parsed, only implicit localhost is available
[WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does not match 'all'
Username: skropf
Password: 

PLAY [Minimal reproduction playbook] *******************************************************************************************************************************************************************************

TASK [Gathering Facts] *********************************************************************************************************************************************************************************************
ok: [localhost]

TASK [[Check login] - OpenNebula login + template] *****************************************************************************************************************************************************************
fatal: [localhost]: FAILED! => {"changed": false, "msg": "There is no template with id=1"}

PLAY RECAP *********************************************************************************************************************************************************************************************************
localhost                  : ok=1    changed=0    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0   

Code of Conduct

  • I agree to follow the Ansible Code of Conduct

Metadata

Assignees

No one assigned

    Labels

    bugThis issue/PR relates to a bugmodulemodulepluginsplugin (any type)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions