Skip to content

Update state.module docs - #52420

Merged
waynew merged 4 commits into
saltstack:developfrom
waynew:better-module.run-docs
Apr 18, 2019
Merged

waynew merged 4 commits into
saltstack:developfrom
waynew:better-module.run-docs

Conversation

@waynew

@waynew waynew commented Apr 4, 2019 •

Copy link
Copy Markdown
Contributor

I'm not sure if this should just go against develop, or if I should rebase and direct towards 2018.3.

What does this PR do?

(Attempts) to clarify the module state docs. It wasn't immediately obvious from the docs that there was an old and new style, and the note about manually enabling them was all the way at the bottom.

What issues does this PR fix or reference?

fixes #44882
fixes #51349
Maybe some others?

Tests written?

No - doc only (but new examples were tested manually)

Commits signed with GPG?

Yes

Hopefully this should be easier to grok, as well as more obvious that
the documentation contains two styles.
@waynew

waynew commented Apr 4, 2019

Copy link
Copy Markdown
Contributor Author

@cr1st1p / @bryceml does this improve the module.run docs? I'm hoping it should make things a little nicer 🙂

@bryceml

bryceml commented Apr 4, 2019 •

Copy link
Copy Markdown
Contributor

If one is a newer style, I would mention what salt versions accept the newer style and when/if the old style will be deprecated as well. It looks a lot better than it did for sure.

@waynew

waynew commented Apr 5, 2019

Copy link
Copy Markdown
Contributor Author

@bryceml AFAICT it's supported by all the current versions of Salt. I couldn't find any specific information about how the with_deprecated decorator is really supposed to be used, but if I grok this correctly it should be swapped out in the Sodium release?

I'll update to include that note.

@cr1st1p

cr1st1p commented Apr 5, 2019

Copy link
Copy Markdown

Sometimes I'm picky so, feel free to use or not my suggestions :-)
Also, they're not all related to your changes and, mind you, I haven't worked with the module.run since reporting the issue(s).

My suggestions aside, I really appreciate your efforts! Thank you and keep it rolling!

a) I had a little bit of a problem grasping the purpose of the comment '# note the trailing ':' '
What do you think if we would start by giving the general form of usage, something like:

# Old style:
some identifier:
  - module.run:
    - name: module_function_to_call # or use module_function_to_call *as* identifier
    - arg1: value  # for that function
    - arg2: value  # for that function
    - other standard *state* parameters
   
# new style:
some identifier:
  - module.run:
    - module_function_to_call : 
      - arg1: value
      - arg2: value
   - other standard *state* parameters

Alternative: do not use examples using a module function call that do not require any argument (network.interfaces), but use an example that does require one.
(Update: Heh...one small mistake on my part, see f) and g) :-)

b) it is not clear (to me), if with the Sodium release, I must remove that configuration snippet. I.e. If I keep it and upgrade to Sodium release, will it error out? Probably a dev should chime in with that info.

c) One example seems bogus to me (untested):
Old style, it seems to call module function hosts.lists ( https://docs.saltstack.com/en/latest/ref/modules/all/salt.modules.hosts.html doesn't show the 'lists' function)
New style example calls hosts.lists_hosts (probably correct)

d) I wouldn't mix usage of 'old' and 'legacy' words
e) Same for 'new style' and 'modern'. 'Modern examples' sounds strange to me, for example.
f) using as starting example a module function call that takes another module function (namely 'mine.send') is very confusing. I had to re-read that part of the current online document several times. Because at first look I thought main actor is module function network.interfaces , then some other things did not look right.
But in fact, the code is about module function 'mine.send'.
g) side effect of f) - I am not sure if the 1st example, in 'new style', is correct.

Thank you again for your effort!

@waynew

waynew commented Apr 5, 2019

Copy link
Copy Markdown
Contributor Author

Sometimes I'm picky so, feel free to use or not my suggestions :-)

I'll be sure to take them with a grain of salt :trollface:

a) I had a little bit of a problem grasping the purpose of the comment '# note the trailing ':' '

Mainly to call out the fact that it's necessary, and new. I can't tell you the number of times that I've stared at two similar code samples that were off by one character before I finally realized they were different.

What do you think if we would start by giving the general form of usage

I'm not against that - though we definitely should have the case where no argument is required, because it's different and not at all intuitive. I certainly never would have guessed at that syntax

b) it is not clear (to me), if with the Sodium release, I must remove that configuration snippet. I.e. If I keep it and upgrade to Sodium release, will it error out? Probably a dev should chime in with that info.

That's probably because it's not clear to me either :trollface: I'll have to find someone who's familiar with the with_deprecated decorator.

c) One example seems bogus to me (untested):
Old style, it seems to call module function hosts.lists ( https://docs.saltstack.com/en/latest/ref/modules/all/salt.modules.hosts.html doesn't show the 'lists' function)
New style example calls hosts.lists_hosts (probably correct)

Ahhh, good catch - I missed that 👍

d) I wouldn't mix usage of 'old' and 'legacy' words

I probably agree with that. If I change that I'd definitely change it to legacy, if the old style is going to go away, as legacy does (or should) communicate that.

e) Same for 'new style' and 'modern'. 'Modern examples' sounds strange to me, for example.

I could probably poke around in the docs elsewhere to see if there's any kind of convention for indicating new-style syntax.

f) using as starting example a module function call that takes another module function (namely 'mine.send') is very confusing.

I also thought it was a little weird. I was (and still am) of mixed feelings about it - it's cool that it calls out mine.send, since that's a useful thing to think about and use, but I'm not entirely sure if this is the best place for it. I defaulted to leaving the reference in there since that's what the original documentation had.

Oh! Looking a little closer into it, I see what you mean. I did not expect that. That is very very weird.

Yeah, I think I'll probably address the docs and start from a slightly different place there. I think it's probably valuable to keep the mine examples, but I'll stick those towards the end.

Thanks for your input!

Took into account some feedback, also tested more things.
@waynew

waynew commented Apr 17, 2019

Copy link
Copy Markdown
Contributor Author

@cr1st1p take a look at my updated docs. Turns out the existing mine.send samples weren't even valid syntax for salt, so I just went ahead and removed them. Hopefully it should be a bit cleaner now.

@cr1st1p

cr1st1p commented Apr 18, 2019

Copy link
Copy Markdown

@waynew : better ! Thank you!

@dwoz dwoz left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@waynew I think this would be good to backport to 2018.3

@waynew
waynew merged commit 6b1ca7f into saltstack:develop Apr 18, 2019
@waynew
waynew deleted the better-module.run-docs branch April 18, 2019 16:45
garethgreenaway added a commit to garethgreenaway/salt that referenced this pull request Sep 19, 2019
dwoz added a commit that referenced this pull request Jan 1, 2020
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

Successfully merging this pull request may close these issues.

salt.module.run documentation improvement? Documentation for states.state.module is incorrect

4 participants