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

Allow using salt modules in onlyif and unless #51846

Merged
merged 8 commits into from
Mar 7, 2019

Conversation

gtmanfred
Copy link
Contributor

What does this PR do?

Allow using salt modules in onlyif and unless

What issues does this PR fix or reference?

Implements #5050
Implements #51604

Previous Behavior

Can only use commands that run through cmd.retcode

New Behavior

Can use any salt module, and the result is determined by the trueish or falsish return of the module.

Tests written?

Yes

Commits signed with GPG?

Yes

@gtmanfred
Copy link
Contributor Author

@saltstack/team-core can I get a review on this.

Thanks!
Daniel

salt/state.py Show resolved Hide resolved
@gtmanfred
Copy link
Contributor Author

Ok, this should be good to merge 😄

@mchugh19
Copy link
Contributor

This is pretty major and should get a shout out in the release notes too

@max-arnold
Copy link
Contributor

@gtmanfred Unfortunately, this doesn't work consistently across all states and needs to be improved. The following states have their own mod_run_check implementations:

  • states.git
  • states.cmd
  • states.macpackage
  • states.file
  • states.docker_container

This is where unless/onlyif get skipped: https://github.com/saltstack/salt/blob/develop/salt/state.py#L1955-L1957

I discovered this while trying to fix slots #53307

@mchugh19
Copy link
Contributor

mchugh19 commented Jun 1, 2019

The following states have their own mod_run_check implementations

In glancing over those states, it's not immediately obvious why they have their own mod_run_check implementations? Would functionality change if they were just removed?

@gtmanfred
Copy link
Contributor Author

They had unless and onlyif implementations before unless and onlyif was implemented, and unless/onlyif was a simpler implementation, so instead of having to make compatible changes for everything that the cmd.run onlyif did, i just let it be configured to be able to customize it.

mchugh19 pushed a commit to mchugh19/salt that referenced this pull request Oct 13, 2019
Allow using salt modules in onlyif and unless
@waynew waynew added the has master-port port to master has been created label Jan 21, 2020
yuriks added a commit to yuriks/salt that referenced this pull request Mar 23, 2020
This seems to have been corrupted by a bad merge when merging saltstack#51846
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
has master-port port to master has been created
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants