---
- name: Check droplet status
  retries: 10
  delay: 20
  community.digitalocean.digital_ocean_droplet_info:
    oauth_token: "{{ DO_API_TOKEN }}"
    name: automated-builder-vps
  register: droplet_facts
  until: droplet_facts.data[0].status == "active"

- name: Wait for cloud-init / user-data to finish
  command: cloud-init status --wait
  changed_when: false

- name: Upgrade the OS (apt-get dist-upgrade)
  apt:
    upgrade: dist
  become: true

- name: Install apt packages
  become: true
  apt:
    pkg:
      - git
    update_cache: true

- name: Reboot the system
  reboot:
  become: true

- name: Wait for cloud-init / user-data to finish after reboot
  command: cloud-init status --wait
  changed_when: false
