GithubHelp home page GithubHelp logo

Comments (9)

psych0d0g avatar psych0d0g commented on July 23, 2024 1

From reading the docs https://docs.ansible.com/ansible/latest/galaxy/user_guide.html#dependencies both methods meta/main.yml and meta/requirements.yml should work exactly the same. Where can I find information about the different behavior?

thats not correct, if you check a few paragraphs below (https://docs.ansible.com/ansible/latest/galaxy/user_guide.html#using-meta-main-yml), it states:

Dependencies installed that way, depending on other factors described below, will also be executed **before** this role is executed during play execution

whereas if you define dependency in meta/requirements.yml they are not executed automatically, just installed, so that they can be executed at a controlled point in the role.

the main difference here i think is meta/main.yml dependencies are an ansible-core feature:
https://docs.ansible.com/ansible/latest/playbook_guide/playbooks_reuse_roles.html#using-role-dependencies

whereas the meta/requirements.yml is "just" instructions for ansible-galaxy to make sure those dependencies listed there are installed if the role is pulled in through a playbooks requirements.yml via ansible-galaxy.
and galaxy happens to also understand the ansible-core meta/main.yml dependencies to make sure those roles are installed aswell.

the differing part is probably that the requirements.yml is only parsed by galaxy and ansible itself has no idea about it or its contents

from ansible-doctor.

xoxys avatar xoxys commented on July 23, 2024

I'm a bit confused by what exactly you try to achieve.

i would try to create a custom template to get requirement roles documented in the readme.md aswell

ansible-doctor does not parse any requirements.yml file, It's intended to be used for roles or collections. According to the docs, both don't include requirements.yml files. To link and document dependencies of roles you can add it to the meta file as described in the ansible roles docs. Dependencies from the meta file will be detected and documented automatically.

another question revolves around dictionary variables, and how to properly get doctor to detect them and document them.
currently its just this

Not sure if I understand this question. The type of an Ansible variable doesn't matter for ansible-doctor. It will detect the variable, document the default and all additional information added by annotations. It's not possible to add annotations or additional information to the keys of a dict variable. But you could add an example annotation:

# @var apache2_listen_ports:example: >
# apache2_listen_ports:
#   # Description of the http key
#   http: 80
#   # Description of the https key
#   https: 443
# @end

The result looks like this:

image

from ansible-doctor.

psych0d0g avatar psych0d0g commented on July 23, 2024

thank you for the answer, ansible-galaxy is picking up requirements.yml defined requirements from roles automatically and installs them aswell when you place a requirement.yml into the meta directory, its diffrent from dependencies since they are not rolled out automatically with that aproach, but can be delegated to within your roles flow of tasks with ansible.builtin.include_role:.
that way you have more control over the roles and their execution.
for example i have an apache and a php role, the apache role has a variable that en- or disables the apache2_mod_php component, and also delegates further php setup to the php role if enabled, from within the apache role like so:

- name: ensure php is setup and installed as needed
  ansible.builtin.include_role:
    name: php
  vars:
    php_implementation:
      apache: true
      cli: false
      fpm: false

for that to work i either need to put both roles into the requirements.yml of my playbooks, or, and that is what i am doing, put the php role into the requirements.yml of my apache role, and only tell my playbook it needs apache

from ansible-doctor.

psych0d0g avatar psych0d0g commented on July 23, 2024

for the variable section, i would love if it would be possible to have doctor resolve nested / sublayers of dictionary variables.
basically instead of detecting apache2_listen_ports as the only var in that block maybe detect something like apache2_listen_ports.http and apache2_listen_ports.https in this case

from ansible-doctor.

xoxys avatar xoxys commented on July 23, 2024

From reading the docs https://docs.ansible.com/ansible/latest/galaxy/user_guide.html#dependencies both methods meta/main.yml and meta/requirements.yml should work exactly the same. Where can I find information about the different behavior?

from ansible-doctor.

xoxys avatar xoxys commented on July 23, 2024

for the variable section, i would love if it would be possible to have doctor resolve nested / sublayers of dictionary variables.

Sorry, this is IMO a bit out of scope.

from ansible-doctor.

xoxys avatar xoxys commented on July 23, 2024

Thanks for the details, I think I understand your use case. Would you like to contribute the meta/requirements.yml parsing feature?

from ansible-doctor.

psych0d0g avatar psych0d0g commented on July 23, 2024

i am open to looking into contributing that feature, just gonna need some time to slice off my general schedules to poke around ;)
ill get back to you in the next 1-2 weeks i think :)

from ansible-doctor.

xoxys avatar xoxys commented on July 23, 2024

No worries 🙂 if you have any question just let me know.

from ansible-doctor.

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.