#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements.  See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License.  You may obtain a copy of the License at
#
#    http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

- name: "add datasources"
  uri:
    url: "http://admin:admin@{{ groups['metrics'][0] }}:3000/api/datasources"
    method: POST
    body: "{{ item }}"
    body_format: json
    status_code: 200,500,409
  register: uresult
  retries: 3
  until: "uresult.status == 500 or uresult.status == 200 or uresult.status == 409"
  with_items:
    - '{"name":"cluster_metrics", "type":"influxdb", "url":"http://{{ groups["metrics"][0] }}:8086", "access":"server", "isDefault":true, "database":"cluster_metrics", "user":"fluo", "password":"secret"}'
    - '{"name":"fluo_metrics", "type":"influxdb", "url":"http://{{ groups["metrics"][0] }}:8086", "access":"server", "isDefault":true, "database":"fluo_metrics", "user":"fluo", "password":"secret"}'
    - '{"name":"accumulo_metrics", "type":"influxdb", "url":"http://{{ groups["metrics"][0] }}:8086", "access":"server", "isDefault":true, "database":"accumulo_metrics", "user":"accumulo", "password":"secret"}'
