---
- include: install.yml
  tags: [influxdb, install]

- include: configure.yml
  tags: [influxdb, configure]

- name: Start the InfluxDB service
  service:
    name: influxdb
    state: restarted
    enabled: yes
  register: influxdb_started
  when: influxdb_start_service

- name: Pause to ensure InfluxDB service is up
  pause:
    seconds: 5
  when: influxdb_started.changed and influxdb_start_service
  
- name: Collect service status
  command: service influxdb status
  register: influxdb_service_status
  when: influxdb_start_service
  ignore_errors: yes

- name: Assert status of InfluxDB service
  assert:
    that:
      - "influxdb_service_status.rc == 0"
  when: influxdb_start_service
  
- include: demo.yml
  tags: [influxdb, demo]
  when: influxdb_load_sample_data and influxdb_http_auth_enabled == "false" and influxdb_start_service

- include: verify.yml
  tags: [influxdb, verify]

- include: stress.yml
  tags: [influxdb, stress]

---
- include: install.yml
  tags: [influxdb, install]

- include: configure.yml
  tags: [influxdb, configure]

- name: Start the InfluxDB service
  service:
    name: influxdb
    state: restarted
    enabled: yes
  register: influxdb_started
  when: influxdb_start_service

- name: Pause to ensure InfluxDB service is up
  wait_for:
    host: "{{ influxdb_bind_hostname }}"
    port: "{{ influxdb_http_port }}"
    delay: 5
    timeout: 30
  when: influxdb_started.changed and influxdb_start_service
  
- include: demo.yml
  tags: [influxdb, demo]
  when: influxdb_load_sample_data and influxdb_http_auth_enabled == "false" and influxdb_start_service

- include: verify.yml
  tags: [influxdb, verify]

- include: stress.yml
  tags: [influxdb, stress]

Swap service check for wait for port.
Swap service check for wait for port.
