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_host: Fix enabled and disabled states #8920

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

abakanovskii
Copy link
Contributor

@abakanovskii abakanovskii commented Sep 25, 2024

SUMMARY

Fix enabled and disabled states
Fixes #1094

ISSUE TYPE
  • Bugfix Pull Request
COMPONENT NAME

ipa_host

ADDITIONAL INFORMATION

Im not sure why it is how it is on 267 line of code and what exactly random_password is used for but for better reverse compatibility I kept it
And looking at the ansible-freeipa collection their module is way ahead of this one (if not all of them) so I don't know if these should be maintained in community.general

# Now this works as intended
    - name: disable host
      community.general.ipa_host:
        fqdn: target_fqdn
        state: disabled
        validate_certs: no
        ipa_pass: pass
        ipa_user: user
        ipa_host: host

Copy link
Collaborator

@felixfontein felixfontein left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your contribution!

)
changed = False
if state in ['present', 'enabled', 'disabled']:
if state in ['present', 'enabled']:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change looks wrong. disabled should (apparently) be a special case of present, so the host exists, but is disabled.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, but if there are no host found It would create one which seems to be weird because enabled and disabled are states for managing already existing hosts so I created an additional if statement for that case

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it's weird. But I think there should also be another state, like disabled-or-absent. Depending on what you want to achieve disabled or disabled-or-absent is the right state to use.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added force_creation parameter for that case

description: State to ensure.
description:
- State to ensure.
- V("present") and V("enabled") give the same results.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks wrong to me. A present host can both be enabled or disabled.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, but there are no such thing as 'enabling' host, because host is considered as 'enabled' if it has a keytab so to 'enable' a host you would need to do something completely different https://freeipa.readthedocs.io/en/latest/api/host_disable.html
https://docs.redhat.com/en/documentation/red_hat_enterprise_linux/6/html/identity_management_guide/host-disable#reenabling-hosts
and this module should not create keytab files on its own so I don't see a reason for having 'enabled' state other than to be an alias for 'present'

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know FreeIPA at all, I only know about Ansible semantics, and what I wrote is what enabled/disabled usually means, and seems to be what the module also means (or better: intended do mean) when looking at the current implementation.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, in that case I will keep it as it was before my changes

@felixfontein felixfontein added check-before-release PR will be looked at again shortly before release and merged if possible. backport-8 Automatically create a backport for the stable-8 branch backport-9 Automatically create a backport for the stable-9 branch labels Sep 25, 2024
@ansibullbot
Copy link
Collaborator

@ansibullbot ansibullbot added bug This issue/PR relates to a bug module module needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR plugins plugin (any type) and removed needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR labels Sep 25, 2024
@abakanovskii
Copy link
Contributor Author

Should ipa_* modules even be maintaned as long as ansible-freeipa exists? ipahost from ansible-freeipa seems to be far advanced

@felixfontein
Copy link
Collaborator

And looking at the ansible-freeipa collection their module is way ahead of this one (if not all of them) so I don't know if these should be maintained in community.general

I think there has been a (not sure how long) discussion some years ago of whether the IPA modules should be moved there / whether forces should be combined with that collection, but I'm not sure what happened to it. (I can't find the discussion anymore, unfortunately...)

@felixfontein
Copy link
Collaborator

Now I found #1147 (comment) and some IRC logs from that time. In the IRC logs we kind of agreed that we should ask the FreeIPA community, but I'm not sure this ever happened.

(Right now there's also https://forum.ansible.com/t/5738 which complicates things a bit...)

@abakanovskii
Copy link
Contributor Author

Now I found #1147 (comment) and some IRC logs from that time. In the IRC logs we kind of agreed that we should ask the FreeIPA community, but I'm not sure this ever happened.

(Right now there's also https://forum.ansible.com/t/5738 which complicates things a bit...)

Thanks for the info! Then I will fix this issue for now but will try to not focus on freeipa modules not to reinvent the wheel
I think even if we combine community and freeipa modules it will result in a different namespace anyway :)

@ansibullbot

This comment was marked as outdated.

@ansibullbot ansibullbot added ci_verified Push fixes to PR branch to re-run CI needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR labels Sep 25, 2024
@ansibullbot ansibullbot removed ci_verified Push fixes to PR branch to re-run CI needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR labels Sep 25, 2024
plugins/modules/ipa_host.py Show resolved Hide resolved
plugins/modules/ipa_host.py Outdated Show resolved Hide resolved
@ansibullbot ansibullbot added needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR and removed needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR labels Oct 2, 2024
@felixfontein
Copy link
Collaborator

I cannot judge the IPA parts, but it looks OK to me. I'll merge this in ~a week if nobody objects.

@felixfontein felixfontein removed the backport-8 Automatically create a backport for the stable-8 branch label Oct 2, 2024
Copy link
Collaborator

@russoz russoz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport-9 Automatically create a backport for the stable-9 branch bug This issue/PR relates to a bug check-before-release PR will be looked at again shortly before release and merged if possible. module module plugins plugin (any type)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ipa host disabled bug
4 participants