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

theforeman.foreman.host: Found no results while searching for users with login="The owner" #1045

Closed
markgraf opened this issue Oct 29, 2020 · 1 comment · Fixed by #1089
Closed

Comments

@markgraf
Copy link

SUMMARY

When I'm trying to create a host and pass an owner to the host module, host creation fails with

Found no results while searching for users with login="The owners name"

Turns out the module does not want the owners name (as you would expect), but the owners login instead.

But owner != login. The naming of the module is off here.
The documentation gives no indication that the login should be used here.

So either the property should be renamed to "login", or enhanced to find the appropriate login for the owner with the given name on its own. Or at the very least it should be mentionned in the docs.

Which way to go from here?

ISSUE TYPE
  • Bug Report
ANSIBLE VERSION
$ ansible --version
ansible 2.10.2
  config file = /home/marco/git/ansible/ansible.cfg
  configured module search path = ['/home/marco/git/ansible/library']
  ansible python module location = /home/marco/git/ansible/.venv/lib/python3.8/site-packages/ansible
  executable location = /home/marco/git/ansible/.venv/bin/ansible
  python version = 3.8.5 (default, Sep  5 2020, 10:50:12) [GCC 10.2.0]
COLLECTION VERSION
$ ansible-galaxy collection list

# /home/marco/git/ansible/collections/ansible_collections
Collection               Version
------------------------ -------
theforeman.foreman       1.4.0 
KATELLO/FOREMAN VERSION

This is on a dockerized foreman without katello. Version is 2.2.0-develop

STEPS TO REPRODUCE

Create a host, give owner: Your Name and fail.
Create a host, give owner: your.name@work and succeed.

- name: testcase
  hosts: localhost

  vars:
    server_url: http://localhost:8080
    password: theSuperSecretPassw0rd
    user: admin
    my_hosts:
      - architecture: x86_64
        build: false
        comment: lets encrypt proxy
        compute_profile: my-profile
        compute_resource_name: cluster1
        domain: some.where
        enabled: true
        environment: production
        hostgroup: some.where/default
        ip: 10.x.x.x
        mac: 00:xx:xx:xx:xx:xx
        managed: true
        medium: debian-repo
        model: VMware Virtual Platform
        name: acme.some.where
        operatingsystem: Debian 9.9
        owner: << see above >>
        provision_method: build
        ptable: Preseed custom LVM
        puppet_ca_proxy: foreman.some.where
        puppet_proxy: foreman.some.where
        pxe_loader: PXELinux BIOS
        subnet: prod-net

  tasks:
    - name: host
      theforeman.foreman.host:
        architecture: "{{ loop_host.architecture | mandatory }}"
        build: "{{ loop_host.build | default(omit) }}"
        comment: "{{ loop_host.comment | default(omit) }}"
        compute_attributes: "{{ loop_host.compute_attributes | default(omit) }}"
        compute_profile: "{{ loop_host.compute_profile | default(omit) }}"
        compute_resource: "{{ loop_host.compute_resource_name | default(omit) }}"
        config_groups: "{{ loop_host.config_groups | default(omit) }}"
        content_source: "{{ loop_host.content_source | default(omit) }}"
        content_view: "{{ loop_host.content_view | default(omit) }}"
        domain: "{{ loop_host.domain | default(omit) }}"
        enabled: "{{ loop_host.enabled | default(omit) }}"
        environment: "{{ loop_host.environment | default(omit) }}"
        hostgroup: "{{ loop_host.hostgroup | default(omit) }}"
        image: "{{ loop_host.image | default(omit) }}"
        ip: "{{ loop_host.ip | default(omit) }}"
        kickstart_repository: "{{ loop_host.kickstart_repository | default(omit) }}"
        lifecycle_environment: "{{ loop_host.lifecycle_environment | default(omit) }}"
        location: "{{ loop_host.location | default('Default Location') }}"
        mac: "{{ loop_host.mac | mandatory }}"
        managed: "{{ loop_host.managed | default(omit) }}"
        medium: "{{ loop_host.medium | default(omit) }}"
        name: "{{ loop_host.name | mandatory }}"
        openscap_proxy: "{{ loop_host.openscap_proxy | default(omit) }}"
        operatingsystem: "{{ loop_host.operatingsystem | default(omit) }}"
        organization: "{{ loop_host.organization | default('Default Organization') }}"
        owner: "{{ loop_host.owner | default(omit) }}"
        owner_group: "{{ loop_host.owner_group | default(omit) }}"
        parameters: "{{ loop_host.parameters | default(omit) }}"
        password: "{{ password }}"
        provision_method: "{{ loop_host.provision_method | default(omit) }}"
        ptable: "{{ loop_host.ptable | default(omit) }}"
        puppet_ca_proxy: "{{ loop_host.puppet_ca_proxy | default(omit) }}"
        puppet_proxy: "{{ loop_host.puppet_proxy | default(omit) }}"
        puppetclasses: "{{ loop_host.puppetclasses | default(omit) }}"
        pxe_loader: "{{ loop_host.pxe_loader | default(omit) }}"
        realm: "{{ loop_host.realm | default(omit) }}"
        root_pass: "{{ loop_host.root_pass | default(omit) }}"
        server_url: "{{ server_url }}"
        state: "{{ loop_auth_source_ldap.state | default(omit) }}"
        subnet6: "{{ loop_host.subnet6 | default(omit) }}"
        subnet: "{{ loop_host.subnet | default(omit) }}"
        username: "{{ user }}"
        validate_certs: "{{ validate_certs | default('yes') }}"
      loop: "{{ my_hosts }}"
      loop_control:
        loop_var: loop_host
        label: "{{ loop_host.name }} [{{ loop_host.organization | default('Default') }} / {{ loop_host.location | default('Default')}}]"
EXPECTED RESULTS

I expected the host to be created.

ACTUAL RESULTS
Found no results while searching for users with login="My name here"
evgeni added a commit to evgeni/foreman-ansible-modules that referenced this issue Dec 8, 2020
@evgeni
Copy link
Member

evgeni commented Dec 8, 2020

login is unique, while name is not, so that's what we use.

documentation update in #1089

evgeni added a commit that referenced this issue Dec 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants