title: Including sub-roles in ansible playbook?
body: <p>I have a ansible role that requires other roles, but is not loading correctly from my playbook. My role is here, <a href="https://github.com/ehime/ansible-role-jenkins" rel="nofollow noreferrer">Jenkins Role</a>, it has dependencies on two other geerlingguy roles, which are listed here</p>
  
  <p><code>meta/main.yml</code></p>
  
  <pre><code>galaxy_info:
    author: Jd Daniel
    description: Jenkins installer
    company: GE Health
  
    min_ansible_version: 2.2
    role_name: jenkins
  
    license: GPLv3
  
    platforms:
      - name: EL
        versions:
          - 7
  
    galaxy_tags:
      - jenkins
      - deployment
      - continuous-deployment
      - cd
  
    dependencies:
      - { role: geerlingguy.repo-epel }
      - { role: geerlingguy.jenkins, jenkins_plugins: [] }
  </code></pre>
  
  <p>My roles <code>ansible.cfg</code> in this role also points to the <code>roles/</code> directory</p>
  
  <pre><code>[defaults]
  # without this, the connection to a new instance is interactive
  host_key_checking = False
  roles_path        = roles/
  </code></pre>
  
  <p>and the roles are downloaded into the <code>roles/</code> folder</p>
  
  <pre><code>┌─[10:25:24]─[ehime@GC02WW38KHTD6E]─[~/Repositories/Infra/Ansible/ansible-role-jenkins]
  └──&gt; tree -L 2
  .
  ├── [ehime  34K]  LICENSE
  ├── [ehime 1.3K]  README.md
  ├── [ehime  128]  ansible.cfg
  ├── [ehime   96]  defaults
  │   └── [ehime   32]  main.yml
  ├── [ehime   96]  files
  │   └── [ehime  633]  job.xml
  ├── [ehime   96]  handlers
  │   └── [ehime   33]  main.yml
  ├── [ehime   96]  meta
  │   └── [ehime  417]  main.yml
  ├── [ehime  160]  roles
  │   ├── [ehime  384]  geerlingguy.java
  │   ├── [ehime  416]  geerlingguy.jenkins
  │   └── [ehime  320]  geerlingguy.repo-epel
  ├── [ehime   96]  tasks
  │   └── [ehime  737]  main.yml
  ├── [ehime  352]  tests
  │   ├── [ehime  669]  README.md
  │   ├── [ehime  276]  Vagrantfile
  │   ├── [ehime  121]  ansible.cfg
  │   ├── [ehime  203]  inventory
  │   ├── [ehime  221]  requirements.yml
  │   ├── [ehime   96]  roles
  │   ├── [ehime   10]  test_7_default.retry
  │   └── [ehime  182]  test_7_default.yml
  └── [ehime   96]  vars
      └── [ehime   91]  main.yml
  </code></pre>
  
  <p>My tasks should be pulling these in then? right?</p>
  
  <p><code>tasks/main.yml</code></p>
  
  <pre><code>---
  - name: Install required roles
    include_role:
      name: "{{ roles }}"
    vars:
      roles:
        - geerlingguy.epel-repo
        - geerlingguy.jenkins
  
  .... other tasks ....
  </code></pre>
  
  <p>When running my playbook though...</p>
  
  <p><code>jenkins.yml</code></p>
  
  <pre><code>#
  # Ansible to provision Jenkins on remote host
  #
  - name: Install Jenkins and its plugins
    hosts: all
  
    become: yes
    become_method: sudo
    gather_facts: yes
  
    vars:
      jenkins_hostname: localhost
      jenkins_http_port: 8080
  
    roles:
      - ehime.jenkins
  
    pre_tasks:
    - name: CA-Certificates update command line execution
      command: /bin/update-ca-trust
  
    tasks:
      - name: Set up pipeline
        jenkins_job:
          config: "{{ lookup('file', 'files/job.xml') }}"
          name: test-auto
          user: "{{ jenkins_admin_username }}"
          password: "{{ jenkins_admin_password }}"
  </code></pre>
  
  <p>When trying to run the following playbook though</p>
  
  <pre><code>#
  # Ansible to provision Jenkins on remote host
  #
  - name: Install Jenkins and its plugins
    hosts: all
  
    become: yes
    become_method: sudo
    gather_facts: yes
  
    vars:
      jenkins_hostname: localhost
      jenkins_http_port: 8080
  
    roles:
      - ehime.jenkins
  
    pre_tasks:
    - name: CA-Certificates update command line execution
      command: /bin/update-ca-trust
  
    tasks:
      - name: Set up pipeline
        jenkins_job:
          config: "{{ lookup('file', 'files/job.xml') }}"
          name: test-auto
          user: "{{ jenkins_admin_username }}"
          password: "{{ jenkins_admin_password }}"
  </code></pre>
  
  <p>With my playbooks config...</p>
  
  <p><code>ansible.cfg</code></p>
  
  <pre><code>[defaults]
  # without this, the connection to a new instance is interactive
  host_key_checking = False
  roles_path        = roles/
  remote_user       = ec2-user
  private_key_file  = ../_keys/test-jenkins
  </code></pre>
  
  <p>I get the following error....</p>
  
  <p><code>error</code></p>
  
  <pre><code>TASK [include_role : {{ roles }}] ************************************************************************************************************************************************************************************************************
  ERROR! Invalid role definition: [u'geerlingguy.epel-repo', u'geerlingguy.jenkins']
  </code></pre>
  
  <p>It's evidently NOT seeing the roles in <code>roles/ehime.jenkins/roles</code> but I'm not sure how to get those working. It also seem like it ignores my <code>meta/main.yml</code> for a galaxy install? Should these be in the <code>requirements.yml</code>?</p>