The only way you can invoke a role from within a role is via meta/main.yml
<http://docs.ansible.com/ansible/playbooks_roles.html#role-dependencies> You
may not explicitly invoke a role within a role like you do tasks.
On Tuesday, December 29, 2015 at 3:12:03 AM UTC-6, Colin Byrne wrote:
>
> Hey, Thanks for the reply... This is already in a role though, so would
> calling a role from a role make sense or even work?
> Thanks, C
>
> On Tuesday, December 29, 2015 at 1:03:50 AM UTC-8, Borys Borysenko wrote:
>>
>> Hello Colin,
>>
>> The most simple way I guess is just to split your playbook with
>> pre_tasks, roles and tasks sections. Something similar to:
>>
>> ---
>> - hosts: all
>> vars: []
>> pre_tasks:
>> - name: create group titled deploy
>> group: name=deploy state=present
>> - name: update apt-cache
>> sudo: yes
>> apt: update_cache=yes
>> - name: create deploy user
>> user: name=deploy group=deploy groups=sudo comment="Deployment User"
>> home="/home/deploy" shell="/bin/bash"
>> roles:
>> - external-rbenv-role
>> tasks:
>> - name: Install the kitchen sink
>> action: apt name={{item}} state=present update_cache=true
>> sudo: yes
>> with_items:
>> - libqtwebkit-dev
>> - node
>> - lots of other tasks
>> post_tasks: []
>>
>> Regards,
>> Borys
>>
>> вторник, 29 декабря 2015 г., 2:08:37 UTC+2 пользователь Colin Byrne
>> написал:
>>>
>>> So I used to have one fairly long main.yml playbook that was used to
>>> perform a number of similar-tasks, one of which was to install rbenv, the
>>> ruby management tool.
>>>
>>> ---
>>>
>>> - name: create group titled deploy
>>>
>>> group: name=deploy state=present
>>>
>>> - name: update apt-cache
>>>
>>> sudo: yes
>>>
>>> apt: update_cache=yes
>>>
>>> - name: create deploy user
>>>
>>> user: name=deploy group=deploy groups=sudo comment="Deployment User"
>>> home="/home/deploy" shell="/bin/bash"
>>>
>>> - name: download rbenv
>>>
>>> ...
>>>
>>> - name: install rbenv
>>>
>>> ...
>>>
>>> - name: configure rbenv
>>>
>>> ...
>>>
>>> - name: Install the kitchen sink
>>>
>>> action: apt name={{item}} state=present update_cache=true
>>>
>>> sudo: yes
>>>
>>> with_items:
>>>
>>> - libqtwebkit-dev
>>>
>>> - node
>>> - lots of other tasks
>>> ...
>>>
>>> I found a nice galaxy role that better suits my needs for installing
>>> rbenv, and I now want to include it to run in the same order as previously,
>>> but I am confused as to how the documentation recommends to do this and the
>>> syntax (seemingly with dependencies or includes?). It is hard to decipher
>>> wether I will have to split it into three roles (the pre-rbenv, rbenv,
>>> post-rbenv) which would really seem inconvenient as the three would always
>>> be used together. I suspect this is a pretty common dilemma...
>>>
>>> Thank you all for the help so far, this forum has really made is a
>>> pleasure learning ansible.
>>>
>>
--
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 post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/41628689-166b-4ae2-b6b8-2168d1b24b94%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.