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

ipa_hostgroup state 'enabled', 'disabled' do not work #8408

Closed
1 task done
jelion opened this issue May 23, 2024 · 2 comments · Fixed by #8900
Closed
1 task done

ipa_hostgroup state 'enabled', 'disabled' do not work #8408

jelion opened this issue May 23, 2024 · 2 comments · Fixed by #8900
Labels
bug This issue/PR relates to a bug module module plugins plugin (any type)

Comments

@jelion
Copy link

jelion commented May 23, 2024

Summary

The module 'ipa_hostgroup' documents that its 'state' parameter accepts 4 values: 'absent', 'disabled', 'enabled', and 'present'.

However, when 'disabled' or 'enabled' is passed in, the hostgroup does not get created. (In fact, the hostgroup gets deleted if it exists!)

Looking at the code in this repository, it is obvious: in the 'ensure' function, the code only checks "if state == 'present'" around line 163; when 'enabled' or 'disabled' is passed in, the "delete hostgroup" if branch gets taken! (In the similar ipa_hbacrule module, the test at the equivalent point in code is a membership test - "if state in ['present', 'enabled', 'disabled']

It seems to me that hostgroups are not something that are enabled or disabled, so it is possible the correct action is to not accept those values. However, I realize that could create version compatibility issues; if it does accept 'enabled' and 'disabled', , then an enabled or disabled hostgroup should probably get created!

Issue Type

Bug Report

Component Name

ipa_hostgroup

Ansible Version

$ ansible --version
ansible [core 2.14.2]
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/var/paas/tmp/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3.11/site-packages/ansible
  ansible collection location = /var/paas/tmp/collections:/usr/share/ansible/collections
  executable location = /usr/bin/ansible
  python version = 3.11.5 (main, Sep 22 2023, 15:34:29) [GCC 8.5.0 20210514 (Red Hat 8.5.0-20)] (/usr/bin/python3.11)
  jinja version = 3.1.2
  libyaml = True

Community.general Version

$ ansible-galaxy collection list community.general

# /usr/share/ansible/collections/ansible_collections
Collection        Version
----------------- -------
community.general 6.5.0

Configuration

$ ansible-config dump --only-changed

OS / Environment

RHEL 8

Steps to Reproduce

---
- hosts: all
  gather_facts: false
  tasks:
  - ipa_hostgroup:
      # 'present' works.
      # 'enabled' and 'disabled' behave equivalent to 'absent'
      state: 'enabled'
      name:  'testhostgroup'

      # adjust for your environment!
      ipa_host: '{{ ipa.fqdn }}'
      ipa_user: 'admin'
      ipa_pass: '{{ pwd_content.admin_pass }}'

Expected Results

When I ran the playbook shown above, I expected the hostgroup to get created. It did not. "ipa hostgroup-find testhostgroup" returned zero results.

When I changed the playbook to use state='present', the hostgroup was created as expected.

When I changed it back to 'enabled' and ran it again, the hostgroup I had just created with 'present' was deleted! I certainly did not expect that!

Actual Results

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

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 module module plugins plugin (any type)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants