Skip to content

Commit d3b64ac

Browse files
committed
fix: bucket config
1 parent 6ff082f commit d3b64ac

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

influxdb/buckets.sls

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,24 +19,27 @@ influxdb_bucket_{{ config['name'] }}:
1919
- pkg: jq
2020
{%- set bucket = salt['cmd.shell']("influx bucket list --json | jq -r '.[] | select(.name == \"" + config['name'] + "\").id'") %}
2121
{% else %}
22+
{%- set orgID = salt['cmd.shell']("curl -s -f -H'Authorization: Token {{ influxdb['user']['admin']['token'] }}' https://{{ influxdb['remote']['host'] }}/api/v2/orgs | jq -r '.[0].id'") %}
23+
2224
get_bucket_{{ config['name'] }}:
2325
http.query:
2426
- name: 'https://{{ influxdb['remote']['host'] }}/api/v2/buckets/{{ config['name'] }}'
27+
- port: 8086
2528
- status: 200
2629
- method: GET
2730
- header_dict:
2831
Authorization: Token {{ influxdb['user']['admin']['token'] }}
2932
3033
{%- set bucket_data = {
31-
name: config['name'],
32-
description: config['description'] | default('A bucket for ' + config['name']),
33-
orgID: config['orgID'],
34-
retentionRules: [],
35-
rp: config['retention_policy']
34+
'name': config['name'],
35+
'description': config['description'] | default('A bucket for ' + config['name']),
36+
'orgID': orgID,
37+
'rp': config['retention_policy'] | default('0'),
3638
} %}
3739
create_bucket_{{ config['name'] }}:
3840
http.query:
3941
- name: 'https://{{ influxdb['remote']['host'] }}/api/v2/buckets'
42+
- port: 8086
4043
- status: 200
4144
- method: POST
4245
- data: '{{ bucket_data | tojson }}'

influxdb/users.sls

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ influxdb_user_{{ loop.index0 }}:
2121
get_user_{{ loop.index0 }}:
2222
http.query:
2323
- name: 'https://{{ influxdb['remote']['host'] }}/api/v2/users/{{ name }}'
24+
- port: 8086
2425
- status: 200
2526
- method: GET
2627
- header_dict:
@@ -29,6 +30,7 @@ get_user_{{ loop.index0 }}:
2930
create_user_{{ loop.index0 }}:
3031
http.query:
3132
- name: 'https://{{ influxdb['remote']['host'] }}/api/v2/users'
33+
- port: 8086
3234
- status: 200
3335
- method: POST
3436
- data: '{"name": "{{ name }}"}'
@@ -41,6 +43,7 @@ create_user_{{ loop.index0 }}:
4143
set_password_{{ loop.index0 }}:
4244
http.query:
4345
- name: 'https://{{ influxdb['remote']['host'] }}/api/v2/users{{ name }}/password'
46+
- port: 8086
4447
- status: 200
4548
- method: POST
4649
- data: '{"password": "{{ config["password"] }}"}'

0 commit comments

Comments
 (0)