I highly disagree with this, and would be interested in a pointer to the documentation that you say claims "importing a role in the tasks of another role is a bad idea" since I've never seen that in the official Ansible documentation.
Explicitly importing or including the role provides more control over execution order, and ansible-galaxy can still handle dependency install by listing them in meta/requirements.yml (https://docs.ansible.com/ansible/latest/galaxy/user_guide.html#using-meta-requirements-yml) On Saturday, June 18, 2022 at 11:33:55 AM UTC-4 [email protected] wrote: > Hi John, > > Per ansible doc, you should not import a role within another role. > Instead, you should use the built in dependencies model. Importing a role > in the tasks of another role is a bad idea because it reduces the > portability of the role. You'd have to guarantee that the role you're using > and the role you import are both present in your roles dir. The dependency > model ansible provides solves this problem by leveraging the ansible galaxy > command to pull dependencies from remote repositories. > > Paul > > Sent from my T-Mobile 5G Device > Get Outlook for Android <https://aka.ms/AAb9ysg> > > ------------------------------ > *From:* [email protected] <[email protected]> on > behalf of John Petro <[email protected]> > *Sent:* Friday, June 17, 2022, 3:26 PM > *To:* [email protected] <[email protected]> > *Subject:* [ansible-project] nested roles > > I have a question regarding nested roles. > > Back Story: I am doing some code reviews for some ansible code a coworker > has done. I noticed that they are importing other roles into the role they > are working on. > > Question: I feel like this is not a good idea, that dependencies should > be taken care of at the playbook level, but I am having a difficult time > justifying why nesting roles is not necessarily a good idea, so I am > looking for some feedback to help me here. I welcome your thoughts on > this... > > --John > > -- > You received this message because you are subscribed to the Google Groups > "Ansible Project" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/ansible-project/CAPAjob8sDH_4Sz23MFPTsBiB0wzmokOKmyJdfkGdsPY6nTZchQ%40mail.gmail.com > > <https://groups.google.com/d/msgid/ansible-project/CAPAjob8sDH_4Sz23MFPTsBiB0wzmokOKmyJdfkGdsPY6nTZchQ%40mail.gmail.com?utm_medium=email&utm_source=footer> > . > > -- You received this message because you are subscribed to the Google Groups "Ansible Project" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/7d730b37-122d-44c8-b198-b3a0589984bdn%40googlegroups.com.
