I have created about 30 roles in ansible. Do i have to manually convert those in single playbooks to use them in Ansible Tower?
3 Answers
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.
- 24,204
- 8
- 77
- 99
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.
- 8,561
- 21
- 31
- 47
- 111
- 3
-
You can have the structure created automatically: `ansible-galaxy init role1` – jscott May 29 '15 at 11:10
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
- 111
- 2