-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathverify.yml
More file actions
67 lines (61 loc) · 3.09 KB
/
Copy pathverify.yml
File metadata and controls
67 lines (61 loc) · 3.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
---
- name: Verify
hosts: all
become: true
gather_facts: false
tasks:
- name: Test influxdb authentication enabled
block:
- name: Test creating database without authentication credentials
command: >
curl -sPOST "http://localhost:8086/query" \
--data-urlencode 'q=CREATE DATABASE "test"'
register: auth_error_response
failed_when: '"unable to parse authentication credentials" not in auth_error_response.stdout'
changed_when: false
- name: Test creating database with authentication credentials
command: >
curl -sPOST "http://localhost:8086/query" \
--data-urlencode 'q=CREATE DATABASE "test"' \
-H 'Authorization: Token {{ influxdb_user_username }}:{{ influxdb_user_password }}'
register: db_created_response
failed_when: '"results" not in db_created_response.stdout'
changed_when: false
when: influxdb_user_password is defined and influxdb_user_password | bool
- name: Test influxdb authentication disabled
block:
- command: >
curl -sPOST "http://localhost:8086/query" \
--data-urlencode 'q=CREATE DATABASE "test"'
register: db_created_response
failed_when: '"results" not in db_created_response.stdout'
changed_when: false
when: influxdb_user_password is not defined or not influxdb_user_password | bool
- name: Test influxdb data directory configuration
block:
- name: Read InfluxDB configuration file
slurp:
src: /etc/influxdb/influxdb.conf
register: influxdb_config_content
- name: Test default data directory when variable not changed
block:
- name: Read InfluxDB configuration file
slurp:
src: /etc/influxdb/influxdb.conf
register: influxdb_config_content
- name: Verify default data directory is present
assert:
that:
- "'/var/lib/influxdb' in (influxdb_config_content.content | b64decode)"
fail_msg: "InfluxDB should use default /var/lib/influxdb when influxdb_data_dir is not defined or unchanged"
success_msg: "InfluxDB correctly using default data directory /var/lib/influxdb"
when: influxdb_data_dir is not defined or influxdb_data_dir == '/var/lib/influxdb'
- name: Verify data directory has been updated in configuration
assert:
that:
- influxdb_data_dir is defined
- "'/var/lib/influxdb' not in (influxdb_config_content.content | b64decode)"
- "influxdb_data_dir in (influxdb_config_content.content | b64decode)"
fail_msg: "InfluxDB configuration should use {{ influxdb_data_dir | default('/var/lib/influxdb') }} instead of default /var/lib/influxdb"
success_msg: "InfluxDB data directory correctly configured as {{ influxdb_data_dir | default('/var/lib/influxdb') }}"
when: influxdb_data_dir is defined and influxdb_data_dir != '/var/lib/influxdb'