---

- name: Push influxdb config, with auth disable, for admin setup
  template:
    src: influxdb.admin.conf.j2
    dest: /etc/influxdb/influxdb.conf
  notify: reload influxdb
  register: conf

- name: Reload influxdb, with auth disable, for admin setup
  service:
    name: influxdb
    state: restarted
  when: conf.changed

- name: Ensure Influx is up
  uri:
    url: http://localhost:{{ influx_port }}
    status: 204
  retries: 3
  delay: 2
  ignore_errors: true

- name: Ensure admin user
  influxdb_user:
    user_name: "{{ admin_name }}"
    user_password: "{{ admin_pass }}"
    admin: yes

- name: Leave a trace of admin setup
  file:
    path: /etc/influxdb/admin
    state: touch