--- - hosts: localhost connection: local vars_files: - vars/main.yml tasks: - name: Create a new spark master instance nova_compute: state: "{{ instance_state }}" name: spark-master image_id: 9bf957ba-a0ce-4513-ba8c-e80d42ea9faf key_name: "{{ key_name }}" wait_for: 200 flavor_id: 4 nics: - net-id: "{{ network_id }}" security_groups: spark,default meta: hostname: spark-master ansible_host_groups: spark_masters,default register: spark_master - name: Create a new spark slaves nova_compute: state: "{{ instance_state }}" name: "{{ item }}" image_id: 9bf957ba-a0ce-4513-ba8c-e80d42ea9faf key_name: "{{ key_name }}" wait_for: 200 flavor_id: 4 nics: - net-id: "{{ network_id }}" security_groups: spark,default meta: hostname: "{{ item }}" ansible_host_groups: spark_slaves,default register: spark_slaves with_sequence: start=0 end="{{ nbr_of_slaves }}" format=spark-slave%02x