---
- name: Set hostname
  hostname: 
      name={{ hostname }}

- name: Tell /etc/hosts about the hostname
  lineinfile:
    dest=/etc/hosts
    line="127.0.0.1 localhost {{hostname}}"
    state=present
    insertbefore=BOF

- name: Install prerequisite packages
  apt:
      pkg={{ item }}
      state=present
  with_items:
      - python
      - python-pip
      - python-dev
      - python-setuptools
      - stunnel
      - git

- name: install Buildbot
  easy_install:
      name: "{{ item }}"
  with_items:
      - buildbot==0.8.12
      - boto

- name: Create buildbot user
  user:
      name: "rustbuild"
      home: "/home/rustbuild"
      shell: /bin/bash
      createhome: yes

- name: Clone the Buildbot configs
  git:
      repo='https://github.com/rust-lang/rust-buildbot.git'
      dest='/home/rustbuild/rust-buildbot'
      accept_hostkey=yes
  become: yes
  become_user: rustbuild

- name: Start Buildbot
  command: buildbot start master
  args:
      chdir: /home/rustbuild/rust-buildbot
  become: yes
  become_user: rustbuild 

---
- name: Set hostname
  hostname:
      name={{ hostname }}

- name: Tell /etc/hosts about the hostname
  lineinfile:
    dest=/etc/hosts
    line="127.0.0.1 localhost {{hostname}}"
    state=present
    insertbefore=BOF

- name: Install prerequisite packages
  apt:
      pkg={{ item }}
      state=present
  with_items:
      - python
      - python-pip
      - python-dev
      - python-setuptools
      - python-virtualenv
      - stunnel
      - git

- name: Clone the Buildbot configs
  git:
      repo='https://github.com/rust-lang/rust-buildbot.git'
      dest='/home/rustbuild/rust-buildbot'
      accept_hostkey=yes
  become: yes
  become_user: rustbuild

- name: Create virtualenv and install packages 
  pip:
    virtualenv=/home/rustbuild/buildmaster-venv
    name="{{ item }}"
  with_items: 
    - buildbot==0.8.12
    - boto

- name: Create buildbot user
  user:
      name: "rustbuild"
      home: "/home/rustbuild"
      shell: /bin/bash
      createhome: yes

- name: Start Buildbot
  command: /home/rustbuild/buildmaster-venv/bin/buildbot start master
  args:
      chdir: /home/rustbuild/rust-buildbot
  become: yes
  become_user: rustbuild

Install Buildbot to a virtualenv
Install Buildbot to a virtualenv
