---
- hosts: dev.controller
  vars:
    host_ip: "{{ ansible_default_ipv4.address }}"
  tasks:
   - name: Record public IP
     shell: wget -qO- http://ipecho.net/plain ; echo
     register: public_ip

   - name: Install tools
     apt: name={{item}} state=latest
     sudo: yes
     with_items:
       - git
       - htop
       - vim

   - name: Checkout DevStack
     git: 
      repo: https://git.openstack.org/openstack-dev/devstack 
      dest: /home/ubuntu/devstack

   - name: Setup local.conf
     template: 
       src: local.conf.j2
       dest: /home/ubuntu/devstack/local.conf

   - name: UnStack (idempotency)
     shell: ./unstack.sh chdir=/home/ubuntu/devstack
     async: 120
     poll: 5
     ignore_errors: yes

   - name: Install DevStack (async)
     shell: ./stack.sh chdir=/home/ubuntu/devstack
     async: 900
     poll: 5

