---
- name: Ensure Rackconnect and Managed Cloud Automation is complete
  hosts: all
  connection: local
  tasks:
    - name: Wait for rackconnect automation to complete
      uri:
        url: "https://{{ rax_region }}.api.rackconnect.rackspace.com/v1/automation_status?format=json"
        return_content: yes
      register: automation_status
      until: automation_status['automation_status']|default('') == 'DEPLOYED'
      retries: 30
      delay: 10

    - name: Wait for managed cloud automation to complete
      wait_for:
        path: /tmp/rs_managed_cloud_automation_complete
        delay: 10

- name: Base Configure Servers
  hosts: all
  connection: local
  roles:
    - role: users

    - role: sivel.openssh
      opensshd_PermitRootLogin: "no"

    - role: bennojoy.ntp

---
- name: Ensure Rackconnect and Managed Cloud Automation is complete
  hosts: all
  connection: local
  tasks:
    - name: Check for completed bootstrap
      stat:
        path: /etc/bootstrap_complete
      register: bootstrap

    - name: Wait for rackconnect automation to complete
      uri:
        url: "https://{{ rax_region }}.api.rackconnect.rackspace.com/v1/automation_status?format=json"
        return_content: yes
      register: automation_status
      when: bootstrap.stat.exists != True
      until: automation_status['automation_status']|default('') == 'DEPLOYED'
      retries: 30
      delay: 10

    - name: Wait for managed cloud automation to complete
      wait_for:
        path: /tmp/rs_managed_cloud_automation_complete
        delay: 10
      when: bootstrap.stat.exists != True

    - name: Set bootstrap completed
      file:
        path: /etc/bootstrap_complete
        state: touch
        owner: root
        group: root
        mode: 0400

- name: Base Configure Servers
  hosts: all
  connection: local
  roles:
    - role: users

    - role: sivel.openssh
      opensshd_PermitRootLogin: "no"

    - role: bennojoy.ntp

Use a bootstrap file to indicate we've already waitted (successfully) for rackconnect and managed cloud automation
Use a bootstrap file to indicate we've already waitted (successfully) for rackconnect and managed cloud automation
