check template for defaults
Opened this issue · 3 comments
I noticed when running this it did not report any defaults for my role however there are a number of defaults outside of the standard tasks folder
When you wrote "check templates for defaults" as the title, did you mean check the vars folder?
I might be off base but I see it like this:
defaults/main.yml
- Public variables that you expect people to overwrite (aka. defaults)vars/main.yml
- Private variables that you use in your tasks but don't want people messing with
Are you using default variables in a different way?
I have the defaults for standard options within the playbook but within templates I have options such as {{directory|default('/var/www')}}, the option of having them within the defaults/main file may be better however I noticed that a few roles that I have seen have used the same method as myself.
Ok, I fully understand what you mean now. I have witnessed that pattern before too. A lot of people put |default() in their template and if it's not overwritten in the user's inventory somewhere then it's undefined which means the default value in the template will be used.
I see 2 potential issues with scraping the templates directory.
The biggest issue is that right now the readme's defaults get taken as is from your defaults/main.yml
when you "rebuild" a role. It is expected that you comment the variables there so you have a single point of truth for both defining and documenting your default variables. If you have defaults set in the template then there's no way to really comment them in a sane way.
The other issue might be some ambiguity between what is expected as a default role value and what you defined locally in the template or what's being passed in from a task.
I do think your suggestion is worth exploring though. It should be able to detect template defaults but we need to come up with a reasonable way of generating documentation from it and removing any chance of ambiguity.