---
# Provision the droplet with:
# - Docker Engine
# - Riak CS (object store)
# - Docker Registry
- hosts: newdroplets
  user: root
  sudo: yes
  vars_files:
    - vars.yml
  roles:
    - common
    - docker_host
    - consul
    - docksul
    - riak_cs
    - docker_reg

---
# Provision the droplet with roles:
# - Docker Engine
# - Consul (service discovery and routing)
# - Riak CS (object store)
# - Docker Registry

# Provision with do_admin user, unless is_first_run is defined, then with root.
# Reboot after first run.
- hosts: newdroplets
  user: "{{ do_admin if is_first_run is not defined else 'root' }}"
  sudo: yes
  vars_files:
    - vars.yml
  roles:
    - common
    - docker_host
    - consul
    - docksu\
    - riak_cs
    - docker_reg

  tasks:
    - name: reboot host
      command: /bin/systemctl reboot --no-block
      async: 0
      poll: 0
      ignore_errors: true
      when: is_first_run is defined

    - name: wait for host to come back
      local_action: >
        wait_for
        host={{ inventory_hostname }}
        port=22
        state=started
      sudo: false
      when: is_first_run is defined

Use root if first run, and reboot
Use root if first run, and reboot
