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

[FEATURE REQUEST] Ignore service state actions when in chroot #62446

Closed
nicholasmhughes opened this issue Aug 9, 2022 · 3 comments · Fixed by #62717
Closed

[FEATURE REQUEST] Ignore service state actions when in chroot #62446

nicholasmhughes opened this issue Aug 9, 2022 · 3 comments · Fixed by #62717
Assignees
Labels
Feature new functionality including changes to functionality and code refactors, etc. State-Module

Comments

@nicholasmhughes
Copy link
Collaborator

Is your feature request related to a problem? Please describe.
We have a common workflow where we need to manage services, but only when Salt is not running in a chroot. Unless we gate the state blocks with Jinja, it runs and fails since the chroot does not have enough access to perform the action.

Describe the solution you'd like
Simple parameter for every state module function which will ignore actions while in chroot, but act normally when outside of it.

Describe alternatives you've considered
Wrapper Jinja around every service state block (or macros):

{% if grains.get("virtual_subtype") != "chroot" -%}
manage_service:
  service.running:
    - name: service_name

{% endif -%}

Additional context
Somewhat related to issue #38751, although we don't want to take action with this workflow... whereas the solution to that issue would allow some actions to be be taken from within the chroot if allowed.

Please Note
If this feature request would be considered a substantial change or addition, this should go through a SEP process here https://github.com/saltstack/salt-enhancement-proposals, instead of a feature request.

@nicholasmhughes nicholasmhughes added Feature new functionality including changes to functionality and code refactors, etc. State-Module labels Aug 9, 2022
@nicholasmhughes nicholasmhughes self-assigned this Aug 9, 2022
nicholasmhughes added a commit to nicholasmhughes/salt that referenced this issue Aug 9, 2022
@OrangeDog
Copy link
Contributor

This doesn't feel like a good idea. It's a very specific case that's already solved by a generic solution.
A global setting to silently disable a whole state module sounds like it will lead to nasty surprises, especially when formulas are involved.

If a state is written to require services to be in particular states, with lots of requisites on the service, that should all fail rather than continue and mess things up.

@nicholasmhughes
Copy link
Collaborator Author

It's a parameter that enables cleaner state workflows and it should not be enabled by default.

@ggiesen
Copy link
Contributor

ggiesen commented Sep 1, 2022

I'd rather see something like a more generic requisite similar to onlyif but the requisite is defined inline, similar to the slots functionality, where it's executed right before the state is run rather than at state file render time. This would solve a very large number of problems for me, and I think it mostly solves your use case as well.

Something like:

manage_service:
  service.running:
    - name: service_name
    - onlyif: __slot__:salt:grains.get("virtual_subtype") != "chroot"

I think a global option specific to whether a service is running in a chroot is too specific a use case

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature new functionality including changes to functionality and code refactors, etc. State-Module
Projects
None yet
3 participants