@@ -19,32 +19,38 @@ 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+ {%- set data = salt[' cmd.shell' ](" curl -v -s -f -H'Authorization: Token {{ influxdb['user']['admin']['token'] }} ' https://{{ influxdb['remote']['host'] }} :{{ influxdb['remote']['port'] }} /api/v2/orgs &> /tmp/test_{{ config['name'] }} .txt" ) % }
24+
2225get_bucket_{{ config[' name' ] }}:
2326 http.query:
24- - name: ' https://{{ influxdb[' remote' ][' host' ] }} /api/v2/buckets/{{ config[' name' ] }} '
27+ - name: ' https://{{ influxdb[' remote' ][' host' ] }} : {{ influxdb[ ' remote ' ][ ' port ' ] }} /api/v2/buckets/{{ config[' name' ] }} '
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} % }
3739create_bucket_{{ config[' name' ] }}:
3840 http.query:
39- - name: ' https://{{ influxdb[' remote' ][' host' ] }} /api/v2/buckets'
41+ - name: ' https://{{ influxdb[' remote' ][' host' ] }} : {{ influxdb[ ' remote ' ][ ' port ' ] }} /api/v2/buckets'
4042 - status: 200
4143 - method: POST
4244 - data: ' {{ bucket_data | tojson }} '
4345 - header_dict:
4446 Authorization: Token {{ influxdb[' user' ][' admin' ][' token' ] }}
4547 - onfail:
4648 - 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'" ) % }
49+ {%- 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'" ) % }
50+
51+ testb_{{ config[' name' ] }}_{{ bucket }}:
52+ cmd.run:
53+ - name: echo {{ bucket }}
4854{% endif % }
4955
5056{%- if ' mapping' in config and bucket % }
0 commit comments