Newer
Older
ansible_spark_openstack / create_spark_cloud_playbook.yml
Johan Dahlberg on 4 Mar 2015 1 KB Initial commit
---

- hosts: localhost
  connection: local
  vars:
    state: present # Set to absent to take down machines
    nbr_of_slaves: 3
    key_name: cloud_key
  tasks:
  - name: Create a new spark master instance 
    nova_compute:
      state: "{{ state }}"
      name: spark-master
      image_id: 9bf957ba-a0ce-4513-ba8c-e80d42ea9faf
      key_name: "{{ key_name }}"
      wait_for: 200
      flavor_id: 4
      nics:
        - net-id: b045a7de-5aa4-43a2-86ff-049fd1ba1884
      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: "{{ state }}"
      name: "{{ item }}"
      image_id: 9bf957ba-a0ce-4513-ba8c-e80d42ea9faf
      key_name: "{{ key_name }}"
      wait_for: 200
      flavor_id: 4
      nics:
        - net-id: b045a7de-5aa4-43a2-86ff-049fd1ba1884
      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