---
- hosts: spark-cluster
  remote_user: ubuntu
  sudo: yes
  tasks:
  - name: Add Java repository
    apt_repository: repo=ppa:webupd8team/java state=present
  - name: Automatically select the Oracle License
    shell: echo debconf shared/accepted-oracle-license-v1-1 select true | sudo debconf-set-selections
  - name: Install JRE
    apt: pkg=oracle-java6-installer state=latest update-cache=yes force=yes
  - name: Set Java environment variable
    shell: echo "JAVA_HOME=/usr/lib/jvm/java-6-oracle" >> /etc/environment
  - name: Install Scala
    apt: name=scala update_cache=yes
  - name: Set Scala environment variable
    shell: echo "SCALA_HOME=/usr/share/java" >> /etc/environment
  - name: Source environment variables
    shell: . /etc/environment
  - name: Install Spark
    shell: wget http://d3kbcqa49mib13.cloudfront.net/spark-1.3.1-bin-hadoop2.6.tgz
  - name: Unarchive Spark install package
    command: tar -xzvf spark-1.3.1-bin-hadoop2.6.tgz
  - name: Edit hosts file
    shell: echo "127.0.0.1 localhost $(hostname)" >> /etc/hosts
  - name: Add hosts file to each node
    shell: cat ~/hosts.txt >> /etc/hosts

---
- hosts: spark-cluster
  remote_user: ubuntu
  sudo: yes
  tasks:
  - name: Add Java repository
    apt_repository: repo=ppa:webupd8team/java state=present
  - name: Automatically select the Oracle License
    shell: echo debconf shared/accepted-oracle-license-v1-1 select true | sudo debconf-set-selections
  - name: Install JRE
    apt: pkg=oracle-java6-installer state=latest update-cache=yes force=yes
  - name: Set Java environment variable
    shell: echo "JAVA_HOME=/usr/lib/jvm/java-6-oracle" >> /etc/environment
  - name: Install Scala
    apt: name=scala update_cache=yes
  - name: Set Scala environment variable
    shell: echo "SCALA_HOME=/usr/share/java" >> /etc/environment
  - name: Source environment variables
    shell: . /etc/environment
  - name: Install Spark
    shell: wget http://d3kbcqa49mib13.cloudfront.net/spark-1.3.1-bin-hadoop2.6.tgz
  - name: Unarchive Spark install package
    command: tar -xzvf spark-1.3.1-bin-hadoop2.6.tgz
  - name: Edit hosts file
    shell: echo "127.0.0.1 localhost $(hostname)" >> /etc/hosts
  - name: Add hosts file to each node
    shell: cat /home/ubuntu/hosts.txt >> /etc/hosts

Change to full path for hosts.
Change to full path for hosts.
