19:01:30 #startmeeting core public irc meeting 19:01:30 Meeting started Tue Jul 2 19:01:30 2019 UTC. 19:01:30 This meeting is logged and archived in a public location. 19:01:30 The chair is bcoca. Information about MeetBot at http://wiki.debian.org/MeetBot. 19:01:30 Useful Commands: #action #agreed #halp #info #idea #link #topic. 19:01:30 The meeting name has been set to 'core_public_irc_meeting' 19:01:34 o/ 19:02:03 #topic https://github.com/ansible/ansible/issues/58587 19:02:10 @agowa338 19:02:14 o/ 19:02:18 hi 19:02:59 I'd like to talk about `Support omit within lists #58587` 19:03:59 make your case, as sivel mentioned in ticket this has been requested previouslly (though mostly for dicts) 19:04:01 +1 to the feature. what happens when [omit] is passed? 19:04:18 cyberpear: nothign, since we dont scan all data values/keys for it 19:04:31 it would require writing it into templating and scanning all data structures 19:04:38 Today, it gets passed to the module, which knows nothing about it... 19:04:43 hi! 19:04:47 while 'avoiding' creating the item/key in the first place is already possible and a lot cheaper 19:05:05 nitzmahone: no, the 'module args handler' takes care of it 19:05:09 I'd rather include a filter that zaps omits than have to scan everything for them by default 19:05:12 when module_option=omit_token 19:05:21 bcoca: I'm saying if you include one in a place we aren't looking for it 19:05:46 nitzmahone: we only look for it in one place ... the ask has been for 'many other places' 19:05:52 including playbook keywords 19:05:53 I know. 19:05:56 I like the filter idea 19:06:08 +1 to filter for prune_omit 19:06:10 I'm saying let's do it with a filter and let people opt into it rather than do it everywhere by default 19:06:14 filter will work on a list or dict, but not on a keyword 19:06:26 Keywords already work 19:06:29 a filter is very efficient because you only need to filter what the user explicitly asks for, and the user has a good way to achieve this 19:06:35 Oh, you mean play keywords 19:06:41 nitzmahone: do we have others? 19:06:59 I thought you were talking about module args (the only thing that supports omit today) 19:07:01 afaik it currently only works on 'module options' .. unless you are calling those keywords 19:07:18 Nope, just missed what you originally meant 19:07:19 k, sorry for mixup, since 'args keyword' holds 'module options' 19:07:45 omit would be very useful if supported on keywords in addition to module args but that's different, I think 19:08:00 keywords aside, a filter should cover all the other requests- we could implement on play keywords somewhat easier than other places, but is a separate decision IMO 19:08:13 actually, dont need new filter 19:08:17 (like play and task level items) 19:08:21 True 19:08:26 mylist|reject('equals', omit) 19:08:31 yep 19:08:35 equals_to? 19:08:42 I think it's equal_to 19:08:55 but how would you use a filter in the example within the issue? 19:08:59 So if we *did* do another filter, it'd just be syntactic sugar for --^ 19:09:10 agowa338: var that creats list, use list with |reject on consumption 19:09:15 Put what bcoca said at the end of your chain, it will zap the omits 19:09:38 nitzmahone: his example creates list directly on module option 19:09:42 does it work at depth? 19:09:55 That's where you'd need a custom filter 19:10:21 ... to recurse- I don't think any of the default filters will recurse a structure 19:10:24 most filters dont recurse 19:12:19 https://github.com/ansible/ansible/issues/58587#issuecomment-507808422 19:12:51 lol 19:12:53 felixfontein: slowpoke! 19:12:57 25 seconds too slow 19:13:50 so i think we are -1 on feature, but would be fine with a 'recursive' option for map/select/reject filters? 19:14:19 ok, that should do, but can what if that list is empty? But I see, maybe we should just add that to the documentation of omit? 19:14:20 as long as the default for the option is false, sounds good to me 19:14:36 agowa338: when: mylist <= will skip if empty 19:14:37 agowa338: then you pass an empty list to the module 19:14:58 or do as bcoca said to avoid that :) 19:15:01 If the module can't handle that, it's arguably a bug in the module that should be easily fixed 19:15:14 "hey module, nothing to do!" ;) 19:15:33 I thought about parameters, like in the docker example with ports. 19:16:57 If |list returns an empty list, it should be fine, but if it returns none? 19:17:15 jump off that bridge if you come to it 19:17:22 why should it return none? 19:17:25 https://github.com/ansible/ansible/issues/58587#issuecomment-507809934 <= or just avoid having 'omit' before consuming 19:17:42 felixfontein: That was the question, does it return return an empty list or none? 19:18:05 agowa338: you can control what it returns with |default(None or [] or '' or somethingelse) 19:18:10 I would be really disappointed if it returns something wihch is not a list, so it must be empty list 19:18:55 ^ see my example building list with set_fact+ loop 19:19:30 bcoca: it will do surprising stuff when namestuff was already defined before 19:19:45 felixfontein: it can, so DONT DO THAT 19:20:01 or you can just use vars: namestuff=[] in block 19:20:14 or play/role/etc 19:20:30 why you should use specific var names that are not common e.g 'name' 19:20:37 win_f_names 19:20:51 but that is whole other topic 19:21:00 ok, thanks ;-) , that works for me. And with the recurse option everything that I currently think of should also work. 19:21:33 #topic https://github.com/ansible/community/issues/475#issuecomment-507736121 19:21:50 ^ our rules seem inconsistent about 'module docs' 19:22:13 for required/default we enforce removal if they have default values, but for type we have started enforcing they are required to be present 19:22:37 i would not force either, but that is just me, if we are going to enforce anything i think it should be the same standard, not contradicory ones depending on field 19:22:56 only thing i would enforce (which we already do) is doc type == arg spec type 19:23:00 I'd argue for consistency we should only require if it's not the default (eg, `type='str'` should go away) 19:23:19 but I also don't have strong feelings 19:23:26 do you want to enforc e'if its default it should not appear'? 19:23:28 how about deprecating the default for type? then our current rules are consistent :) 19:24:08 felixfontein: that seems to try to pin the donkey on the tail 19:24:22 We don't like breaking stuff in the module API, and that'd definitely qualify... 19:24:33 We already broke it once with the switch from raw to str 19:24:38 (ish) 19:24:41 +1 to removing type=str, +1 to don't include a default 19:24:55 -1 to breaking changes 19:25:06 deprecating doesn't mean that we should break the API, I just mean that sanity tests will tell you "please specify type" if you don't specify it :) 19:25:27 I can live with that, but deprecation usually implies something that will be removed 19:25:39 so i see these options a) require all fields always b) require removal of any field that has default value c) just require fields are correct and match argspec 19:26:00 I would be fine omitting the requirement for `type='str'` from the docstring since it is the default. 19:26:00 +1 to don't include a default, one question, how does one specify multiple types? Or is that bad practice? 19:26:12 (this is more coding standards) 19:26:13 agowa338: raw 19:26:19 and yes, bad practice 19:26:26 It'd be nice if we displayed the type with `ansible-doc foo`, though. Not sure if we do (me may). 19:26:36 raw == argpsec will ignore validation and module should do it itself 19:26:37 That just saves typing. 19:26:37 I think we display it if present 19:26:42 I like having type always there. as opposed to having required and default always there. 19:26:47 sdoran: if its there, we display it 19:26:59 there's lots of name=str or name=list 19:26:59 we currently display "-" if no type is specified 19:27:08 If it's not there, we don't display the type? 19:27:32 we are missing 'insert default value' in many cases, we can add that, we didnt fix when default was 'raw' 19:27:54 Yeah, that's a minor thing we can change later. I would like it displayed, though. 19:27:55 so it made sense back then to not display type, but when we changed default to str, we should have changed display, but that is minor issue i can fix in a few mins 19:28:09 It's helpful info for authors. 19:28:11 sdoran: open issue and i'll probably get it done tmrow 19:28:11 Yup. 19:28:22 👍 19:28:41 need to fix ansible-doc and plugin_formatter.py 19:28:49 We'd still have to *have* a default to avoid making it a breaking change, but can add a sanity test that always requires it to be specified for stuff we ship 19:29:06 https://github.com/ansible/ansible/blob/devel/docs/bin/plugin_formatter.py#L155 19:29:12 nitzmahone: that is test we have now, why i brought up this issue since it contradicts other policies 19:29:37 bcoca: we don't really have that test now 19:29:44 I think 19:29:45 felixfontein: we do 19:29:56 i just hit it and was puzzled by it, hence this topic in meeting 19:30:00 ah 19:30:01 since we normally had policity the other way around 19:30:14 e.g required: false< = we have tests that forces you to remove this 19:30:32 @nitzmahone Do you mean a default type for the parameter if not specified in `argument_spec`? 19:30:33 i would actually remove both tests and let users document it even if its default 19:30:49 I'm pretty sure we do default to `str` in the code. 19:30:59 yes, i checked 19:31:03 Yeah, I guess we do, it's just ignored for a boatload of nonconformant existing modules. 19:31:05 it would make sense if default was still raw 19:31:10 but since wem oved to str ... 19:31:31 nitzmahone: yeah, would prefer not having a test that most existing modules violage 19:31:39 bcoca: when you leave type away in argspec, but specify 'str' in docs, the sanity check won't complain 19:31:41 bcoca: we already do 19:31:51 It's validate-modules rule E338 19:32:16 nitzmahone: i know, that is my point, specially since we have other tests that do the opposite 19:32:19 it will only complain (for type not in argspec) if you don't specify type in the docs, or when you have another type than str in the docs 19:32:39 felixfontein: it complains if type=str is missing in docs 19:32:49 bcoca: yes, but not if it is missing in argspec 19:33:19 that would not matter since it should still be same, that seems like a capricious rule 19:33:42 we allow required:false in spec, but not in docs ... which i also find puzzling 19:35:25 where do we prohibit (by a sanity check) that required:false is writtin in the docs? 19:35:36 I can't find that in https://github.com/ansible/ansible/blob/devel/test/sanity/validate-modules/main.py 19:38:00 dont tknow its there, i know we did big purges to follow that 'rule' 19:38:50 https://github.com/ansible/ansible/blob/devel/test/sanity/validate-modules/main.py#L1193-L1199 19:39:22 having default means no required:true, that is diff issue 19:39:24 bcoca: you approved the PR that added it ;) 19:39:51 ah, you're right, that's a different one 19:40:10 that is 'conflicting' data and we SHOULD validate and reject that 19:40:17 yep 19:40:28 vs 'redundant' data, which i really think we should not be policing 19:41:53 felixfontein: why do you want to force users to specify type (remove type=str as default) ? 19:41:59 s/user/authors/ 19:42:28 because I find that easier to read, when looking at an argspec 19:42:46 but knowing the defaults is simple, avoids a lot of extra work/data 19:42:58 why not force EVERY field in argspec then? not just type? 19:43:05 required, default, etc 19:43:14 IMO type is the most important value (next to name), so being able to see it without having to think is good IMO 19:43:37 because the others are not that important :) but yes, I see your point, and I'm somewhat torn... 19:43:43 if you are reviewing code and trying 'not to think' .. i dont think you should be reviewing code 19:44:05 it's more when quickly going back to find out what type something has 19:44:18 its not like default changes per module 19:45:21 I can also live without it being there, I'll just have to get used to that then ;) 19:46:11 about forcing every field to be there: that makes it hard to read 19:46:45 if that's the alternative to not having default values, I prefer not having default values 19:47:50 bcoca: so basically, you're proposing reverting https://github.com/ansible/ansible/pull/56534, right? 19:48:54 mostly 19:48:59 also the rule against required: false 19:49:04 and similar 19:49:19 i think our 'display' should take care of defaults, but if they are included in docs, its fine also 19:49:32 seems we are being overtly strict for no real gain 19:49:38 That one's already apparently not machine-enforced (though I thought it was) 19:50:20 I know dag was pretty vocally against the 56534 changes 19:50:55 well, im happy we dont enforce the others, but we can also just remove the rule (since we've had tons of PRs that just removed those fields) 19:51:15 ^ bcs tons, which are not metric, before you ask 19:52:04 ah, when I see my last comment in that PR: do we want to allow that if an option has aliases, that the documentation uses an alias instead of the "main" option name? 19:52:33 overly nitpicky again IMO 19:52:46 (if we didn't allow it I mean) 19:52:55 the main problem is that consistency for type etc. isn't checked in this case, I think 19:53:15 that would require validate-modules to handle aliases 19:53:17 i.e. if we really want to allow it, argspec validation does need to be adjusted 19:53:34 i would agree with nitzmahone, but until someone adds that code, it should actually complain 'undocumented option' 19:53:47 and 'documentd option not in argspec' 19:54:26 ^ though we use those on purpose in a couple of cases, e.g use= on service (since action plugin uses it but module does not) 19:55:27 nitzmahone: im not sure i want to remove the PR .. more like tweak it to ignore missing type as long as it matches argspec (including default) 19:55:30 I'm fine with allowing that, we should just make sure that the documentation uses the correct type etc. in this case 19:56:49 so we all more or less agree on making this less strict (match, but dont complain if extra/less info ?) 19:58:59 going to assume that is a yes, unless we want official vote? 19:59:34 Yes. I'm in favor of tweaking existing behavior to not be so strict. 19:59:51 so remove the check for 338, and adjust 337 so that it only fires if argspec type is not str? 19:59:54 And I opened an issue about having `ansible-doc` automatically display the type if not specified in the docs. 20:00:12 felixfontein: yep 20:00:45 well, 337 goes away and becomes 325 20:02:31 why not keep 337 and adjust it to only fire if argspec type is not str? 20:02:54 325 is explicit type conflict, where 337 is only "type isn't documented even though it is not default (str)" 20:03:31 k, i misread that, that is also a mismatch im ho 20:04:47 if we change docs generation to display "str" in this case, yes 20:05:00 basucakkt 335 us sane as 325 but due to default 20:05:11 felixfontein: done already 20:05:13 and its 'string' 20:06:03 yes, it displays 'string', but the source value is 'str' :) 20:06:21 explicit and implicit, both would work 20:06:38 + if text == 'str' or isinstance(text, Undefined): 20:06:40 + text = 'string' 20:06:58 yes 20:08:02 the validate-modules check is also not right, if type is not set in argspec but set in docs, it wont check mismatch 20:08:19 nitzmahone: how's work going on the return value deprecation? 20:08:48 felixfontein: its not return value, its 'variable deprecation' as we want to apply at many levels 20:09:02 ansible facts, some 'magic vars', etc 20:09:29 k, we can continue details in devel, for now im going to close meeting 20:09:30 bcoca: it does check mismatch: if type is not in argspec, it checks whether doctype is None (E338), str (fine), or anything else (E335) 20:09:39 #endmeeting