I'm automating my mac setup using ansible, having great success.  I just 
can't figure out how to move one particular task from my playbook (where it 
succeeds) to a role.  The task relies on a module (or possibly a role: it's 
not entirely clear to me from the context): yutannihilation.module-cran 
(see: https://github.com/yutannihilation/ansible-module-cran) and its job 
is to install two R packages from CRAN.  This is my (successful) playbook 
task:


```

- hosts: mac

  roles:

    - yutannihilation.module-cran

  environment:

    PATH: /opt/brew/bin:{{ ansible_env.PATH }}

  tasks:

    - name: Install R packages

      cran: name={{ item }} state=present

      with_items:

        - tuneR

        - seewav

```


where it works fine.  I've now created a role av_dev, and in 
roles/av_dev/tasks/main.yml I have tried all manner of things: this is the 
only form in which ansible doesn't error out, but unfortunately it also 
doesn't install the packages:


```

- name: Install AV dev R packages

  include_role:

    name: yutannihilation.module-cran

  vars:

    name: "{{ item }}"

    state: present

    environment:

      PATH: /opt/brew/bin:{{ ansible_env.PATH }}

  with_items:

    - tuneR

    - seewave

```


Note: it's only this task that doesn't work: I have created lots of roles, 
with lots of tasks, and this is the only task I can't get to work inside a 
role.  I assume (hope) that it is possible to call this module/role from 
within my role; if anyone can show me how to do it I'll be very grateful: 
and no doubt understand ansible a little better as a result.  Many thanks,


Note: this is cross-posted to stack overflow 
(https://stackoverflow.com/questions/67794835/how-to-move-this-ansible-task-to-install-r-packages-from-a-playbook-to-a-role)
 
but I realized this forum is much more appropriate!

Mike

-- 
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/170e72dd-8b37-41f2-989b-b3586f561ad5n%40googlegroups.com.

Reply via email to