Hi friends in Ansible
I would like to loop over a list roles. The following failing sample should explain what I try to acchieve:
- hosts: all
become: yes
become_method: sudo
remote_user: root
vars:
servers: - server1:
name: abadoc1
port: 9000 - server2:
name: abadoc2
port: 9100 - server3:
name: abadoc3
port: 9200
tasks:
loop: “{{ servers }}”
- include_role:
name: common - include_role:
name: dockercompose - include_role:
name: dockerinstallrepos - include_role:
name: logrotate
As you can see, there are a number of servers. For each one a set of roles should executed.
How can I do that? A sample or a link to a tutorial, would be much appreciated.
Thanks a lot for your help
Robert