I'm having issues working out how to best apply hosts/roles to different operating systems in Ansible.
I'm currently using Ansible to generate Windows/Mac/Linux VMs, and each of the VMs have different roles which need to be applied to them.
I've read the best practices and have tried to follow them, especially to use the grouping method, but I'm still unsure as they mostly mention webservers and dbservers.
- name: Apply common configuration to all nodes hosts: all roles: - common - name: Configure and deploy test node 1 hosts: build-test-node roles: - build-machine-test-1 - name: Configure and deploy test node 2 hosts: build-test-node-2 roles: - build-machine-test-2
[win_build_nodes] win_build_machine_1 win_build_machine_2 [mac_build_nodes] mac_build_machine_1
win_build_machine_1 ansible_host=...... win_build_machine_2 ansible_host=...... mac_build_machine_1 ansible_host=......
[mac_build_nodes] [win_build_nodes] [win:children] win_build_nodes [mac:children] mac_build_nodes [linux:children] [build_nodes:children] win_build_nodes mac_build_nodes
environment/test/meta file I believe needs to be changed with the
build_nodes:children, but I'm not sure what to. Previously I was just having the VMs have all the roles built to it with the following:
- name: Apply everything hosts: build_nodes roles: - common - build-machine-test-1 - build-machine-test-2
But then realised I didn't want everything being built on the same machine. Note,
2 both have separate Windows/Mac/Linux builds as they detect what to include based on the operating system.
Can anyone suggest a better way of separating the VMs based on operating systems?