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

host module failing to operate due to FQDN issue #1563

Open
Ricker42 opened this issue Feb 24, 2023 · 1 comment
Open

host module failing to operate due to FQDN issue #1563

Ricker42 opened this issue Feb 24, 2023 · 1 comment

Comments

@Ricker42
Copy link

SUMMARY

When using the theforeman.foreman.host module, it will not execute if the name parameter is not a FQDN. However, not all hosts are always listed that way in the database, so when it attempts to identify the content host via lookup it fails to find it and thus does not execute the requested function

ISSUE TYPE
  • Bug Report
ANSIBLE VERSION
ansible [core 2.13.3]
  config file = /home/rgreene/ansible/satellite/ansible.cfg
  configured module search path = ['/home/rgreene/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3.9/site-packages/ansible
  ansible collection location = /home/rgreene/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/bin/ansible
  python version = 3.9.13 (main, Nov  9 2022, 13:16:24) [GCC 8.5.0 20210514 (Red Hat 8.5.0-15)]
  jinja version = 3.1.2
  libyaml = True
COLLECTION VERSION
Collection         Version
------------------ -------
theforeman.foreman 3.8.0  
KATELLO/FOREMAN VERSION
tfm-rubygem-katello-4.3.0.50-1.el7sat.noarch
foreman-3.1.1.25-1.el7sat.noarch
STEPS TO REPRODUCE
[content_hosts]
rgreene-rhel79.tamlab.rdu2.redhat.com  content_host=rgreene-rhel79
---
- name: Remove host from Satellite inventory
  hosts: content_hosts
  gather_facts: yes
  become: yes

  vars:
    old_satellite: "sat6.******.com"

  vars_files:
    - satpass.yml

  tasks:

    - name: Remove host from old Satellite
      theforeman.foreman.host:
        password: "{{ satpassword }}"
        username: "{{ satuser }}"
        server_url: "https://{{ old_satellite }}"
        name: "{{ content_host }}"
        state: absent
        validate_certs: false
EXPECTED RESULTS

End result of the playbook should be the content-host "test-server" being removed from foreman/katello

ACTUAL RESULTS
ansible-playbook -vvvv --diff --ask-vault-password -i sat.inventory.yml remove_host.yml
[ansible.log](https://github.com/theforeman/foreman-ansible-modules/files/10828198/ansible.log)
@Ricker42
Copy link
Author

I was able to run the playbook successfully by modifying my ~/.ansible/collections/ansible_collections/theforeman/foreman/plugins/modules/host.py file to comment out the following lines (lines 461-462 in my version):
if '.' not in module.foreman_params['name']:
module.fail_json(msg="The hostname must be FQDN")

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

No branches or pull requests

1 participant