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

check template for defaults #1

Open
Trozz opened this issue Jul 22, 2014 · 3 comments
Open

check template for defaults #1

Trozz opened this issue Jul 22, 2014 · 3 comments

Comments

@Trozz
Copy link

Trozz commented Jul 22, 2014

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

@nickjj
Copy link
Owner

nickjj commented Jul 22, 2014

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?

@Trozz
Copy link
Author

Trozz commented Jul 22, 2014

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.

@nickjj
Copy link
Owner

nickjj commented Jul 22, 2014

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants