@@ -19,32 +19,41 @@ 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'] }} :{{ influxdb['remote']['port'] }} /api/v2/orgs | jq -r '.orgs[0].id'" ) % }
23+
24+ test_{{ config[' name' ] }}:
25+ cmd.run:
26+ - name: echo {{ orgID }}
27+
2228get_bucket_{{ config[' name' ] }}:
2329 http.query:
24- - name: ' https://{{ influxdb[' remote' ][' host' ] }} /api/v2/buckets/{{ config[' name' ] }} '
30+ - name: ' https://{{ influxdb[' remote' ][' host' ] }} : {{ influxdb[ ' remote ' ][ ' port ' ] }} /api/v2/buckets/{{ config[' name' ] }} '
2531 - status: 200
2632 - method: GET
2733 - header_dict:
2834 Authorization: Token {{ influxdb[' user' ][' admin' ][' token' ] }}
2935
3036{%- 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' ]
37+ ' name' : config[' name' ],
38+ ' description' : config[' description' ] | default(' A bucket for ' + config[' name' ]),
39+ ' orgID' : orgID,
40+ ' rp' : config[' retention_policy' ] | default(' 0' ),
3641} % }
3742create_bucket_{{ config[' name' ] }}:
3843 http.query:
39- - name: ' https://{{ influxdb[' remote' ][' host' ] }} /api/v2/buckets'
44+ - name: ' https://{{ influxdb[' remote' ][' host' ] }} : {{ influxdb[ ' remote ' ][ ' port ' ] }} /api/v2/buckets'
4045 - status: 200
4146 - method: POST
4247 - data: ' {{ bucket_data | tojson }} '
4348 - header_dict:
4449 Authorization: Token {{ influxdb[' user' ][' admin' ][' token' ] }}
4550 - onfail:
4651 - http: get_bucket_{{ config[' name' ] }}
47- {%- set bucket = salt[' cmd.shell' ](" curl -s -f -H'Authorization: Token {{ influxdb['user']['admin']['token'] }} ' https://{{ influxdb['remote']['host'] }} /api/v2/buckets | jq -r '.[] | select(.name == \" " + config[' name' ] + " \" ).id'" ) % }
52+ {%- set bucket = salt[' cmd.shell' ](" curl -s -f -H'Authorization: Token {{ influxdb['user']['admin']['token'] }} ' https://{{ influxdb['remote']['host'] }} :{{ influxdb['remote']['port'] }} /api/v2/buckets | jq -r '.buckets[] | select(.name == \" " + config[' name' ] + " \" ).id'" ) % }
53+
54+ testb_{{ config[' name' ] }}:
55+ cmd.run:
56+ - name: echo {{ bucket }}
4857{% endif % }
4958
5059{%- if ' mapping' in config and bucket % }
0 commit comments