Git Product home page Git Product logo

Comments (3)

nickjj avatar nickjj commented on August 15, 2024

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?

from ansigenome.

Trozz avatar Trozz commented on August 15, 2024

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.

from ansigenome.

nickjj avatar nickjj commented on August 15, 2024

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.

from ansigenome.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.