2

I have created about 30 roles in ansible. Do i have to manually convert those in single playbooks to use them in Ansible Tower?

techraf
  • 4,163
  • 8
  • 27
  • 44
Alexander
  • 23
  • 1
  • 3

3 Answers3

5

Yes, you may use roles in Tower. We do something like the following, grouping related roles into a playbook (playbook.yml in this example) then calling that from a Tower job.

playbook.yml

---
- name: Example playbook
  hosts: '{{ target }}'
  roles:
    - { role: init }
    - { role: deploy }
    - { role: cleanup }

Directory tree

roles/
  init/
    ...
    tasks/
      main.yml
    ...
  deploy/
    ...
    tasks/
      main.yml
    ...
  cleanup/
    ...
    tasks/
      main.yml
  ...

Then from the Tower job, you can either supply {{ target }} or use a survey to prompt the user.

jscott
  • 24,204
  • 8
  • 77
  • 99
1

You can move all the roles to roles folder and you can call them from yml file so that they can be executed from ansible tower.

Below is the example file which worked for me.

---
- name: Give your name
    roles:
       - { role: role1 }
       - { role: role2 }

Note: create a folder with name roles where you are creating this yml file and move all roles to this folder. See Directory Layout in the Ansible docs for more information.

Andrew Schulman
  • 8,561
  • 21
  • 31
  • 47
1

You can leverage tower + galaxy to download the roles automagically. Just create a requirements.yml file in your playbook projects.

http://docs.ansible.com/ansible-tower/2.4.1/html/userguide/projects.html#ansible-galaxy-support

chrism
  • 111
  • 2