├── tests ├── .gitignore ├── tmp │ └── .gitignore ├── pre_tasks │ ├── disable_systemd.yml │ ├── influxdata.yml │ └── apt_keys │ │ └── influxdata.pgp ├── 0200_config.goss.yml ├── 0000_default.goss.yml ├── 0000_default.yml └── 0200_config.yml ├── .gitignore ├── filter_plugins ├── .gitignore └── manala_toml.py ├── .manala └── make │ ├── gmsl │ ├── __gmsl │ └── gmsl │ ├── Makefile.host │ ├── Makefile.travis │ ├── Makefile.docker │ ├── Makefile │ └── Makefile.manala ├── templates └── config │ ├── empty.conf.j2 │ ├── _macros.j2 │ ├── influxdata │ └── influxdb.conf.j2 │ └── _default.j2 ├── tasks ├── databases.yml ├── install.yml ├── privileges.yml ├── users.yml ├── services.yml ├── dir.yml ├── config.yml └── main.yml ├── Makefile ├── handlers └── main.yml ├── .travis.yml ├── meta └── main.yml ├── defaults └── main.yml ├── CHANGELOG.md └── README.md /tests/.gitignore: -------------------------------------------------------------------------------- 1 | *.retry 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /.cache/ 2 | .env 3 | -------------------------------------------------------------------------------- /filter_plugins/.gitignore: -------------------------------------------------------------------------------- 1 | *.pyc 2 | -------------------------------------------------------------------------------- /tests/tmp/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /.manala/make/gmsl/__gmsl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/manala/ansible-role-influxdb/HEAD/.manala/make/gmsl/__gmsl -------------------------------------------------------------------------------- /templates/config/empty.conf.j2: -------------------------------------------------------------------------------- 1 | {#- Deprecated -#} 2 | 3 | {%- import '_macros.j2' as macros with context -%} 4 | 5 | {{ macros.config(manala_influxdb_config) }} 6 | -------------------------------------------------------------------------------- /tasks/databases.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | - name: databases > Create Influx databases 4 | command: "{{ manala_influxdb_influx_bin }} -execute 'CREATE DATABASE \"{{ item }}\"'" 5 | with_items: "{{ manala_influxdb_databases }}" 6 | changed_when: false 7 | -------------------------------------------------------------------------------- /tests/pre_tasks/disable_systemd.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | - name: Pre tasks > Disable systemctl to force sysv init script 4 | command: mv /bin/systemctl /bin/systemctl.disabled 5 | args: 6 | creates: /bin/systemctl.disabled 7 | removes: /bin/systemctl 8 | -------------------------------------------------------------------------------- /tasks/install.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | - name: install > Packages 4 | apt: 5 | name: "{{ manala_influxdb_install_packages|default(manala_influxdb_install_packages_default, True) }}" 6 | install_recommends: false 7 | update_cache: true 8 | cache_valid_time: 3600 9 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | .SILENT: 2 | 3 | ########## 4 | # Manala # 5 | ########## 6 | 7 | include .manala/make/Makefile 8 | 9 | ######## 10 | # Role # 11 | ######## 12 | 13 | ROLE = manala.influxdb 14 | ROLE_DISTRIBUTIONS = debian.jessie debian.stretch debian.buster 15 | -------------------------------------------------------------------------------- /tasks/privileges.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | - name: privileges > Setup Influx privileges 4 | command: "{{ manala_influxdb_influx_bin }} -execute 'GRANT {{ item.grant }} ON \"{{ item.database }}\" TO \"{{ item.user }}\"'" 5 | with_items: "{{ manala_influxdb_privileges }}" 6 | changed_when: false 7 | -------------------------------------------------------------------------------- /tasks/users.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | - name: users > Create Influx users 4 | command: "{{ manala_influxdb_influx_bin }} -database '{{ item.database }}' -execute \"CREATE USER {{ item.name }} WITH PASSWORD '{{ item.password }}'\"" 5 | with_items: "{{ manala_influxdb_users }}" 6 | changed_when: false 7 | -------------------------------------------------------------------------------- /tasks/services.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | - name: services > Services 4 | service: 5 | name: "{{ item }}" 6 | state: started 7 | with_items: 8 | - influxdb 9 | register: _manala_influxdb_services_output 10 | until: _manala_influxdb_services_output is not failed 11 | retries: 12 12 | delay: 1 13 | -------------------------------------------------------------------------------- /tasks/dir.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | - name: dir > Create directory 4 | file: 5 | path: "{{ item }}" 6 | state: directory 7 | owner: "{{ manala_influxdb_dir_user }}" 8 | group: "{{ manala_influxdb_dir_group }}" 9 | mode: "{{ manala_influxdb_dir_mode }}" 10 | with_items: "{{ manala_influxdb_dir }}" 11 | -------------------------------------------------------------------------------- /tests/pre_tasks/influxdata.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | - name: Pre tasks > Influxdata apt key 4 | apt_key: 5 | file: pre_tasks/apt_keys/influxdata.pgp 6 | id: 2582E0C5 7 | 8 | - name: Pre tasks > Influxdata apt repository 9 | apt_repository: 10 | repo: deb https://repos.influxdata.com/debian {{ ansible_distribution_release }} stable 11 | -------------------------------------------------------------------------------- /handlers/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | - name: influxdb restart 4 | service: 5 | name: influxdb 6 | state: stopped 7 | notify: influxdb start 8 | 9 | - name: influxdb start 10 | service: 11 | name: influxdb 12 | state: started 13 | register: _manala_influxdb_services_output 14 | until: _manala_influxdb_services_output is not failed 15 | retries: 12 16 | delay: 1 17 | -------------------------------------------------------------------------------- /tasks/config.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | - name: config > Template 4 | template: 5 | src: "{{ manala_influxdb_config_template|default('config/_default.j2', true) }}" 6 | dest: "{{ manala_influxdb_config_file }}" 7 | owner: root 8 | group: root 9 | mode: "0644" 10 | when: manala_influxdb_config_template 11 | or manala_influxdb_config 12 | notify: 13 | - influxdb restart 14 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: generic 2 | 3 | branches: 4 | only: 5 | - master 6 | 7 | services: 8 | - docker 9 | 10 | script: 11 | - gem install chandler -v 0.9.0 12 | - chandler push `perl -lne '/^## \[(?!Unreleased)([\w.-]+)\] - [\w-]+$/ && print $1;' CHANGELOG.md | head -1` 13 | 14 | notifications: 15 | webhooks: 16 | urls: 17 | - https://galaxy.ansible.com/api/v1/notifications/ 18 | -------------------------------------------------------------------------------- /meta/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | dependencies: [] 4 | 5 | galaxy_info: 6 | 7 | role_name: influxdb 8 | author: Manala 9 | company: Manala 10 | description: Install and configure InfluxDB 11 | license: MIT 12 | min_ansible_version: 2.4.0 13 | issue_tracker_url: https://github.com/manala/ansible-roles/issues 14 | platforms: 15 | - name: Debian 16 | versions: 17 | - jessie 18 | - stretch 19 | - buster 20 | galaxy_tags: 21 | - database 22 | - influxdb 23 | -------------------------------------------------------------------------------- /defaults/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | # Install 4 | manala_influxdb_install_packages: ~ 5 | manala_influxdb_install_packages_default: 6 | - influxdb 7 | 8 | # Dir 9 | manala_influxdb_dir: [] 10 | manala_influxdb_dir_user: influxdb 11 | manala_influxdb_dir_group: influxdb 12 | manala_influxdb_dir_mode: "0750" 13 | 14 | # Databases 15 | manala_influxdb_databases: [] 16 | 17 | # Users 18 | manala_influxdb_users: [] 19 | 20 | # Privileges 21 | manala_influxdb_privileges: [] 22 | 23 | # Bin 24 | manala_influxdb_influx_bin: /usr/bin/influx 25 | 26 | # Config 27 | manala_influxdb_config_file: /etc/influxdb/influxdb.conf 28 | manala_influxdb_config_template: ~ 29 | manala_influxdb_config: ~ 30 | -------------------------------------------------------------------------------- /.manala/make/Makefile.host: -------------------------------------------------------------------------------- 1 | ######## 2 | # Host # 3 | ######## 4 | 5 | MANALA_HOST ?= local 6 | 7 | # Usage: 8 | # target: .fail_if_host_not(local) 9 | # # Do something on local host... 10 | 11 | .fail_if_host_not(%): 12 | $(call fail_if_host_not,$(*)) 13 | 14 | define fail_if_host_not 15 | $(call if_eq,$(1),$(MANALA_HOST),,$(call message_error,Must be run on \"$(1)\" host); exit 1) 16 | endef 17 | 18 | # Usage: 19 | # $(call if_host,local,Yes,No) = Yes 20 | 21 | define if_host 22 | $(call if_eq,$(1),$(MANALA_HOST),$(2),$(3)) 23 | endef 24 | 25 | .host_switch(%): 26 | $(call host_switch,$(*)) 27 | 28 | # Usage: 29 | # $(call host_switch,target) => make target@[host] 30 | 31 | define host_switch 32 | $(MAKE) $(1)@$(MANALA_HOST) 33 | endef 34 | -------------------------------------------------------------------------------- /tests/0200_config.goss.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | file: 4 | tmp/config/default/default.conf: 5 | exists: true 6 | filetype: file 7 | owner: root 8 | group: root 9 | mode: "0644" 10 | contains: 11 | - reporting-disabled = true 12 | tmp/config/default/default_deprecated.conf: 13 | exists: true 14 | filetype: file 15 | owner: root 16 | group: root 17 | mode: "0644" 18 | contains: 19 | - reporting-disabled = true 20 | tmp/config/default/default_content.conf: 21 | exists: true 22 | filetype: file 23 | owner: root 24 | group: root 25 | mode: "0644" 26 | contains: 27 | - reporting-disabled = true 28 | tmp/config/default/template.conf: 29 | exists: true 30 | filetype: file 31 | owner: root 32 | group: root 33 | mode: "0644" 34 | contains: 35 | - reporting-disabled = true 36 | -------------------------------------------------------------------------------- /tasks/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | # Install 4 | - import_tasks: install.yml 5 | tags: 6 | - manala_influxdb 7 | - manala_influxdb.install 8 | 9 | # Dir 10 | - import_tasks: dir.yml 11 | tags: 12 | - manala_influxdb 13 | - manala_influxdb.dir 14 | 15 | # Config 16 | - import_tasks: config.yml 17 | tags: 18 | - manala_influxdb 19 | - manala_influxdb.config 20 | 21 | # Services 22 | - import_tasks: services.yml 23 | tags: 24 | - manala_influxdb 25 | - manala_influxdb.services 26 | - manala.services 27 | 28 | # Databases 29 | - import_tasks: databases.yml 30 | tags: 31 | - manala_influxdb 32 | - manala_influxdb.databases 33 | 34 | # Users 35 | - import_tasks: users.yml 36 | tags: 37 | - manala_influxdb 38 | - manala_influxdb.users 39 | 40 | # Privileges 41 | - import_tasks: privileges.yml 42 | tags: 43 | - manala_influxdb 44 | - manala_influxdb.privileges 45 | -------------------------------------------------------------------------------- /.manala/make/Makefile.travis: -------------------------------------------------------------------------------- 1 | ############### 2 | # List - Loop # 3 | ############### 4 | 5 | MANALA_LIST_LOOP_HOOK_START_TRAVIS_FOLD = $(if $(TRAVIS), \ 6 | MANALA_TRAVIS_FOLD=`echo $${MANALA_LIST_LOOP_ITEM} | sed -E 's/[^-_A-Za-z0-9]+/./g'` ; \ 7 | printf "travis_fold:start:$${MANALA_TRAVIS_FOLD}\n" ; \ 8 | MANALA_TRAVIS_TIME_ID=$(call rand) ; \ 9 | MANALA_TRAVIS_TIME_START=$(call date_nano) ; \ 10 | printf "travis_time:start:$${MANALA_TRAVIS_TIME_ID}\n" ; \ 11 | ) 12 | 13 | MANALA_LIST_LOOP_HOOK_END_TRAVIS_FOLD = $(if $(TRAVIS), \ 14 | MANALA_TRAVIS_TIME_FINISH=$(call date_nano) ; \ 15 | printf "travis_time:end:$${MANALA_TRAVIS_TIME_ID}:start=$${MANALA_TRAVIS_TIME_START}$(,)finish=$${MANALA_TRAVIS_TIME_FINISH}$(,)duration=$$(($${MANALA_TRAVIS_TIME_FINISH}-$${MANALA_TRAVIS_TIME_START}))\n" ; \ 16 | if [ $${MANALA_LIST_LOOP_ITEM_EXIT} -eq 0 ]; then \ 17 | printf "travis_fold:end:$${MANALA_TRAVIS_FOLD}\n" ; \ 18 | fi ; \ 19 | ) 20 | -------------------------------------------------------------------------------- /tests/0000_default.goss.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | package: 4 | influxdb: 5 | installed: true 6 | 7 | service: 8 | influxdb: 9 | enabled: true 10 | running: true 11 | 12 | file: 13 | /srv/db/influxdb/data: 14 | exists: true 15 | filetype: directory 16 | owner: influxdb 17 | group: influxdb 18 | mode: "0750" 19 | /srv/db/influxdb/meta: 20 | exists: true 21 | filetype: directory 22 | owner: influxdb 23 | group: influxdb 24 | mode: "0750" 25 | /srv/db/influxdb/wal: 26 | exists: true 27 | filetype: directory 28 | owner: influxdb 29 | group: influxdb 30 | mode: "0750" 31 | 32 | command: 33 | influx -execute 'show databases': 34 | exit-status: 0 35 | stdout: 36 | - my_db 37 | influx -execute 'show users': 38 | exit-status: 0 39 | stdout: 40 | - my_user 41 | influx -database my_db -execute 'show grants for my_user': 42 | exit-status: 0 43 | stdout: 44 | - my_db ALL PRIVILEGES 45 | -------------------------------------------------------------------------------- /tests/0000_default.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | - name: "{{ test }}" 4 | hosts: debian 5 | become: true 6 | tasks: 7 | 8 | - block: 9 | - import_tasks: pre_tasks/disable_systemd.yml 10 | when: ansible_distribution_release in ['jessie'] 11 | - import_tasks: pre_tasks/influxdata.yml 12 | 13 | - block: 14 | - import_role: 15 | name: manala.influxdb 16 | vars: 17 | manala_influxdb_dir: 18 | - /srv/db/influxdb/meta 19 | - /srv/db/influxdb/data 20 | - /srv/db/influxdb/wal 21 | manala_influxdb_databases: 22 | - my_db 23 | manala_influxdb_users: 24 | - database: my_db 25 | name: my_user 26 | password: my_password 27 | manala_influxdb_privileges: 28 | - database: my_db 29 | user: my_user 30 | grant: ALL 31 | always: 32 | - name: Goss 33 | command: > 34 | goss --gossfile {{ test }}.goss.yml validate 35 | -------------------------------------------------------------------------------- /.manala/make/Makefile.docker: -------------------------------------------------------------------------------- 1 | ############# 2 | # Functions # 3 | ############# 4 | 5 | define docker_run 6 | docker run \ 7 | --rm \ 8 | $(if $(MANALA_DOCKER_MOUNT_DIR), \ 9 | --volume $(MANALA_CURRENT_DIR):$(MANALA_DOCKER_MOUNT_DIR) \ 10 | --workdir $(MANALA_DOCKER_MOUNT_DIR) \ 11 | ) \ 12 | $(if $(MANALA_INTERACTIVE),--tty --interactive) \ 13 | $(if $(MANALA_DOCKER_HOST),--hostname $(MANALA_DOCKER_HOST)) \ 14 | $(if $(MANALA_DOCKER_VOLUMES), \ 15 | $(foreach \ 16 | VOLUME,\ 17 | $(MANALA_DOCKER_VOLUMES),\ 18 | --volume $(VOLUME) \ 19 | ) \ 20 | ) \ 21 | $(if $(MANALA_DOCKER_ENV), \ 22 | $(foreach \ 23 | ENV,\ 24 | $(call encode_spaces,$(MANALA_DOCKER_ENV)),\ 25 | --env $(call decode_spaces,$(ENV)) \ 26 | ) \ 27 | ) \ 28 | $(MANALA_DOCKER_OPTIONS) \ 29 | $(MANALA_DOCKER_RUN_OPTIONS) \ 30 | $(MANALA_DOCKER_IMAGE):$(if $(MANALA_DOCKER_IMAGE_TAG),$(MANALA_DOCKER_IMAGE_TAG),latest) \ 31 | $(1) 32 | endef 33 | 34 | define docker_shell 35 | $(call docker_run) 36 | endef 37 | 38 | define docker_make 39 | $(call docker_run,sh -c "make --silent --directory=$(MANALA_DOCKER_MOUNT_DIR) $(1)") 40 | endef 41 | 42 | define docker_pull 43 | docker pull \ 44 | $(MANALA_DOCKER_OPTIONS) \ 45 | $(MANALA_DOCKER_PULL_OPTIONS) \ 46 | $(MANALA_DOCKER_IMAGE):$(if $(MANALA_DOCKER_IMAGE_TAG),$(MANALA_DOCKER_IMAGE_TAG),latest) 47 | endef 48 | 49 | define docker_build 50 | docker build \ 51 | $(MANALA_DOCKER_OPTIONS) \ 52 | $(MANALA_DOCKER_BUILD_OPTIONS) \ 53 | --tag $(MANALA_DOCKER_IMAGE):$(if $(MANALA_DOCKER_IMAGE_TAG),$(MANALA_DOCKER_IMAGE_TAG),latest) 54 | endef 55 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | All notable changes to this project will be documented in this file. 3 | 4 | The format is based on [Keep a Changelog](http://keepachangelog.com/) 5 | and this project adheres to [Semantic Versioning](http://semver.org/). 6 | 7 | ## [Unreleased] 8 | 9 | ## [2.0.3] - 2021-01-11 10 | ### Added 11 | - Dict based config filters 12 | 13 | # Changed 14 | - Deprecate dict's array configs 15 | 16 | ## [2.0.2] - 2020-08-28 17 | ### Changed 18 | - Explicit file permissions 19 | 20 | ## [2.0.1] - 2020-02-13 21 | ### Added 22 | - Tags for each tasks, with the format `manala_rolename.taskname` 23 | 24 | ## [2.0.0] - 2019-11-21 25 | ### Removed 26 | - Debian wheezy support 27 | 28 | ## [1.0.10] - 2019-10-24 29 | ### Added 30 | - Debian buster support 31 | 32 | ## [1.0.9] - 2019-07-16 33 | ### Changed 34 | - Update config template for 1.7.6 35 | 36 | ### Added 37 | - Handle directory change 38 | 39 | ## [1.0.8] - 2019-03-19 40 | ### Changed 41 | - Update config template for 1.7.4 42 | 43 | ## [1.0.7] - 2019-01-14 44 | ### Changed 45 | - Update config template for 1.7.3 46 | 47 | ## [1.0.6] - 2018-11-19 48 | ### Changed 49 | - Update config template for 1.7.1 50 | 51 | ## [1.0.5] - 2018-10-17 52 | ### Fixed 53 | - Python 3 compatibility 54 | 55 | ## [1.0.4] - 2018-08-14 56 | ### Changed 57 | - Update config template for 1.6.1 58 | 59 | ## [1.0.3] - 2018-06-05 60 | ### Added 61 | - Handle dependency packages to install 62 | 63 | ### Changed 64 | - Replace deprecated uses of "include" 65 | - Pass apt module packages list directly to the `name` option 66 | 67 | ## [1.0.2] - 2018-03-12 68 | ### Changed 69 | - Update config template for 1.5.0 70 | 71 | ## [1.0.1] - 2017-12-06 72 | ### Added 73 | - Debian stretch support 74 | 75 | ## [1.0.0] - 2017-05-22 76 | ### Added 77 | - Install and configure influxdb v1.2.4 78 | -------------------------------------------------------------------------------- /tests/0200_config.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | - name: "{{ test }}" 4 | hosts: debian 5 | become: true 6 | tasks: 7 | 8 | - block: 9 | - import_tasks: pre_tasks/disable_systemd.yml 10 | when: ansible_distribution_release in ['jessie'] 11 | - import_tasks: pre_tasks/influxdata.yml 12 | 13 | - block: 14 | - file: 15 | path: tmp/config/default 16 | state: "{{ item }}" 17 | loop: [absent, directory] 18 | # Default 19 | - import_role: 20 | # Play role fully on first run, so that handlers don't breaks 21 | name: manala.influxdb 22 | vars: 23 | manala_influxdb_config_file: tmp/config/default/default.conf 24 | manala_influxdb_config: 25 | reporting-disabled: true 26 | # Default - Deprecated 27 | - import_role: 28 | name: manala.influxdb 29 | tasks_from: config 30 | vars: 31 | manala_influxdb_config_file: tmp/config/default/default_deprecated.conf 32 | manala_influxdb_config: 33 | - reporting-disabled: true 34 | # Default - Content 35 | - import_role: 36 | name: manala.influxdb 37 | tasks_from: config 38 | vars: 39 | manala_influxdb_config_file: tmp/config/default/default_content.conf 40 | manala_influxdb_config: | 41 | reporting-disabled = true 42 | # Template 43 | - import_role: 44 | name: manala.influxdb 45 | tasks_from: config 46 | vars: 47 | manala_influxdb_config_file: tmp/config/default/template.conf 48 | manala_influxdb_config_template: config/influxdata/influxdb.conf.j2 49 | manala_influxdb_config: 50 | reporting-disabled: true 51 | always: 52 | - name: Goss 53 | command: > 54 | goss --gossfile {{ test }}.goss.yml validate 55 | -------------------------------------------------------------------------------- /templates/config/_macros.j2: -------------------------------------------------------------------------------- 1 | {#- Deprecated -#} 2 | 3 | {%- macro config(parameters, exclusions = [], indent = 0) -%} 4 | {%- for parameter in parameters -%} 5 | {%- if parameter is string or parameter is number -%} 6 | {{ parameter }}{{ '\n' }} 7 | {%- elif parameter is mapping -%} 8 | {%- for parameter_key, parameter_value in parameter.items() -%} 9 | {%- if parameter_key not in exclusions -%} 10 | {{ _config_parameter(parameter_key, parameter_value, indent) }}{{ '\n' }} 11 | {%- endif -%} 12 | {%- endfor -%} 13 | {%- endif -%} 14 | {%- endfor -%} 15 | {%- endmacro -%} 16 | 17 | {%- macro config_row(parameters, key, default, indent = 0, placeholder = false) -%} 18 | {%- set vars = {'values': []} -%} 19 | {%- for parameter in parameters -%} 20 | {%- if parameter is mapping -%} 21 | {%- for parameter_key, parameter_value in parameter.items() -%} 22 | {%- if parameter_key == key -%} 23 | {%- if vars.update({'values': vars['values'] + [parameter_value]}) -%}{%- endif -%} 24 | {%- endif -%} 25 | {%- endfor -%} 26 | {%- endif -%} 27 | {%- endfor -%} 28 | {%- if vars['values']|length -%} 29 | {%- for value in vars['values'] -%} 30 | {{ _config_parameter(key, value, indent) }}{% if not loop.last %}{{ '\n' }}{% endif %} 31 | {%- endfor -%} 32 | {%- else -%} 33 | {%- if placeholder -%} 34 | {{ default }} 35 | {%- else -%} 36 | {%- for value in (default if (default is sequence and default is not string) else [default]) -%} 37 | {{ _config_parameter(key, value, indent) }}{% if not loop.last %}{{ '\n' }}{% endif %} 38 | {%- endfor -%} 39 | {%- endif -%} 40 | {%- endif -%} 41 | {%- endmacro -%} 42 | 43 | {%- macro _config_parameter(key, value, indent = 0) -%} 44 | {{ _config_parameter_key(key)|indent(indent, true) }} = {{ _config_parameter_value(value) }} 45 | {%- endmacro -%} 46 | 47 | {%- macro _config_parameter_key(key) -%} 48 | {{ key }} 49 | {%- endmacro -%} 50 | 51 | {%- macro _config_parameter_value(value) -%} 52 | {%- if value is sameas none -%} 53 | {%- elif value is sameas true -%} 54 | true 55 | {%- elif value is sameas false -%} 56 | false 57 | {%- elif value is string -%} 58 | "{{ value }}" 59 | {%- elif value is number -%} 60 | {{ value }} 61 | {%- endif -%} 62 | {%- endmacro -%} 63 | -------------------------------------------------------------------------------- /tests/pre_tasks/apt_keys/influxdata.pgp: -------------------------------------------------------------------------------- 1 | -----BEGIN PGP PUBLIC KEY BLOCK----- 2 | Version: GnuPG v1 3 | 4 | mQINBFYJmwQBEADCw7mob8Vzk+DmkYyiv0dTU/xgoSlp4SQwrTzat8MB8jxmx60l 5 | QjmhqEyuB8ho4zzZF9KV+gJWrG6Rj4t69JMTJWM7jFz+0B1PC7kJfNM+VcBmkTnj 6 | fP+KJjqz50ETnsF0kQTG++UJeRYjG1dDK0JQNQJAM6NQpIWJI339lcDf15vzrMnb 7 | OgIlNxV6j1ZZqkle4fvScF1NQxYScRiL+sRgVx92SI4SyD/xZnVGD/szB+4OCzah 8 | +0Q/MnNGV6TtN0RiCDZjIUYiHoeT9iQXEONKf7T62T4zUafO734HyqGvht93MLVU 9 | GQAeuyx0ikGsULfOsJfBmb3XJS9u+16v7oPFt5WIbeyyNuhUu0ocK/PKt5sPYR4u 10 | ouPq6Ls3RY3BGCH9DpokcYsdalo51NMrMdnYwdkeq9MEpsEKrKIN5ke7fk4weamJ 11 | BiLI/bTcfM7Fy5r4ghdI9Ksw/ULXLm4GNabkIOSfT7UjTzcBDOvWfKRBLX4qvsx4 12 | YzA5kR+nX85u6I7W10aSqBiaLqk6vCj0QmBmCjlSeYqNQqSzH/6OoL6FZ7lP6AiG 13 | F2NyGveJKjugoXlreLEhOYp20F81PNwlRBCAlMC2Q9mpcFu0dtAriVoG4gVDdYn5 14 | t+BiGfD2rJlCinYLgYBDpTPcdRT3VKHWqL9fcC4HKmic0mwWg9homx550wARAQAB 15 | tDFJbmZsdXhEQiBQYWNrYWdpbmcgU2VydmljZSA8c3VwcG9ydEBpbmZsdXhkYi5j 16 | b20+iQI3BBMBCgAhBQJWCZsEAhsDBQsJCAcDBRUKCQgLBRYDAgEAAh4BAheAAAoJ 17 | EGhKFM8lguDF9XEQAK9rREnZt6ujh7GXfeNki35bkn39q8GYh0mouShFbFY9o0i3 18 | UJVChsxokJSRPgFh9GOhOPTupl3rzfdpD+IlWI2Myt6han2HOjZKNZ4RGNrYJ5UR 19 | uxt4dKMWlMbpkzL56bhHlx97RoXKv2d2zRQfw9nyZb6t3lw2k2kKXsMxjGa0agM+ 20 | 2SropwYOXdtkz8UWaGd3LYxwEvW3AuhI8EEEHdLetQaYe9sANDvUEofgFbdsuICH 21 | 9QLmbYavk7wyGTPBKfPBbeyTxwW2rMUnFCNccMKLm1i5NpZYineBtQbX2cfx9Xsk 22 | 1JLOzEBmNal53H2ob0kjev6ufzOD3s8hLu4KMCivbIz4YT3fZyeExn0/0lUtsQ56 23 | 5fCxE983+ygDzKsCnfdXqm3GgjaI90OkNr1y4gWbcd5hicVDv5fD3TD9f0GbpDVw 24 | yDz8YmvNzxMILt5Glisr6aH7gLG/u8jxy0D8YcBiyv5kfY4vMI2yXHpGg1cn/sVu 25 | ZB01sU09VVIM2BznnimyAayI430wquxkZCyMx//BqFM1qetIgk1wDZTlFd0n6qtA 26 | fDmXAC4s5pM5rfM5V57WmPaIqnRIaESJ35tFUFlCHfkfl/N/ribGVDg1z2KDW08r 27 | 96oEiIIiV4GfXl+NprJqpNS3Cn+aCXtd7/TsDScDEgs4sMaR29Lsf26cuWk8uQIN 28 | BFYJmwQBEADDPi3fmwn6iwkiDcH2E2V31cHlBw9OdJfxKVUdyAQEhTtqmG9P8XFZ 29 | ERRQF155XLQPLvRlUlq7vEYSROn5J6BAnsjdjsH9LmFMOEV8CIRCRIDePG/Mez2d 30 | nIK5yiU6GkS3IFaQg2T9/tOBKxm0ZJPfqTXbT4jFSfvYJ3oUqc+AyYxtb8gj1GRk 31 | X283/86/bA3C98u7re1vPtiDRyM8r0+lhEc59Yx/EAOL+X2gZyTgyUoH+LLuOWQK 32 | s1egI8y80R8NZfM1nMiQk2ywMsTFwQjSVimScvzqv5Nt8k8CvHUQ3a6R+6doXGNX 33 | 5RnUqn9Qvmh0JY5sNgFsoaGbuk2PJrVaGBRnfnjaDqAlZpDhwkWhcCcguNhRbRHp 34 | N7/a0pQr70bAG9VikzLyGC17EU0sxney/hyNHkr4Uyy2OXHpuJvRjVKy/BwZ3fxA 35 | AYX2oZIOxQB3/OulzO/DppaCVhRtp1bt+Z5f+fpisiVb5DvZcMdeyAoQ4+oOr7v3 36 | EasIs2XYcQ+kOE3Y2kdlHWBeuXzxgWgJZ1OOpwGMjR3Uy6IwhuSWtreJBA4er+Df 37 | vgSPwKBsRLNLbPe3ftjArnC5GfMiGgikVdAUdN4OkEqvUbkRoAVGKTOMLUKm+ZkG 38 | OskJOVYS+JAina0qkYEFF7haycMjf9olhqLmTIC+6X7Ox9R2plaOhQARAQABiQIf 39 | BBgBCgAJBQJWCZsEAhsMAAoJEGhKFM8lguDF8ZIP/1q9Sdz8oMvf9AJXZ7AYxm77 40 | V+kJzJqi62nZLWJnrFXDZJpU+LkYlb3fstsZ1rvBhnrEPSmFxoj72CP0RtcyX7wJ 41 | dA7K1Fl9LpJi5H8300cC7UyG94MUYbrXijbLTbnFTfNr1tGx4a1T/7Yyxx/wZGrT 42 | H/X8cvNybkl33SxDdlQQ9kx3lFOwC41e3TkGsUWxn3TCfvDh8VdA6Py6JeSPFGOb 43 | MEO2/q7oUgvjfV+ivN5ayZi9bWgeqm1sgtmTHHQ4RqwwKrAb5ynXpn1b9QrkevgT 44 | b91uzMA22Prl4DuzKiaMYDcZOQ3vtf0eFBP0GOSSgUKS4bQ3dGgi1JmQ7VuAM4uj 45 | +Ug5TnGoLwclTwLksc7v89C5MMPgm2vVXvCUDzyzQA7bIHFeX+Rziby4nymec4Nr 46 | eeXYNBJWrEp8XR7UNWmEgroXRoN1x9/6esh5pnoUXGAIWuKzSLQM70/wWxS67+v2 47 | aC1GNb+pXXAzYeIIiyLWaZwCSr8sWMvshFT9REk2+lnb6sAeJswQtfTUWI00mVqZ 48 | dvI3Wys2h0IyIejuwetTUvGhr9VgpqiLLfGzGlt/y2sg27wdHzSJbMh0VrVAK26/ 49 | BlvEwWDCFT0ZJUMG9Lvre25DD0ycbougLsRYjzmGb/3k3UktS3XTCxyBa/k3TPw3 50 | vqIHrEqk446nGPDqJPS5 51 | =9iF7 52 | -----END PGP PUBLIC KEY BLOCK----- 53 | -------------------------------------------------------------------------------- /.manala/make/gmsl/gmsl: -------------------------------------------------------------------------------- 1 | # ---------------------------------------------------------------------------- 2 | # 3 | # GNU Make Standard Library (GMSL) 4 | # 5 | # A library of functions to be used with GNU Make's $(call) that 6 | # provides functionality not available in standard GNU Make. 7 | # 8 | # Copyright (c) 2005-2014 John Graham-Cumming 9 | # 10 | # This file is part of GMSL 11 | # 12 | # Redistribution and use in source and binary forms, with or without 13 | # modification, are permitted provided that the following conditions 14 | # are met: 15 | # 16 | # Redistributions of source code must retain the above copyright 17 | # notice, this list of conditions and the following disclaimer. 18 | # 19 | # Redistributions in binary form must reproduce the above copyright 20 | # notice, this list of conditions and the following disclaimer in the 21 | # documentation and/or other materials provided with the distribution. 22 | # 23 | # Neither the name of the John Graham-Cumming nor the names of its 24 | # contributors may be used to endorse or promote products derived from 25 | # this software without specific prior written permission. 26 | # 27 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 28 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 29 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 30 | # FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 31 | # COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 32 | # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 33 | # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 34 | # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 35 | # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 36 | # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 37 | # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 38 | # POSSIBILITY OF SUCH DAMAGE. 39 | # 40 | # ---------------------------------------------------------------------------- 41 | 42 | # Determine if the library has already been included and if so don't 43 | # bother including it again 44 | 45 | ifndef __gmsl_included 46 | 47 | # Standard definitions for true and false. true is any non-empty 48 | # string, false is an empty string. These are intended for use with 49 | # $(if). 50 | 51 | true := T 52 | false := 53 | 54 | # ---------------------------------------------------------------------------- 55 | # Function: not 56 | # Arguments: 1: A boolean value 57 | # Returns: Returns the opposite of the arg. (true -> false, false -> true) 58 | # ---------------------------------------------------------------------------- 59 | not = $(if $1,$(false),$(true)) 60 | 61 | # Prevent reinclusion of the library 62 | 63 | __gmsl_included := $(true) 64 | 65 | # Try to determine where this file is located. If the caller did 66 | # include /foo/gmsl then extract the /foo/ so that __gmsl gets 67 | # included transparently 68 | 69 | __gmsl_root := 70 | 71 | ifneq ($(MAKEFILE_LIST),) 72 | __gmsl_root := $(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST)) 73 | 74 | # If there are any spaces in the path in __gmsl_root then give up 75 | 76 | ifeq (1,$(words $(__gmsl_root))) 77 | __gmsl_root := $(patsubst %gmsl,%,$(__gmsl_root)) 78 | endif 79 | 80 | endif 81 | 82 | include $(__gmsl_root)__gmsl 83 | 84 | endif # __gmsl_included 85 | 86 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Ansible Role : InfluxDB [![Build Status](https://travis-ci.org/manala/ansible-role-influxdb.svg?branch=master)](https://travis-ci.org/manala/ansible-role-influxdb) 2 | 3 | :exclamation: [Report issues](https://github.com/manala/ansible-roles/issues) and [send Pull Requests](https://github.com/manala/ansible-roles/pulls) in the [main Ansible Role repository](https://github.com/manala/ansible-roles) :exclamation: 4 | 5 | This role will assume the setup of [InfluxDB](https://www.influxdata.com/time-series-platform/influxdb/). 6 | 7 | It's part of the [Manala Ansible stack](http://www.manala.io) but can be used as a stand alone component. 8 | 9 | ## Requirements 10 | 11 | This role is made to work with the __influxdata__ influxDB debian packages. Please use the [**manala.apt**](https://galaxy.ansible.com/manala/apt/) role to handle it properly. 12 | 13 | ```yaml 14 | manala_apt_preferences: 15 | - influxdb@influxdata 16 | ``` 17 | 18 | ## Dependencies 19 | 20 | None. 21 | 22 | ## Supported InfluxDB versions 23 | 24 | 0.13.0+ 25 | 26 | ## Installation 27 | 28 | ### Ansible 2+ 29 | 30 | Using ansible galaxy cli: 31 | 32 | ```bash 33 | ansible-galaxy install manala.influxdb 34 | ``` 35 | 36 | Using ansible galaxy requirements file: 37 | 38 | ```yaml 39 | - src: manala.influxdb 40 | ``` 41 | 42 | ## Role Handlers 43 | 44 | | Name | Type | Description | 45 | | ------------------ | ------- | ----------------------- | 46 | | `influxdb restart` | Service | Restart influxdb server | 47 | 48 | ## Role Variables 49 | 50 | | Name | Default | Type | Description | 51 | | ------------------------------------------ | ----------------------------- | ------------ | -------------------------------------- | 52 | | `manala_influxdb_install_packages` | ~ | Array | Dependency packages to install | 53 | | `manala_influxdb_install_packages_default` | ['influxdb'] | Array | Default dependency packages to install | 54 | | `manala_influxdb_dir`: | [] | Array | Directories used by Influxdb | 55 | | `manala_influxdb_databases` | [] | Array | Databases | 56 | | `manala_influxdb_users` | [] | Array | Users | 57 | | `manala_influxdb_privileges` | [] | Array | Privileges | 58 | | `manala_influxdb_config` | ~ | Array/String | Configuration | 59 | | `manala_influxdb_config_file` | '/etc/influxdb/influxdb.conf' | String | Configuration file path | 60 | | `manala_influxdb_config_template` | 'config/base.conf.j2' | String | Configuration template path | 61 | 62 | ### Configuration example 63 | 64 | Use influxdata default main config template (recommended): 65 | 66 | ```yaml 67 | manala_influxdb_config_template: config/influxdata/influxdb.conf.j2 68 | manala_influxdb_config: 69 | reporting-disabled: true 70 | meta: 71 | dir: /srv/db/influxdb/meta 72 | http: 73 | enabled: true 74 | udp: 75 | - enabled: true 76 | bind-address: :8090 77 | database: app 78 | ``` 79 | 80 | Use dict parameters: 81 | ```yaml 82 | manala_influxdb_config: 83 | reporting-disabled: true 84 | meta: 85 | dir: /srv/db/influxdb/meta 86 | http: 87 | enabled: true 88 | udp: 89 | - enabled: true 90 | bind-address: :8090 91 | database: app 92 | ``` 93 | 94 | Use raw config: 95 | ```yaml 96 | manala_influxdb_config: | 97 | reporting-disabled = true 98 | [meta] 99 | dir = "/srv/db/influxdb/meta" 100 | [http] 101 | enabled = true 102 | [[udp]] 103 | enabled = true 104 | bind-address = ":8090" 105 | database = "app" 106 | ``` 107 | 108 | Use dict's array parameters (deprecated): 109 | ```yaml 110 | manala_influxdb_config: 111 | - reporting-disabled: true 112 | - meta: 113 | - dir: /srv/db/influxdb/meta 114 | - http: 115 | - enabled: true 116 | - udp: 117 | - enabled: true 118 | - bind-address: :8090 119 | - database: app 120 | ``` 121 | 122 | Databases & Users & Privileges: 123 | ```yaml 124 | manala_influxdb_databases: 125 | - my_db 126 | manala_influxdb_users: 127 | - database: my_db 128 | name: my_user 129 | password: my_password 130 | manala_influxdb_privileges: 131 | - database: my_db 132 | user: my_user 133 | grant: ALL 134 | ``` 135 | 136 | See InfluxDB documentation for more information about [databases](https://docs.influxdata.com/influxdb/v0.13/query_language/database_management/#data-management), [users and privileges](https://docs.influxdata.com/influxdb/v0.13/administration/authentication_and_authorization/) 137 | 138 | ## Example playbook 139 | 140 | ```yaml 141 | - hosts: servers 142 | roles: 143 | - role: manala.influxdb 144 | ``` 145 | 146 | # Licence 147 | 148 | MIT 149 | 150 | # Author information 151 | 152 | Manala [**(http://www.manala.io/)**](http://www.manala.io) 153 | -------------------------------------------------------------------------------- /.manala/make/Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: sh update lint test 2 | 3 | ########## 4 | # Manala # 5 | ########## 6 | 7 | MANALA_MAKE_DIR := $(abspath $(patsubst %/Makefile,%,$(lastword $(MAKEFILE_LIST)))) 8 | 9 | include \ 10 | $(MANALA_MAKE_DIR)/Makefile.manala \ 11 | $(MANALA_MAKE_DIR)/Makefile.docker \ 12 | $(MANALA_MAKE_DIR)/Makefile.host \ 13 | $(MANALA_MAKE_DIR)/Makefile.travis 14 | 15 | -include \ 16 | $(MANALA_CURRENT_DIR)/../.env \ 17 | $(MANALA_CURRENT_DIR)/.env 18 | 19 | MANALA_VERBOSE := $(if $(VERBOSE),$(VERBOSE),$(MANALA_VERBOSE)) 20 | 21 | ######## 22 | # Role # 23 | ######## 24 | 25 | ROLE_DIR := $(MANALA_CURRENT_DIR) 26 | ROLE_TESTS_DIR := $(ROLE_DIR)/tests 27 | 28 | ################ 29 | # Distribution # 30 | ################ 31 | 32 | DISTRIBUTION_ID = $(call list_split_first,.,$(DISTRIBUTION)) 33 | DISTRIBUTION_RELEASE = $(call list_split_last,.,$(DISTRIBUTION)) 34 | 35 | ########## 36 | # Docker # 37 | ########## 38 | 39 | MANALA_DOCKER_IMAGE = manala/test-ansible 40 | MANALA_DOCKER_IMAGE_TAG = $(if $(ANSIBLE_VERSION),$(ANSIBLE_VERSION)-)$(DISTRIBUTION) 41 | MANALA_DOCKER_MOUNT_DIR = $(if $(ROLE_MOUNT_DIR),$(ROLE_MOUNT_DIR),/srv/role) 42 | MANALA_DOCKER_HOST = $(ROLE).$(DISTRIBUTION).test 43 | MANALA_DOCKER_RUN_OPTIONS = --privileged 44 | MANALA_DOCKER_VOLUMES = \ 45 | $(ROLE_DIR):/etc/ansible/roles/$(ROLE) \ 46 | $(if $(CACHE_DIR), \ 47 | $(call if_in,$(DISTRIBUTION_ID),debian, \ 48 | $(CACHE_DIR)/$(DISTRIBUTION_ID)/$(DISTRIBUTION_RELEASE)/apt/archives:/var/cache/apt/archives \ 49 | $(CACHE_DIR)/$(DISTRIBUTION_ID)/$(DISTRIBUTION_RELEASE)/apt/lists:/var/lib/apt/lists \ 50 | ) \ 51 | ) 52 | MANALA_DOCKER_ENV = \ 53 | USER_ID=$(MANALA_USER_ID) \ 54 | GROUP_ID=$(MANALA_GROUP_ID) \ 55 | MANALA_HOST=test \ 56 | MANALA_VERBOSE=$(MANALA_VERBOSE) \ 57 | DISTRIBUTION=$(DISTRIBUTION) \ 58 | DISTRIBUTION_ID=$(DISTRIBUTION_ID) \ 59 | DISTRIBUTION_RELEASE=$(DISTRIBUTION_RELEASE) \ 60 | ANSIBLE_ACTION_PLUGINS=/srv/role/action_plugins \ 61 | ANSIBLE_BECOME_FLAGS="$(call escape_spaces,-H -S -n -E)" \ 62 | ANSIBLE_RETRY_FILES_ENABLED=0 \ 63 | ANSIBLE_FORCE_COLOR=1 64 | 65 | ###### 66 | # Sh # 67 | ###### 68 | 69 | MANALA_HELP += $(call if_host,local,$(SH_HELP)\n) 70 | 71 | SH_HELP = \ 72 | $(call help_section,Test host shell) 73 | 74 | sh: .fail_if_host_not(local) 75 | $(call fail_if_not,$(DISTRIBUTION),DISTRIBUTION is empty or not set) 76 | $(call if_in,$(DISTRIBUTION),$(ROLE_DISTRIBUTIONS), \ 77 | $(call docker_shell), \ 78 | $(call log_warning,Shell on \"$(DISTRIBUTION)\" is not supported) \ 79 | ) 80 | 81 | SH_HELP += $(call if_in,debian.jessie,$(ROLE_DISTRIBUTIONS),$(call help,sh.debian.jessie, Open shell on test host - Debian Jessie)) 82 | sh.debian.jessie: DISTRIBUTION = debian.jessie 83 | sh.debian.jessie: sh 84 | 85 | SH_HELP += $(call if_in,debian.stretch,$(ROLE_DISTRIBUTIONS),$(call help,sh.debian.stretch,Open shell on test host - Debian Stretch)) 86 | sh.debian.stretch: DISTRIBUTION = debian.stretch 87 | sh.debian.stretch: sh 88 | 89 | SH_HELP += $(call if_in,debian.buster,$(ROLE_DISTRIBUTIONS),$(call help,sh.debian.buster, Open shell on test host - Debian Buster)) 90 | sh.debian.buster: DISTRIBUTION = debian.buster 91 | sh.debian.buster: sh 92 | 93 | ########## 94 | # Update # 95 | ########## 96 | 97 | MANALA_HELP += $(call if_host,local,$(UPDATE_HELP)\n) 98 | 99 | UPDATE_HELP = \ 100 | $(call help_section,Test host update) \ 101 | $(call help,update, Update test hosts across distributions) 102 | 103 | update: .fail_if_host_not(local) 104 | $(call list_loop,DISTRIBUTION,$(if $(DISTRIBUTIONS),$(DISTRIBUTIONS),$(ROLE_DISTRIBUTIONS)), \ 105 | $$(call if_in,$$(DISTRIBUTION),$$(ROLE_DISTRIBUTIONS), \ 106 | $$(call log,Update \"$$(DISTRIBUTION)\") ; \ 107 | $$(call docker_pull), \ 108 | $$(call log_warning,Update \"$$(DISTRIBUTION)\" is not supported) \ 109 | ) \ 110 | ) 111 | 112 | UPDATE_HELP += $(call if_in,debian.jessie,$(ROLE_DISTRIBUTIONS),$(call help,update.debian.jessie, Update test host - Debian Jessie)) 113 | update.debian.jessie: DISTRIBUTIONS = debian.jessie 114 | update.debian.jessie: update 115 | 116 | UPDATE_HELP += $(call if_in,debian.stretch,$(ROLE_DISTRIBUTIONS),$(call help,update.debian.stretch,Update test host - Debian Stretch)) 117 | update.debian.stretch: DISTRIBUTIONS = debian.stretch 118 | update.debian.stretch: update 119 | 120 | UPDATE_HELP += $(call if_in,debian.buster,$(ROLE_DISTRIBUTIONS),$(call help,update.debian.buster, Update test host - Debian Buster)) 121 | update.debian.buster: DISTRIBUTIONS = debian.buster 122 | update.debian.buster: update 123 | 124 | ######## 125 | # Lint # 126 | ######## 127 | 128 | MANALA_HELP += $(call if_host,local,$(LINT_HELP_LOCAL)\n,$(LINT_HELP_TEST)\n) 129 | 130 | LINT_HELP = $(call help_section,Lint) 131 | LINT_HELP_LOCAL = $(LINT_HELP) \ 132 | $(call help,lint, Lint role across distributions) 133 | LINT_HELP_TEST = $(LINT_HELP) \ 134 | $(call help,lint,Lint role) 135 | 136 | lint: .host_switch(lint) 137 | 138 | lint@local: .fail_if_host_not(local) 139 | $(call list_loop,DISTRIBUTION,$(if $(DISTRIBUTIONS),$(DISTRIBUTIONS),$(ROLE_DISTRIBUTIONS)), \ 140 | $$(call if_in,$$(DISTRIBUTION),$$(ROLE_DISTRIBUTIONS), \ 141 | $$(call log,Lint \"$$(ROLE)\" on \"$$(DISTRIBUTION)\") ; \ 142 | $$(call docker_make,lint@test), \ 143 | $$(call log_warning,Lint \"$$(ROLE)\" on \"$$(DISTRIBUTION)\" is not supported) \ 144 | ) \ 145 | ) 146 | 147 | lint@test: .fail_if_host_not(test) 148 | ansible-lint --force-color -v $(ROLE_DIR) 149 | 150 | LINT_HELP_LOCAL += $(call if_in,debian.jessie,$(ROLE_DISTRIBUTIONS),$(call help,lint.debian.jessie, Lint role - Debian Jessie)) 151 | lint.debian.jessie: DISTRIBUTIONS = debian.jessie 152 | lint.debian.jessie: lint@local 153 | 154 | LINT_HELP_LOCAL += $(call if_in,debian.stretch,$(ROLE_DISTRIBUTIONS),$(call help,lint.debian.stretch,Lint role - Debian Stretch)) 155 | lint.debian.stretch: DISTRIBUTIONS = debian.stretch 156 | lint.debian.stretch: lint@local 157 | 158 | LINT_HELP_LOCAL += $(call if_in,debian.buster,$(ROLE_DISTRIBUTIONS),$(call help,lint.debian.buster, Lint role - Debian Buster)) 159 | lint.debian.buster: DISTRIBUTIONS = debian.buster 160 | lint.debian.buster: lint@local 161 | 162 | ######## 163 | # Test # 164 | ######## 165 | 166 | TESTS = $(sort \ 167 | $(foreach \ 168 | TEST, \ 169 | $(wildcard $(ROLE_TESTS_DIR)/*.yml), \ 170 | $(if $(findstring .goss.,$(TEST)),, \ 171 | $(patsubst /%,%,$(subst $(ROLE_DIR),,$(TEST))) \ 172 | ) \ 173 | ) \ 174 | ) 175 | 176 | tests/%.yml: FORCE 177 | $(call verbose, ,ANSIBLE_STDOUT_CALLBACK=actionable,ANSIBLE_STDOUT_CALLBACK=debug) \ 178 | ansible-playbook $@ \ 179 | --extra-vars="test=$(subst .yml,,$(subst tests/,,$@))" \ 180 | $(if $(CHECK),--check --diff) \ 181 | $(if $(TAGS),--tags=$(TAGS)) 182 | FORCE: 183 | 184 | MANALA_HELP += $(call if_host,local,$(TEST_HELP_LOCAL),$(TEST_HELP_TEST)) 185 | 186 | TEST_HELP = $(call help_section,Test) 187 | TEST_HELP_LOCAL = $(TEST_HELP) \ 188 | $(call help,test, Test role across distributions) 189 | TEST_HELP_BUILD = $(TEST_HELP) \ 190 | $(call help,test,Test role) 191 | 192 | test: .host_switch(test) 193 | 194 | test@local: .fail_if_host_not(local) 195 | $(call list_loop,DISTRIBUTION,$(if $(DISTRIBUTIONS),$(DISTRIBUTIONS),$(ROLE_DISTRIBUTIONS)), \ 196 | $$(call if_in,$$(DISTRIBUTION),$$(ROLE_DISTRIBUTIONS), \ 197 | $$(call log,Test \"$$(ROLE)\" on \"$$(DISTRIBUTION)\") ; \ 198 | $$(call list_loop,TEST,$$(TESTS), \ 199 | $$$$(call log, $$$$(TEST)) ; \ 200 | $$$$(call docker_make,$$$$(TEST)), \ 201 | TRAVIS_FOLD \ 202 | ), \ 203 | $$(call log_warning,Test \"$$(ROLE)\" on \"$$(DISTRIBUTION)\" is not supported) \ 204 | ) \ 205 | ) 206 | 207 | test@test: .fail_if_host_not(test) 208 | $(call list_loop,TEST,$(TESTS), \ 209 | $$(call log,Test \"$$(TEST)\") ; \ 210 | $$(MAKE) $$(TEST) \ 211 | ) 212 | 213 | TEST_HELP_LOCAL += $(call if_in,debian.jessie,$(ROLE_DISTRIBUTIONS),$(call help,test.debian.jessie, Test role - Debian Jessie)) 214 | test.debian.jessie: DISTRIBUTIONS = debian.jessie 215 | test.debian.jessie: test@local 216 | 217 | TEST_HELP_LOCAL += $(call if_in,debian.stretch,$(ROLE_DISTRIBUTIONS),$(call help,test.debian.stretch,Test role - Debian Stretch)) 218 | test.debian.stretch: DISTRIBUTIONS = debian.stretch 219 | test.debian.stretch: test@local 220 | 221 | TEST_HELP_LOCAL += $(call if_in,debian.buster,$(ROLE_DISTRIBUTIONS),$(call help,test.debian.buster, Test role - Debian Buster)) 222 | test.debian.buster: DISTRIBUTIONS = debian.buster 223 | test.debian.buster: test@local 224 | -------------------------------------------------------------------------------- /filter_plugins/manala_toml.py: -------------------------------------------------------------------------------- 1 | from __future__ import absolute_import, division, print_function 2 | __metaclass__ = type 3 | 4 | from ansible.errors import AnsibleFilterError 5 | from ansible.module_utils.six import string_types 6 | 7 | import re 8 | 9 | """ 10 | Config Encoder Filters 11 | More information: https://github.com/jtyr/ansible-config_encoder_filters 12 | """ 13 | 14 | 15 | def _is_num(data): 16 | """Verify if data is either int or float. 17 | Could be replaced by: 18 | from numbers import Number as number 19 | isinstance(data, number) 20 | but that requires Python v2.6+. 21 | """ 22 | 23 | return isinstance(data, int) or isinstance(data, float) 24 | 25 | 26 | def _escape(data, quote='"', format=None): 27 | """Escape special characters in a string.""" 28 | 29 | if format == 'xml': 30 | return ( 31 | str(data). 32 | replace('&', '&'). 33 | replace('<', '<'). 34 | replace('>', '>')) 35 | elif format == 'control': 36 | return ( 37 | str(data). 38 | replace('\b', '\\b'). 39 | replace('\f', '\\f'). 40 | replace('\n', '\\n'). 41 | replace('\r', '\\r'). 42 | replace('\t', '\\t')) 43 | elif quote is not None and len(quote): 44 | return str(data).replace('\\', '\\\\').replace(quote, "\\%s" % quote) 45 | else: 46 | return data 47 | 48 | 49 | def _str_is_int(data): 50 | """Verify if data is integer.""" 51 | 52 | return re.match(r"^[-+]?(0|[1-9][0-9]*)$", str(data)) 53 | 54 | 55 | def _str_is_float(data): 56 | """Verify if data is float.""" 57 | 58 | return re.match( 59 | r"^[-+]?(0|[1-9][0-9]*)(\.[0-9]*)?(e[-+]?[0-9]+)?$", 60 | str(data), flags=re.IGNORECASE) 61 | 62 | 63 | def _str_is_num(data): 64 | """Verify if data is either integer or float.""" 65 | 66 | return _str_is_int(data) or _str_is_float(data) 67 | 68 | 69 | def _str_is_bool(data): 70 | """Verify if data is boolean.""" 71 | 72 | return re.match(r"^(true|false)$", str(data), flags=re.IGNORECASE) 73 | 74 | 75 | def encode_toml( 76 | data, convert_bools=False, convert_nums=False, first=True, quote='"', 77 | table_name="", table_type=None): 78 | """Convert Python data structure to TOML format.""" 79 | 80 | # Return value 81 | rv = "" 82 | 83 | if isinstance(data, dict): 84 | # It's a dict 85 | 86 | tn = table_name 87 | 88 | # First process all keys with elementar value (num/str/bool/array) 89 | for k, v in sorted(data.items()): 90 | 91 | if not (isinstance(v, dict) or isinstance(v, list)): 92 | if tn: 93 | if not first: 94 | rv += "\n" 95 | 96 | if table_type == 'table': 97 | rv += "[%s]\n" % tn 98 | else: 99 | rv += "[[%s]]\n" % tn 100 | 101 | rv += "%s = %s\n" % ( 102 | k, 103 | encode_toml( 104 | v, 105 | convert_bools=convert_bools, 106 | convert_nums=convert_nums, 107 | first=first, 108 | quote=quote)) 109 | 110 | first = False 111 | tn = '' 112 | elif isinstance(v, list) and (not v or not isinstance(v[0], dict)): 113 | if tn: 114 | if not first: 115 | rv += "\n" 116 | 117 | if table_type == 'table': 118 | rv += "[%s]\n" % tn 119 | else: 120 | rv += "[[%s]]\n" % tn 121 | 122 | rv += "%s = %s\n" % ( 123 | k, 124 | encode_toml( 125 | v, 126 | convert_bools=convert_bools, 127 | convert_nums=convert_nums, 128 | first=first, 129 | quote=quote)) 130 | 131 | first = False 132 | tn = '' 133 | 134 | if not data and table_type is not None: 135 | if not first: 136 | rv += "\n" 137 | 138 | if table_type == 'table': 139 | rv += "[%s]\n" % tn 140 | else: 141 | rv += "[[%s]]\n" % tn 142 | 143 | # Then process tables and arrays of tables 144 | for k, v in sorted(data.items()): 145 | tn = table_name 146 | 147 | if isinstance(v, dict): 148 | # Table 149 | tk = k 150 | 151 | if '.' in k: 152 | tk = "%s%s%s" % (quote, _escape(k, quote), quote) 153 | 154 | if tn: 155 | tn += ".%s" % tk 156 | else: 157 | tn += "%s" % tk 158 | 159 | rv += encode_toml( 160 | v, 161 | convert_bools=convert_bools, 162 | convert_nums=convert_nums, 163 | first=first, 164 | quote=quote, 165 | table_name=tn, 166 | table_type='table') 167 | 168 | first = False 169 | elif isinstance(v, list) and (not v or isinstance(v[0], dict)): 170 | # Array of tables 171 | tk = k 172 | 173 | if '.' in k: 174 | tk = "%s%s%s" % (quote, _escape(k, quote), quote) 175 | 176 | if tn: 177 | tn += ".%s" % tk 178 | else: 179 | tn += "%s" % tk 180 | 181 | for t in v: 182 | rv += encode_toml( 183 | t, 184 | convert_bools=convert_bools, 185 | convert_nums=convert_nums, 186 | first=first, 187 | quote=quote, 188 | table_name=tn, 189 | table_type='table_array') 190 | 191 | first = False 192 | 193 | elif isinstance(data, list): 194 | 195 | # Check if all values are elementar (num/str/bool/array) 196 | def is_elem(a): 197 | all_elementar = True 198 | 199 | for lv in a: 200 | if ( 201 | isinstance(lv, dict) or ( 202 | isinstance(lv, list) and 203 | not is_elem(lv))): 204 | all_elementar = False 205 | break 206 | 207 | return all_elementar 208 | 209 | if is_elem(data): 210 | v_len = len(data) 211 | 212 | array = '' 213 | 214 | for i, lv in enumerate(data): 215 | array += "%s" % encode_toml( 216 | lv, 217 | convert_bools=convert_bools, 218 | convert_nums=convert_nums, 219 | first=first, 220 | quote=quote) 221 | 222 | if i+1 < v_len: 223 | array += ', ' 224 | 225 | rv += "[%s]" % (array) 226 | 227 | elif ( 228 | _is_num(data) or 229 | isinstance(data, bool) or 230 | (convert_nums and _str_is_num(data)) or 231 | (convert_bools and _str_is_bool(data))): 232 | # It's number or boolean 233 | 234 | rv += str(data).lower() 235 | 236 | elif isinstance(data, string_types): 237 | # It's a string 238 | 239 | rv += "%s%s%s" % (quote, _escape(data, quote), quote) 240 | 241 | return rv 242 | 243 | 244 | def toml(parameters, exclude=[]): 245 | if not isinstance(parameters, dict): 246 | raise AnsibleFilterError('manala_toml expects a dict but was given a %s' % type(parameters)) 247 | [parameters.pop(key) for key in exclude] 248 | return encode_toml(parameters) 249 | 250 | 251 | def toml_parameters(parameters, exclude=[]): 252 | if not isinstance(parameters, dict): 253 | raise AnsibleFilterError('manala_toml_parameters expects a dict but was given a %s' % type(parameters)) 254 | [parameters.pop(key) for key in exclude] 255 | result = '' 256 | for key in sorted(parameters): 257 | result += '\n %s' % toml_parameter(parameters, key) 258 | return result 259 | 260 | 261 | def toml_parameter(parameters, key, required=False, default=None, comment=False): 262 | if not isinstance(parameters, dict): 263 | raise AnsibleFilterError('manala_toml_parameter parameters expects a dict but was given a %s' % type(parameters)) 264 | if not isinstance(key, string_types): 265 | raise AnsibleFilterError('manala_toml_parameter key expects a string but was given a %s' % type(key)) 266 | if required and key not in parameters: 267 | raise AnsibleFilterError('manala_toml_parameter requires a value for key %s' % key) 268 | result = encode_toml({ 269 | key: parameters.get(key, default) 270 | }).strip() 271 | if key not in parameters: 272 | if comment is True: 273 | result = '# ' + result.replace('\n', '\n# ') 274 | elif isinstance(comment, string_types): 275 | result = comment 276 | return result 277 | 278 | 279 | class FilterModule(object): 280 | ''' Manala toml jinja2 filters ''' 281 | 282 | def filters(self): 283 | filters = { 284 | 'manala_toml': toml, 285 | 'manala_toml_parameters': toml_parameters, 286 | 'manala_toml_parameter': toml_parameter, 287 | } 288 | 289 | return filters 290 | -------------------------------------------------------------------------------- /.manala/make/Makefile.manala: -------------------------------------------------------------------------------- 1 | .DEFAULT_GOAL := help 2 | .PHONY: help manala 3 | 4 | ############################# 5 | # GNU Make Standard Library # 6 | ############################# 7 | 8 | include $(MANALA_MAKE_DIR)/gmsl/gmsl 9 | 10 | ############### 11 | # Directories # 12 | ############### 13 | 14 | MANALA_DIR := $(patsubst %/make,%,$(MANALA_MAKE_DIR)) 15 | MANALA_CURRENT_DIR := $(CURDIR) 16 | 17 | ########### 18 | # Contact # 19 | ########### 20 | 21 | MANALA_CONTACT = $(MANALA_CONTACT_NAME) <$(MANALA_CONTACT_MAIL)> 22 | MANALA_CONTACT_NAME := Manala 23 | MANALA_CONTACT_MAIL := contact@manala.io 24 | 25 | ########## 26 | # Colors # 27 | ########## 28 | 29 | MANALA_COLOR_RESET := \033[0m 30 | MANALA_COLOR_ERROR := \033[31m 31 | MANALA_COLOR_INFO := \033[32m 32 | MANALA_COLOR_WARNING := \033[33m 33 | MANALA_COLOR_COMMENT := \033[36m 34 | 35 | ######## 36 | # Help # 37 | ######## 38 | 39 | define help_section 40 | \n$(MANALA_COLOR_COMMENT)$(1):$(MANALA_COLOR_RESET) 41 | endef 42 | 43 | define help 44 | \n $(MANALA_COLOR_INFO)$(1)$(MANALA_COLOR_RESET) $(2) 45 | endef 46 | 47 | MANALA_HELP = \ 48 | \nUsage: make [$(MANALA_COLOR_INFO)target$(MANALA_COLOR_RESET)]\n\ 49 | $(call help_section,Help)\ 50 | $(call help,help,This help)\ 51 | \n 52 | 53 | help: 54 | @printf "$(MANALA_HELP)" 55 | ifneq ($(MANALA_CURRENT_DIR),$(MANALA_DIR)) 56 | @awk '/^[a-zA-Z\-\_0-9\.@%]+:/ { \ 57 | helpMessage = match(lastLine, /^## (.*)/); \ 58 | if (helpMessage) { \ 59 | helpCommand = substr($$1, 0, index($$1, ":")); \ 60 | helpMessage = substr(lastLine, RSTART + 3, RLENGTH); \ 61 | printf "\n $(MANALA_COLOR_INFO)%-20s$(MANALA_COLOR_RESET) %s", helpCommand, helpMessage; \ 62 | } \ 63 | } \ 64 | { lastLine = $$0 }' $(MAKEFILE_LIST) 65 | endif 66 | @printf "\n\n" 67 | 68 | ################ 69 | # User / Group # 70 | ################ 71 | 72 | MANALA_USER_ID := $(shell id -u) 73 | MANALA_GROUP_ID := $(shell id -g) 74 | 75 | ############### 76 | # Interactive # 77 | ############### 78 | 79 | MANALA_INTERACTIVE := $(shell [ -t 0 ] && echo 1) 80 | 81 | ############### 82 | # Date / Time # 83 | ############### 84 | 85 | # Usage: 86 | # $(call time) = 11:06:20 87 | # $(call date_nano) = 1504443855143518510 88 | 89 | define time 90 | `date -u +%T` 91 | endef 92 | 93 | ifeq ($(shell uname -s),Darwin) 94 | define date_nano 95 | `date -u +%s000000000` 96 | endef 97 | else 98 | define date_nano 99 | `date -u +%s%N` 100 | endef 101 | endif 102 | 103 | ########### 104 | # Verbose # 105 | ########### 106 | 107 | # 0: Nothing 108 | # 1: Nothing but errors and logs 109 | # 2: Normal 110 | # 3: Verbose 111 | MANALA_VERBOSE ?= 2 112 | 113 | # Usage: 114 | # [MANALA_VERBOSE = 0] 115 | # $(call verbose,foo,bar) = foo 116 | # $(call verbose,foo) = foo 117 | # [MANALA_VERBOSE = 1] 118 | # $(call verbose,foo,bar) = bar 119 | # $(call verbose,foo,) = 120 | # $(call verbose,foo) = foo 121 | 122 | define verbose 123 | $(call if_eq,$(MANALA_VERBOSE),0,$(1),$(call if_eq,$(MANALA_VERBOSE),1,$(if $(2),$(2),$(1)),$(call if_eq,$(MANALA_VERBOSE),2,$(if $(3),$(3),$(if $(2),$(2),$(1))),$(if $(4),$(4),$(if $(3),$(3),$(if $(2),$(2),$(1))))))) 124 | endef 125 | 126 | ################# 127 | # Message / Log # 128 | ################# 129 | 130 | # Usage: 131 | # $(call message,Foo bar) = Foo bar 132 | # $(call message_warning,Foo bar) = ¯\_(ツ)_/¯ Foo bar 133 | # $(call message_error,Foo bar) = (╯°□°)╯︵ ┻━┻ Foo bar 134 | # $(call log,Foo bar) = [11:06:20] [target] Foo bar 135 | # $(call log_warning,Foo bar) = [11:06:20] [target] ¯\_(ツ)_/¯ Foo bar 136 | # $(call log_error,Foo bar) = [11:06:20] [target] (╯°□°)╯︵ ┻━┻ Foo bar 137 | 138 | define message 139 | $(call verbose,:,printf "$(MANALA_COLOR_INFO)$(1)$(MANALA_COLOR_RESET)\n") 140 | endef 141 | 142 | define message_warning 143 | $(call verbose,:,printf "$(MANALA_COLOR_WARNING)¯\_(ツ)_/¯ $(1)$(MANALA_COLOR_RESET)\n") 144 | endef 145 | 146 | define message_error 147 | $(call verbose,:,printf "$(MANALA_COLOR_ERROR)(╯°□°)╯︵ ┻━┻ $(1)$(MANALA_COLOR_RESET)\n") 148 | endef 149 | 150 | define log 151 | $(call verbose,:,printf "[$(MANALA_COLOR_COMMENT)$(call time)$(MANALA_COLOR_RESET)] [$(MANALA_COLOR_COMMENT)$(@)$(MANALA_COLOR_RESET)] $(MANALA_COLOR_INFO)$(1)$(MANALA_COLOR_RESET)\n") 152 | endef 153 | 154 | define log_warning 155 | $(call verbose,:,printf "[$(MANALA_COLOR_COMMENT)$(call time)$(MANALA_COLOR_RESET)] [$(MANALA_COLOR_COMMENT)$(@)$(MANALA_COLOR_RESET)] $(MANALA_COLOR_WARNING)¯\_(ツ)_/¯ $(1)$(MANALA_COLOR_RESET)\n") 156 | endef 157 | 158 | define log_error 159 | $(call verbose,:,printf "[$(MANALA_COLOR_COMMENT)$(call time)$(MANALA_COLOR_RESET)] [$(MANALA_COLOR_COMMENT)$(@)$(MANALA_COLOR_RESET)] $(MANALA_COLOR_ERROR)(╯°□°)╯︵ ┻━┻ $(1)$(MANALA_COLOR_RESET)\n") 160 | endef 161 | 162 | ###################### 163 | # Special Characters # 164 | ###################### 165 | 166 | # Hide special characters from Make's parser 167 | # See: http://blog.jgc.org/2007/06/escaping-comma-and-space-in-gnu-make.html 168 | 169 | , := , 170 | space := 171 | space += 172 | $(space) := 173 | $(space) += 174 | 175 | # Usage: 176 | # $(call escape_spaces,foo bar) = foo\ bar 177 | # $(call unescape_spaces,foo\ bar) = foo bar 178 | # $(call encode_spaces,foo\ bar) = foo␣bar 179 | # $(call decode_spaces,foo␣bar) = foo bar 180 | 181 | define escape_spaces 182 | $(subst $( ),\ ,$(1)) 183 | endef 184 | 185 | define unescape_spaces 186 | $(subst \ ,$( ),$(1)) 187 | endef 188 | 189 | define encode_spaces 190 | $(subst \ ,␣,$(1)) 191 | endef 192 | 193 | define decode_spaces 194 | $(subst ␣, ,$(1)) 195 | endef 196 | 197 | ######## 198 | # Fail # 199 | ######## 200 | 201 | define fail_if_not 202 | $(if $(1),,$(call message_error,$(2)); exit 1) 203 | endef 204 | 205 | define fail_if_not_in 206 | $(call if_in,$(1),$(2),,$(call message_error,$(3)); exit 1) 207 | endef 208 | 209 | ########### 210 | # Confirm # 211 | ########### 212 | 213 | define confirm 214 | printf "\n$(MANALA_COLOR_INFO) ༼ つ ◕_◕ ༽つ $(MANALA_COLOR_WARNING)$(1) (y/N)$(MANALA_COLOR_RESET): "; \ 215 | read CONFIRM ; if [ "$$CONFIRM" != "y" ]; then printf "\n"; exit 1; fi; \ 216 | printf "\n" 217 | endef 218 | 219 | ###### 220 | # If # 221 | ###### 222 | 223 | # If element in list list 224 | 225 | # Usage: 226 | # $(call if_in,foo,foo bar baz,Yes,No) = Yes 227 | # $(call if_in,qux,foo bar baz,Yes,No) = No 228 | 229 | define if_in 230 | $(if $(call set_is_member,$(1),$(2)),$(3),$(4)) 231 | endef 232 | 233 | # If equal 234 | 235 | # Usage: 236 | # $(call if_eq,1,1,Yes,No) = Yes 237 | # $(call if_eq,1,2,Yes,No) = No 238 | 239 | define if_eq 240 | $(if $(call seq,$(1),$(2)),$(3),$(4)) 241 | endef 242 | 243 | # If number greater than or equal 244 | 245 | # Usage: 246 | # $(call if_gte,1,1,Yes,No) = Yes 247 | # $(call if_gte,2,1,Yes,No) = Yes 248 | # $(call if_gte,2,1,Yes,No) = No 249 | 250 | define if_gte 251 | $(if $(call gte,$(1),$(2)),$(3),$(4)) 252 | endef 253 | 254 | ######## 255 | # List # 256 | ######## 257 | 258 | # Returns the list with duplicate elements removed without reordering 259 | # Usage: 260 | # $(call list_uniq,foo bar bar baz) = foo bar 261 | 262 | define list_uniq 263 | $(call uniq,$(1)) 264 | endef 265 | 266 | # Splits a string into a list separated by spaces at the split character in the first argument 267 | # Usage: 268 | # $(call list_split,:,foo:bar) = foo bar 269 | 270 | define list_split 271 | $(call split,$(1),$(2)) 272 | endef 273 | 274 | # Usage: 275 | # $(call list_split_first,:,foo:bar) = foo 276 | 277 | define list_split_first 278 | $(call list_first,$(call list_split,$(1),$(2))) 279 | endef 280 | 281 | # Usage: 282 | # $(call list_split_last,:,foo:bar) = bar 283 | 284 | define list_split_last 285 | $(call list_last,$(call list_split,$(1),$(2))) 286 | endef 287 | 288 | # Returns the first element of a list 289 | # Usage: 290 | # $(call list_first,foo bar) = foo 291 | 292 | define list_first 293 | $(call first,$(1)) 294 | endef 295 | 296 | # Returns the last element of a list 297 | # Usage: 298 | # $(call list_last,foo bar) = bar 299 | 300 | define list_last 301 | $(call last,$(1)) 302 | endef 303 | 304 | # Returns the list with the first element removed 305 | # Usage: 306 | # $(call list_rest,foo bar baz) = bar baz 307 | 308 | define list_rest 309 | $(call rest,$(1)) 310 | endef 311 | 312 | # Returns the list with the last element removed 313 | # Usage: 314 | # $(call list_chop,foo bar baz) = foo bar 315 | 316 | define list_chop 317 | $(call chop,$(1)) 318 | endef 319 | 320 | # Usage: 321 | # $(call list_loop,ITEM,foo bar baz,echo $$(ITEM)) = foo\nbar\nbaz\n 322 | 323 | define list_loop 324 | ( MANALA_LIST_LOOP_EXIT=0 ; \ 325 | $(foreach \ 326 | $(1), \ 327 | $(2), \ 328 | MANALA_LIST_LOOP_ITEM=$($(1)) ; \ 329 | $(foreach MANALA_LIST_LOOP_START_HOOK,$(4),$(eval MANALA_LIST_LOOP_HOOK = $(value MANALA_LIST_LOOP_HOOK_START_$(MANALA_LIST_LOOP_START_HOOK))) $(MANALA_LIST_LOOP_HOOK)) \ 330 | ( $(eval MANALA_LIST_LOOP := $(3)) $(MANALA_LIST_LOOP) ) ; \ 331 | MANALA_LIST_LOOP_ITEM_EXIT=$${?} ; MANALA_LIST_LOOP_EXIT=$$(($${MANALA_LIST_LOOP_EXIT} || $${MANALA_LIST_LOOP_ITEM_EXIT})) ; \ 332 | $(foreach MANALA_LIST_LOOP_END_HOOK,$(4),$(eval MANALA_LIST_LOOP_HOOK = $(value MANALA_LIST_LOOP_HOOK_END_$(MANALA_LIST_LOOP_END_HOOK))) $(MANALA_LIST_LOOP_HOOK)) \ 333 | ) \ 334 | [ $${MANALA_LIST_LOOP_EXIT} -eq 0 ] ) 335 | endef 336 | 337 | MANALA_LIST_LOOP_HOOK_START_DEBUG = printf "$(MANALA_COLOR_COMMENT)===$(MANALA_COLOR_RESET) Loop start \"$(MANALA_COLOR_INFO)$${MANALA_LIST_LOOP_ITEM}$(MANALA_COLOR_RESET)\" $(MANALA_COLOR_COMMENT)===$(MANALA_COLOR_RESET)\n" ; 338 | MANALA_LIST_LOOP_HOOK_END_DEBUG = printf "$(MANALA_COLOR_COMMENT)===$(MANALA_COLOR_RESET) Loop stop \"$(MANALA_COLOR_INFO)$${MANALA_LIST_LOOP_ITEM}$(MANALA_COLOR_RESET)\" $(MANALA_COLOR_COMMENT)===$(MANALA_COLOR_RESET) Exit \"$(MANALA_COLOR_INFO)$${MANALA_LIST_LOOP_ITEM_EXIT}$(MANALA_COLOR_RESET)\" $(MANALA_COLOR_COMMENT)===$(MANALA_COLOR_RESET)\n" ; 339 | 340 | # Usage: 341 | # $(call list_partition,1,3,aaa zzz eee rrr ttt yyy uuu iii ooo ppp) = aaa zzz eee 342 | # $(call list_partition,2,3,aaa zzz eee rrr ttt yyy uuu iii ooo ppp) = rrr ttt yyy 343 | # $(call list_partition,3,3,aaa zzz eee rrr ttt yyy uuu iii ooo ppp) = uuu iii ooo ppp 344 | 345 | define list_partition 346 | $(wordlist $(call list_partition_index,$(1),$(2),$(words $(3))),$(call plus,$(call list_partition_index,$(1),$(2),$(words $(3))),$(call list_partition_size,$(1),$(2),$(words $(3)))),$(3)) 347 | endef 348 | 349 | define list_partition_index 350 | $(call if_gte,$(3),$(2),$(call plus,$(call multiply,$(call subtract,$(1),1),$(call divide,$(3),$(2))),1),$(1)) 351 | endef 352 | 353 | define list_partition_size 354 | $(call if_eq,$(1),$(2),$(3),$(call subtract,$(call if_gte,$(3),$(2),$(call divide,$(3),$(2)),1,),1)) 355 | endef 356 | 357 | ########## 358 | # Semver # 359 | ########## 360 | 361 | # Usage: 362 | # $(call semver_major,3.2.1) = 3 363 | 364 | define semver_major 365 | $(call list_first,$(call list_split,.,$(1))) 366 | endef 367 | 368 | # Usage: 369 | # $(call semver_minor,3.2.1) = 2 370 | 371 | define semver_minor 372 | $(call list_first,$(call list_rest,$(call list_split,.,$(1)))) 373 | endef 374 | 375 | # Usage: 376 | # $(call semver_patch,3.2.1) = 1 377 | 378 | define semver_patch 379 | $(call list_last,$(call list_split,.,$(1))) 380 | endef 381 | 382 | 383 | ######## 384 | # Rand # 385 | ######## 386 | 387 | # Usage: 388 | # $(call rand) = 51088 389 | # $(call rand) = 49478 390 | # ... 391 | 392 | define rand 393 | `od -An -N2 -i /dev/random | tr -d ' '` 394 | endef 395 | 396 | ########## 397 | # Manala # 398 | ########## 399 | 400 | manala: 401 | @curl -s -L http://bit.ly/10hA8iC | bash 402 | -------------------------------------------------------------------------------- /templates/config/influxdata/influxdb.conf.j2: -------------------------------------------------------------------------------- 1 | {% set config = { 2 | 'meta': {}, 3 | 'data': {}, 4 | 'coordinator': {}, 5 | 'retention': {}, 6 | 'shard-precreation': {}, 7 | 'monitor': {}, 8 | 'http': {}, 9 | 'logging': {}, 10 | 'subscriber': {}, 11 | 'graphite': [{}], 12 | 'collectd': [{}], 13 | 'opentsdb': [{}], 14 | 'udp': [{}], 15 | 'continuous_queries': {}, 16 | 'tls': {}, 17 | } | combine(manala_influxdb_config|default({}, true)) -%} 18 | 19 | ### Welcome to the InfluxDB configuration file. 20 | 21 | # The values in this file override the default values used by the system if 22 | # a config option is not specified. The commented out lines are the configuration 23 | # field and the default value used. Uncommenting a line and changing the value 24 | # will change the value used at runtime when the process is restarted. 25 | 26 | # Once every 24 hours InfluxDB will report usage data to usage.influxdata.com 27 | # The data includes a random ID, os, arch, version, the number of series and other 28 | # usage data. No data from user databases is ever transmitted. 29 | # Change this option to true to disable reporting. 30 | {{ config | manala_toml_parameter('reporting-disabled', default=False, comment=True) }} 31 | 32 | # Bind address to use for the RPC service for backup and restore. 33 | {{ config | manala_toml_parameter('bind-address', default='127.0.0.1:8088', comment=True) }} 34 | 35 | ### 36 | ### [meta] 37 | ### 38 | ### Controls the parameters for the Raft consensus group that stores metadata 39 | ### about the InfluxDB cluster. 40 | ### 41 | 42 | [meta] 43 | # Where the metadata/raft database is stored 44 | {{ config.meta | manala_toml_parameter('dir', default='/var/lib/influxdb/meta') }} 45 | 46 | # Automatically create a default retention policy when creating a database. 47 | {{ config.meta | manala_toml_parameter('retention-autocreate', default=True, comment=True) }} 48 | 49 | # If log messages are printed for the meta service 50 | {{ config.meta | manala_toml_parameter('logging-enabled', default=True, comment=True) }} 51 | 52 | ### 53 | ### [data] 54 | ### 55 | ### Controls where the actual shard data for InfluxDB lives and how it is 56 | ### flushed from the WAL. "dir" may need to be changed to a suitable place 57 | ### for your system, but the WAL settings are an advanced configuration. The 58 | ### defaults should work for most systems. 59 | ### 60 | 61 | [data] 62 | # The directory where the TSM storage engine stores TSM files. 63 | {{ config.data | manala_toml_parameter('dir', default='/var/lib/influxdb/data') }} 64 | 65 | # The directory where the TSM storage engine stores WAL files. 66 | {{ config.data | manala_toml_parameter('wal-dir', default='/var/lib/influxdb/wal') }} 67 | 68 | # The amount of time that a write will wait before fsyncing. A duration 69 | # greater than 0 can be used to batch up multiple fsync calls. This is useful for slower 70 | # disks or when WAL write contention is seen. A value of 0s fsyncs every write to the WAL. 71 | # Values in the range of 0-100ms are recommended for non-SSD disks. 72 | {{ config.data | manala_toml_parameter('wal-fsync-delay', default='0s', comment=True) }} 73 | 74 | 75 | # The type of shard index to use for new shards. The default is an in-memory index that is 76 | # recreated at startup. A value of "tsi1" will use a disk based index that supports higher 77 | # cardinality datasets. 78 | {{ config.data | manala_toml_parameter('index-version', default='inmem', comment=True) }} 79 | 80 | # Trace logging provides more verbose output around the tsm engine. Turning 81 | # this on can provide more useful output for debugging tsm engine issues. 82 | {{ config.data | manala_toml_parameter('trace-logging-enabled', default=False, comment=True) }} 83 | 84 | # Whether queries should be logged before execution. Very useful for troubleshooting, but will 85 | # log any sensitive data contained within a query. 86 | {{ config.data | manala_toml_parameter('query-log-enabled', default=True, comment=True) }} 87 | 88 | # Validates incoming writes to ensure keys only have valid unicode characters. 89 | # This setting will incur a small overhead because every key must be checked. 90 | {{ config.data | manala_toml_parameter('validate-keys', default=False, comment=True) }} 91 | 92 | # Settings for the TSM engine 93 | 94 | # CacheMaxMemorySize is the maximum size a shard's cache can 95 | # reach before it starts rejecting writes. 96 | # Valid size suffixes are k, m, or g (case insensitive, 1024 = 1k). 97 | # Values without a size suffix are in bytes. 98 | {{ config.data | manala_toml_parameter('cache-max-memory-size', default='1g', comment=True) }} 99 | 100 | # CacheSnapshotMemorySize is the size at which the engine will 101 | # snapshot the cache and write it to a TSM file, freeing up memory 102 | # Valid size suffixes are k, m, or g (case insensitive, 1024 = 1k). 103 | # Values without a size suffix are in bytes. 104 | {{ config.data | manala_toml_parameter('cache-snapshot-memory-size', default='25m', comment=True) }} 105 | 106 | # CacheSnapshotWriteColdDuration is the length of time at 107 | # which the engine will snapshot the cache and write it to 108 | # a new TSM file if the shard hasn't received writes or deletes 109 | {{ config.data | manala_toml_parameter('cache-snapshot-write-cold-duration', default='10m', comment=True) }} 110 | 111 | # CompactFullWriteColdDuration is the duration at which the engine 112 | # will compact all TSM files in a shard if it hasn't received a 113 | # write or delete 114 | {{ config.data | manala_toml_parameter('compact-full-write-cold-duration', default='4h', comment=True) }} 115 | 116 | # The maximum number of concurrent full and level compactions that can run at one time. A 117 | # value of 0 results in 50% of runtime.GOMAXPROCS(0) used at runtime. Any number greater 118 | # than 0 limits compactions to that value. This setting does not apply 119 | # to cache snapshotting. 120 | {{ config.data | manala_toml_parameter('max-concurrent-compactions', default=0, comment=True) }} 121 | 122 | # CompactThroughput is the rate limit in bytes per second that we 123 | # will allow TSM compactions to write to disk. Note that short bursts are allowed 124 | # to happen at a possibly larger value, set by CompactThroughputBurst 125 | {{ config.data | manala_toml_parameter('compact-throughput', default='48m', comment=True) }} 126 | 127 | # CompactThroughputBurst is the rate limit in bytes per second that we 128 | # will allow TSM compactions to write to disk. 129 | {{ config.data | manala_toml_parameter('compact-throughput-burst', default='48m', comment=True) }} 130 | 131 | # If true, then the mmap advise value MADV_WILLNEED will be provided to the kernel with respect to 132 | # TSM files. This setting has been found to be problematic on some kernels, and defaults to off. 133 | # It might help users who have slow disks in some cases. 134 | {{ config.data | manala_toml_parameter('tsm-use-madv-willneed', default=False, comment=True) }} 135 | 136 | # Settings for the inmem index 137 | 138 | # The maximum series allowed per database before writes are dropped. This limit can prevent 139 | # high cardinality issues at the database level. This limit can be disabled by setting it to 140 | # 0. 141 | {{ config.data | manala_toml_parameter('max-series-per-database', default=1000000, comment=True) }} 142 | 143 | # The maximum number of tag values per tag that are allowed before writes are dropped. This limit 144 | # can prevent high cardinality tag values from being written to a measurement. This limit can be 145 | # disabled by setting it to 0. 146 | {{ config.data | manala_toml_parameter('max-values-per-tag', default=100000, comment=True) }} 147 | 148 | # Settings for the tsi1 index 149 | 150 | # The threshold, in bytes, when an index write-ahead log file will compact 151 | # into an index file. Lower sizes will cause log files to be compacted more 152 | # quickly and result in lower heap usage at the expense of write throughput. 153 | # Higher sizes will be compacted less frequently, store more series in-memory, 154 | # and provide higher write throughput. 155 | # Valid size suffixes are k, m, or g (case insensitive, 1024 = 1k). 156 | # Values without a size suffix are in bytes. 157 | {{ config.data | manala_toml_parameter('max-index-log-file-size', default='1m', comment=True) }} 158 | 159 | # The size of the internal cache used in the TSI index to store previously 160 | # calculated series results. Cached results will be returned quickly from the cache rather 161 | # than needing to be recalculated when a subsequent query with a matching tag key/value 162 | # predicate is executed. Setting this value to 0 will disable the cache, which may 163 | # lead to query performance issues. 164 | # This value should only be increased if it is known that the set of regularly used 165 | # tag key/value predicates across all measurements for a database is larger than 100. An 166 | # increase in cache size may lead to an increase in heap usage. 167 | {{ config.data | manala_toml_parameter('series-id-set-cache-size', default=100) }} 168 | 169 | ### 170 | ### [coordinator] 171 | ### 172 | ### Controls the clustering service configuration. 173 | ### 174 | 175 | [coordinator] 176 | # The default time a write request will wait until a "timeout" error is returned to the caller. 177 | {{ config.coordinator | manala_toml_parameter('write-timeout', default='10s', comment=True) }} 178 | 179 | # The maximum number of concurrent queries allowed to be executing at one time. If a query is 180 | # executed and exceeds this limit, an error is returned to the caller. This limit can be disabled 181 | # by setting it to 0. 182 | {{ config.coordinator | manala_toml_parameter('max-concurrent-queries', default=0, comment=True) }} 183 | 184 | # The maximum time a query will is allowed to execute before being killed by the system. This limit 185 | # can help prevent run away queries. Setting the value to 0 disables the limit. 186 | {{ config.coordinator | manala_toml_parameter('query-timeout', default='0s', comment=True) }} 187 | 188 | # The time threshold when a query will be logged as a slow query. This limit can be set to help 189 | # discover slow or resource intensive queries. Setting the value to 0 disables the slow query logging. 190 | {{ config.coordinator | manala_toml_parameter('log-queries-after', default='0s', comment=True) }} 191 | 192 | # The maximum number of points a SELECT can process. A value of 0 will make 193 | # the maximum point count unlimited. This will only be checked every second so queries will not 194 | # be aborted immediately when hitting the limit. 195 | {{ config.coordinator | manala_toml_parameter('max-select-point', default=0, comment=True) }} 196 | 197 | # The maximum number of series a SELECT can run. A value of 0 will make the maximum series 198 | # count unlimited. 199 | {{ config.coordinator | manala_toml_parameter('max-select-series', default=0, comment=True) }} 200 | 201 | # The maximum number of group by time bucket a SELECT can create. A value of zero will max the maximum 202 | # number of buckets unlimited. 203 | {{ config.coordinator | manala_toml_parameter('max-select-buckets', default=0, comment=True) }} 204 | 205 | ### 206 | ### [retention] 207 | ### 208 | ### Controls the enforcement of retention policies for evicting old data. 209 | ### 210 | 211 | [retention] 212 | # Determines whether retention policy enforcement enabled. 213 | {{ config.retention | manala_toml_parameter('enabled', default=True, comment=True) }} 214 | 215 | # The interval of time when retention policy enforcement checks run. 216 | {{ config.retention | manala_toml_parameter('check-interval', default='30m', comment=True) }} 217 | 218 | ### 219 | ### [shard-precreation] 220 | ### 221 | ### Controls the precreation of shards, so they are available before data arrives. 222 | ### Only shards that, after creation, will have both a start- and end-time in the 223 | ### future, will ever be created. Shards are never precreated that would be wholly 224 | ### or partially in the past. 225 | 226 | [shard-precreation] 227 | # Determines whether shard pre-creation service is enabled. 228 | {{ config['shard-precreation'] | manala_toml_parameter('enabled', default=True, comment=True) }} 229 | 230 | # The interval of time when the check to pre-create new shards runs. 231 | {{ config['shard-precreation'] | manala_toml_parameter('check-interval', default='10m', comment=True) }} 232 | 233 | # The default period ahead of the endtime of a shard group that its successor 234 | # group is created. 235 | {{ config['shard-precreation'] | manala_toml_parameter('advance-period', default='30m', comment=True) }} 236 | 237 | ### 238 | ### Controls the system self-monitoring, statistics and diagnostics. 239 | ### 240 | ### The internal database for monitoring data is created automatically if 241 | ### if it does not already exist. The target retention within this database 242 | ### is called 'monitor' and is also created with a retention period of 7 days 243 | ### and a replication factor of 1, if it does not exist. In all cases the 244 | ### this retention policy is configured as the default for the database. 245 | 246 | [monitor] 247 | # Whether to record statistics internally. 248 | {{ config.monitor | manala_toml_parameter('store-enabled', default=True, comment=True) }} 249 | 250 | # The destination database for recorded statistics 251 | {{ config.monitor | manala_toml_parameter('store-database', default='_internal', comment=True) }} 252 | 253 | # The interval at which to record statistics 254 | {{ config.monitor | manala_toml_parameter('store-interval', default='10s', comment=True) }} 255 | 256 | ### 257 | ### [http] 258 | ### 259 | ### Controls how the HTTP endpoints are configured. These are the primary 260 | ### mechanism for getting data into and out of InfluxDB. 261 | ### 262 | 263 | [http] 264 | # Determines whether HTTP endpoint is enabled. 265 | {{ config.http | manala_toml_parameter('enabled', default=True, comment=True) }} 266 | 267 | # Determines whether the Flux query endpoint is enabled. 268 | {{ config.http | manala_toml_parameter('flux-enabled', default=False, comment=True) }} 269 | 270 | # Determines whether the Flux query logging is enabled. 271 | {{ config.http | manala_toml_parameter('flux-log-enabled', default=False, comment=True) }} 272 | 273 | # The bind address used by the HTTP service. 274 | {{ config.http | manala_toml_parameter('bind-address', default=':8086', comment=True) }} 275 | 276 | # Determines whether user authentication is enabled over HTTP/HTTPS. 277 | {{ config.http | manala_toml_parameter('auth-enabled', default=False, comment=True) }} 278 | 279 | # The default realm sent back when issuing a basic auth challenge. 280 | {{ config.http | manala_toml_parameter('realm', default='InfluxDB', comment=True) }} 281 | 282 | # Determines whether HTTP request logging is enabled. 283 | {{ config.http | manala_toml_parameter('log-enabled', default=True, comment=True) }} 284 | 285 | # Determines whether the HTTP write request logs should be suppressed when the log is enabled. 286 | {{ config.http | manala_toml_parameter('suppress-write-log', default=False, comment=True) }} 287 | 288 | # When HTTP request logging is enabled, this option specifies the path where 289 | # log entries should be written. If unspecified, the default is to write to stderr, which 290 | # intermingles HTTP logs with internal InfluxDB logging. 291 | # 292 | # If influxd is unable to access the specified path, it will log an error and fall back to writing 293 | # the request log to stderr. 294 | {{ config.http | manala_toml_parameter('access-log-path', default='', comment=True) }} 295 | 296 | # Filters which requests should be logged. Each filter is of the pattern NNN, NNX, or NXX where N is 297 | # a number and X is a wildcard for any number. To filter all 5xx responses, use the string 5xx. 298 | # If multiple filters are used, then only one has to match. The default is to have no filters which 299 | # will cause every request to be printed. 300 | {{ config.http | manala_toml_parameter('access-log-status-filters', default=[], comment=True) }} 301 | 302 | # Determines whether detailed write logging is enabled. 303 | {{ config.http | manala_toml_parameter('write-tracing', default=False, comment=True) }} 304 | 305 | # Determines whether the pprof endpoint is enabled. This endpoint is used for 306 | # troubleshooting and monitoring. 307 | {{ config.http | manala_toml_parameter('pprof-enabled', default=True, comment=True) }} 308 | 309 | # Enables authentication on pprof endpoints. Users will need admin permissions 310 | # to access the pprof endpoints when this setting is enabled. This setting has 311 | # no effect if either auth-enabled or pprof-enabled are set to false. 312 | {{ config.http | manala_toml_parameter('pprof-auth-enabled', default=False, comment=True) }} 313 | 314 | # Enables a pprof endpoint that binds to localhost:6060 immediately on startup. 315 | # This is only needed to debug startup issues. 316 | {{ config.http | manala_toml_parameter('debug-pprof-enabled', default=False, comment=True) }} 317 | 318 | # Enables authentication on the /ping, /metrics, and deprecated /status 319 | # endpoints. This setting has no effect if auth-enabled is set to false. 320 | {{ config.http | manala_toml_parameter('ping-auth-enabled', default=False, comment=True) }} 321 | 322 | # Determines whether HTTPS is enabled. 323 | {{ config.http | manala_toml_parameter('https-enabled', default=False, comment=True) }} 324 | 325 | # The SSL certificate to use when HTTPS is enabled. 326 | {{ config.http | manala_toml_parameter('https-certificate', default='/etc/ssl/influxdb.pem', comment=True) }} 327 | 328 | # Use a separate private key location. 329 | {{ config.http | manala_toml_parameter('https-private-key', default='', comment=True) }} 330 | 331 | # The JWT auth shared secret to validate requests using JSON web tokens. 332 | {{ config.http | manala_toml_parameter('shared-secret', default='', comment=True) }} 333 | 334 | # The default chunk size for result sets that should be chunked. 335 | {{ config.http | manala_toml_parameter('max-row-limit', default=0, comment=True) }} 336 | 337 | # The maximum number of HTTP connections that may be open at once. New connections that 338 | # would exceed this limit are dropped. Setting this value to 0 disables the limit. 339 | {{ config.http | manala_toml_parameter('max-connection-limit', default=0, comment=True) }} 340 | 341 | # Enable http service over unix domain socket 342 | {{ config.http | manala_toml_parameter('unix-socket-enabled', default=False, comment=True) }} 343 | 344 | # The path of the unix domain socket. 345 | {{ config.http | manala_toml_parameter('bind-socket', default='/var/run/influxdb.sock', comment=True) }} 346 | 347 | # The maximum size of a client request body, in bytes. Setting this value to 0 disables the limit. 348 | {{ config.http | manala_toml_parameter('max-body-size', default=25000000, comment=True) }} 349 | 350 | # The maximum number of writes processed concurrently. 351 | # Setting this to 0 disables the limit. 352 | {{ config.http | manala_toml_parameter('max-concurrent-write-limit', default=0, comment=True) }} 353 | 354 | # The maximum number of writes queued for processing. 355 | # Setting this to 0 disables the limit. 356 | {{ config.http | manala_toml_parameter('max-enqueued-write-limit', default=0, comment=True) }} 357 | 358 | # The maximum duration for a write to wait in the queue to be processed. 359 | # Setting this to 0 or setting max-concurrent-write-limit to 0 disables the limit. 360 | {{ config.http | manala_toml_parameter('enqueued-write-timeout', default=0, comment=True) }} 361 | 362 | # User supplied HTTP response headers 363 | # 364 | {% if 'headers' in config.http %} 365 | {{ {'http': {'headers': config.http.headers}} | manala_toml_parameter('http') | replace('\n','\n ') }} 366 | {% else %} 367 | # [http.headers] 368 | # X-Header-1 = "Header Value 1" 369 | # X-Header-2 = "Header Value 2" 370 | {% endif %} 371 | 372 | ### 373 | ### [logging] 374 | ### 375 | ### Controls how the logger emits logs to the output. 376 | ### 377 | 378 | [logging] 379 | # Determines which log encoder to use for logs. Available options 380 | # are auto, logfmt, and json. auto will use a more a more user-friendly 381 | # output format if the output terminal is a TTY, but the format is not as 382 | # easily machine-readable. When the output is a non-TTY, auto will use 383 | # logfmt. 384 | {{ config.logging | manala_toml_parameter('format', default='auto', comment=True) }} 385 | 386 | # Determines which level of logs will be emitted. The available levels 387 | # are error, warn, info, and debug. Logs that are equal to or above the 388 | # specified level will be emitted. 389 | {{ config.logging | manala_toml_parameter('level', default='info', comment=True) }} 390 | 391 | # Suppresses the logo output that is printed when the program is started. 392 | # The logo is always suppressed if STDOUT is not a TTY. 393 | {{ config.logging | manala_toml_parameter('suppress-logo', default=False, comment=True) }} 394 | 395 | ### 396 | ### [subscriber] 397 | ### 398 | ### Controls the subscriptions, which can be used to fork a copy of all data 399 | ### received by the InfluxDB host. 400 | ### 401 | 402 | [subscriber] 403 | # Determines whether the subscriber service is enabled. 404 | {{ config.subscriber | manala_toml_parameter('enabled', default=True, comment=True) }} 405 | 406 | # The default timeout for HTTP writes to subscribers. 407 | {{ config.subscriber | manala_toml_parameter('http-timeout', default='30s', comment=True) }} 408 | 409 | # Allows insecure HTTPS connections to subscribers. This is useful when testing with self- 410 | # signed certificates. 411 | {{ config.subscriber | manala_toml_parameter('insecure-skip-verify', default=False, comment=True) }} 412 | 413 | # The path to the PEM encoded CA certs file. If the empty string, the default system certs will be used 414 | {{ config.subscriber | manala_toml_parameter('ca-certs', default='', comment=True) }} 415 | 416 | # The number of writer goroutines processing the write channel. 417 | {{ config.subscriber | manala_toml_parameter('write-concurrency', default=40, comment=True) }} 418 | 419 | # The number of in-flight writes buffered in the write channel. 420 | {{ config.subscriber | manala_toml_parameter('write-buffer-size', default=1000, comment=True) }} 421 | 422 | 423 | ### 424 | ### [[graphite]] 425 | ### 426 | ### Controls one or many listeners for Graphite data. 427 | ### 428 | {% for graphite in config.graphite %} 429 | 430 | [[graphite]] 431 | # Determines whether the graphite endpoint is enabled. 432 | {{ graphite | manala_toml_parameter('enabled', default=False, comment=True) }} 433 | {{ graphite | manala_toml_parameter('database', default='graphite', comment=True) }} 434 | {{ graphite | manala_toml_parameter('retention-policy', default='', comment=True) }} 435 | {{ graphite | manala_toml_parameter('bind-address', default=':2003', comment=True) }} 436 | {{ graphite | manala_toml_parameter('protocol', default='tcp', comment=True) }} 437 | {{ graphite | manala_toml_parameter('consistency-level', default='one', comment=True) }} 438 | 439 | # These next lines control how batching works. You should have this enabled 440 | # otherwise you could get dropped metrics or poor performance. Batching 441 | # will buffer points in memory if you have many coming in. 442 | 443 | # Flush if this many points get buffered 444 | {{ graphite | manala_toml_parameter('batch-size', default=5000, comment=True) }} 445 | 446 | # number of batches that may be pending in memory 447 | {{ graphite | manala_toml_parameter('batch-pending', default=10, comment=True) }} 448 | 449 | # Flush at least this often even if we haven't hit buffer limit 450 | {{ graphite | manala_toml_parameter('batch-timeout', default='1s', comment=True) }} 451 | 452 | # UDP Read buffer size, 0 means OS default. UDP listener will fail if set above OS max. 453 | {{ graphite | manala_toml_parameter('udp-read-buffer', default=0, comment=True) }} 454 | 455 | ### This string joins multiple matching 'measurement' values providing more control over the final measurement name. 456 | {{ graphite | manala_toml_parameter('separator', default='.', comment=True) }} 457 | 458 | ### Default tags that will be added to all metrics. These can be overridden at the template level 459 | ### or by tags extracted from metric 460 | {{ graphite | manala_toml_parameter('tags', default=['region=us-east', 'zone=1c'], comment=True) }} 461 | 462 | ### Each template line requires a template pattern. It can have an optional 463 | ### filter before the template and separated by spaces. It can also have optional extra 464 | ### tags following the template. Multiple tags should be separated by commas and no spaces 465 | ### similar to the line protocol format. There can be only one default template. 466 | {{ graphite | manala_toml_parameter('templates', comment='# templates = [ 467 | # "*.app env.service.resource.measurement", 468 | # # Default template 469 | # "server.*", 470 | # ]') }} 471 | {% endfor %} 472 | 473 | ### 474 | ### [collectd] 475 | ### 476 | ### Controls one or many listeners for collectd data. 477 | ### 478 | {% for collectd in config.collectd %} 479 | 480 | [[collectd]] 481 | {{ collectd | manala_toml_parameter('enabled', default=False, comment=True) }} 482 | {{ collectd | manala_toml_parameter('bind-address', default=':25826', comment=True) }} 483 | {{ collectd | manala_toml_parameter('database', default='collectd', comment=True) }} 484 | {{ collectd | manala_toml_parameter('retention-policy', default='', comment=True) }} 485 | # 486 | # The collectd service supports either scanning a directory for multiple types 487 | # db files, or specifying a single db file. 488 | {{ collectd | manala_toml_parameter('typesdb', default='/usr/local/share/collectd', comment=True) }} 489 | # 490 | {{ collectd | manala_toml_parameter('security-level', default='none', comment=True) }} 491 | {{ collectd | manala_toml_parameter('auth-file', default='/etc/collectd/auth_file', comment=True) }} 492 | 493 | # These next lines control how batching works. You should have this enabled 494 | # otherwise you could get dropped metrics or poor performance. Batching 495 | # will buffer points in memory if you have many coming in. 496 | 497 | # Flush if this many points get buffered 498 | {{ collectd | manala_toml_parameter('batch-size', default=5000, comment=True) }} 499 | 500 | # Number of batches that may be pending in memory 501 | {{ collectd | manala_toml_parameter('batch-pending', default=10, comment=True) }} 502 | 503 | # Flush at least this often even if we haven't hit buffer limit 504 | {{ collectd | manala_toml_parameter('batch-timeout', default='10s', comment=True) }} 505 | 506 | # UDP Read buffer size, 0 means OS default. UDP listener will fail if set above OS max. 507 | {{ collectd | manala_toml_parameter('read-buffer', default=0, comment=True) }} 508 | 509 | # Multi-value plugins can be handled two ways. 510 | # "split" will parse and store the multi-value plugin data into separate measurements 511 | # "join" will parse and store the multi-value plugin as a single multi-value measurement. 512 | # "split" is the default behavior for backward compatibility with previous versions of influxdb. 513 | {{ collectd | manala_toml_parameter('parse-multivalue-plugin', default='split', comment=True) }} 514 | {% endfor %} 515 | ### 516 | ### [opentsdb] 517 | ### 518 | ### Controls one or many listeners for OpenTSDB data. 519 | ### 520 | {% for opentsdb in config.opentsdb %} 521 | 522 | [[opentsdb]] 523 | {{ opentsdb | manala_toml_parameter('enabled', default=False, comment=True) }} 524 | {{ opentsdb | manala_toml_parameter('bind-address', default=':4242', comment=True) }} 525 | {{ opentsdb | manala_toml_parameter('database', default='opentsdb', comment=True) }} 526 | {{ opentsdb | manala_toml_parameter('retention-policy', default='', comment=True) }} 527 | {{ opentsdb | manala_toml_parameter('consistency-level', default='one', comment=True) }} 528 | {{ opentsdb | manala_toml_parameter('tls-enabled', default=False, comment=True) }} 529 | {{ opentsdb | manala_toml_parameter('certificate', comment='# certificate= "/etc/ssl/influxdb.pem"') }} 530 | 531 | # Log an error for every malformed point. 532 | {{ opentsdb | manala_toml_parameter('log-point-errors', default=True, comment=True) }} 533 | 534 | # These next lines control how batching works. You should have this enabled 535 | # otherwise you could get dropped metrics or poor performance. Only points 536 | # metrics received over the telnet protocol undergo batching. 537 | 538 | # Flush if this many points get buffered 539 | {{ opentsdb | manala_toml_parameter('batch-size', default=1000, comment=True) }} 540 | 541 | # Number of batches that may be pending in memory 542 | {{ opentsdb | manala_toml_parameter('batch-pending', default=5, comment=True) }} 543 | 544 | # Flush at least this often even if we haven't hit buffer limit 545 | {{ opentsdb | manala_toml_parameter('batch-timeout', default='1s', comment=True) }} 546 | {% endfor %} 547 | 548 | ### 549 | ### [[udp]] 550 | ### 551 | ### Controls the listeners for InfluxDB line protocol data via UDP. 552 | ### 553 | {% for udp in config.udp %} 554 | 555 | [[udp]] 556 | {{ udp | manala_toml_parameter('enabled', default=False, comment=True) }} 557 | {{ udp | manala_toml_parameter('bind-address', default=':8089', comment=True) }} 558 | {{ udp | manala_toml_parameter('database', default='udp', comment=True) }} 559 | {{ udp | manala_toml_parameter('retention-policy', default='', comment=True) }} 560 | 561 | # InfluxDB precision for timestamps on received points ("" or "n", "u", "ms", "s", "m", "h") 562 | {{ udp | manala_toml_parameter('precision', default='', comment=True) }} 563 | 564 | # These next lines control how batching works. You should have this enabled 565 | # otherwise you could get dropped metrics or poor performance. Batching 566 | # will buffer points in memory if you have many coming in. 567 | 568 | # Flush if this many points get buffered 569 | {{ udp | manala_toml_parameter('batch-size', default=5000, comment=True) }} 570 | 571 | # Number of batches that may be pending in memory 572 | {{ udp | manala_toml_parameter('batch-pending', default=10, comment=True) }} 573 | 574 | # Will flush at least this often even if we haven't hit buffer limit 575 | {{ udp | manala_toml_parameter('batch-timeout', default='1s', comment=True) }} 576 | 577 | # UDP Read buffer size, 0 means OS default. UDP listener will fail if set above OS max. 578 | {{ udp | manala_toml_parameter('read-buffer', default=0, comment=True) }} 579 | {% endfor %} 580 | 581 | ### 582 | ### [continuous_queries] 583 | ### 584 | ### Controls how continuous queries are run within InfluxDB. 585 | ### 586 | 587 | [continuous_queries] 588 | # Determines whether the continuous query service is enabled. 589 | {{ config.continuous_queries | manala_toml_parameter('enabled', default=True, comment=True) }} 590 | 591 | # Controls whether queries are logged when executed by the CQ service. 592 | {{ config.continuous_queries | manala_toml_parameter('log-enabled', default=True, comment=True) }} 593 | 594 | # Controls whether queries are logged to the self-monitoring data store. 595 | {{ config.continuous_queries | manala_toml_parameter('query-stats-enabled', default=False, comment=True) }} 596 | 597 | # interval for how often continuous queries will be checked if they need to run 598 | {{ config.continuous_queries | manala_toml_parameter('run-interval', default='1s', comment=True) }} 599 | 600 | ### 601 | ### [tls] 602 | ### 603 | ### Global configuration settings for TLS in InfluxDB. 604 | ### 605 | 606 | [tls] 607 | # Determines the available set of cipher suites. See https://golang.org/pkg/crypto/tls/#pkg-constants 608 | # for a list of available ciphers, which depends on the version of Go (use the query 609 | # SHOW DIAGNOSTICS to see the version of Go used to build InfluxDB). If not specified, uses 610 | # the default settings from Go's crypto/tls package. 611 | {{ config.tls | manala_toml_parameter('ciphers', comment='# ciphers = [ 612 | # "TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305", 613 | # "TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305", 614 | # ]') }} 615 | 616 | # Minimum version of the tls protocol that will be negotiated. If not specified, uses the 617 | # default settings from Go's crypto/tls package. 618 | {{ config.tls | manala_toml_parameter('min-version', default='tls1.2', comment=True) }} 619 | 620 | # Maximum version of the tls protocol that will be negotiated. If not specified, uses the 621 | # default settings from Go's crypto/tls package. 622 | {{ config.tls | manala_toml_parameter('max-version', default='tls1.3', comment=True) }} 623 | -------------------------------------------------------------------------------- /templates/config/_default.j2: -------------------------------------------------------------------------------- 1 | {%- set config = manala_influxdb_config -%} 2 | 3 | {%- if config is mapping -%} 4 | 5 | {{ config | manala_toml }} 6 | 7 | {%- elif config is iterable and config is not string -%} 8 | 9 | {#- Deprecated -#} 10 | {%- import '_macros.j2' as macros with context -%} 11 | 12 | {% set config = manala_influxdb_config -%} 13 | 14 | {% set config_meta = [] -%} 15 | {% set config_data = [] -%} 16 | {% set config_database = [] -%} 17 | {% set config_hinted_handoff = [] -%} 18 | {% set config_coordinator = [] -%} 19 | {% set config_retention = [] -%} 20 | {% set config_shard_precreation = [] -%} 21 | {% set config_monitor = [] -%} 22 | {% set config_http = [] -%} 23 | {% set config_logging = [] -%} 24 | {% set config_subscriber = [] -%} 25 | {% set config_graphite = [] -%} 26 | {% set config_collectd = [] -%} 27 | {% set config_opentsdb = [] -%} 28 | {% set config_udp = [] -%} 29 | {% set config_continuous_queries = [] -%} 30 | {% set config_tls = [] -%} 31 | 32 | {%- for configs in config -%} 33 | {%- for config_name, config_parameters in configs.items() -%} 34 | {%- if config_name == 'meta' -%} 35 | {%- if config_meta.extend(config_parameters) -%}{%- endif -%} 36 | {%- elif config_name == 'data' -%} 37 | {%- if config_data.extend(config_parameters) -%}{%- endif -%} 38 | {%- elif config_name == 'database' -%} 39 | {%- if config_database.extend(config_parameters) -%}{%- endif -%} 40 | {%- elif config_name == 'hinted_handoff' -%} 41 | {%- if config_hinted_handoff.extend(config_parameters) -%}{%- endif -%} 42 | {%- elif config_name == 'coordinator' -%} 43 | {%- if config_coordinator.extend(config_parameters) -%}{%- endif -%} 44 | {%- elif config_name == 'retention' -%} 45 | {%- if config_retention.extend(config_parameters) -%}{%- endif -%} 46 | {%- elif config_name == 'shard_precreation' -%} 47 | {%- if config_shard_precreation.extend(config_parameters) -%}{%- endif -%} 48 | {%- elif config_name == 'monitor' -%} 49 | {%- if config_monitor.extend(config_parameters) -%}{%- endif -%} 50 | {%- elif config_name == 'http' -%} 51 | {%- if config_http.extend(config_parameters) -%}{%- endif -%} 52 | {%- elif config_name == 'logging' -%} 53 | {%- if config_logging.extend(config_parameters) -%}{%- endif -%} 54 | {%- elif config_name == 'subscriber' -%} 55 | {%- if config_subscriber.extend(config_parameters) -%}{%- endif -%} 56 | {%- elif config_name == 'auth.graphite' -%} 57 | {%- if config_graphite.extend(config_parameters) -%}{%- endif -%} 58 | {%- elif config_name == 'collectd' -%} 59 | {%- if config_collectd.extend(config_parameters) -%}{%- endif -%} 60 | {%- elif config_name == 'udp' -%} 61 | {%- if config_udp.extend(config_parameters) -%}{%- endif -%} 62 | {%- elif config_name == 'continuous_queries' -%} 63 | {%- if config_continuous_queries.extend(config_parameters) -%}{%- endif -%} 64 | {%- elif config_name == 'tls' -%} 65 | {%- if config_tls.extend(config_parameters) -%}{%- endif -%} 66 | {%- endif -%} 67 | {%- endfor -%} 68 | {%- endfor -%} 69 | ### Welcome to the InfluxDB configuration file. 70 | 71 | # The values in this file override the default values used by the system if 72 | # a config option is not specified. The commented out lines are the configuration 73 | # field and the default value used. Uncommenting a line and changing the value 74 | # will change the value used at runtime when the process is restarted. 75 | 76 | # Once every 24 hours InfluxDB will report usage data to usage.influxdata.com 77 | # The data includes a random ID, os, arch, version, the number of series and other 78 | # usage data. No data from user databases is ever transmitted. 79 | # Change this option to true to disable reporting. 80 | {{ macros.config_row(config, 'reporting-disabled', '# reporting-disabled = false', 0, true) }} 81 | 82 | # Bind address to use for the RPC service for backup and restore. 83 | {{ macros.config_row(config, 'bind-address', '# bind-address = "127.0.0.1:8088"', 0, true) }} 84 | 85 | ### 86 | ### [meta] 87 | ### 88 | ### Controls the parameters for the Raft consensus group that stores metadata 89 | ### about the InfluxDB cluster. 90 | ### 91 | 92 | [meta] 93 | # Where the metadata/raft database is stored 94 | {{ macros.config_row(config_meta, 'dir', '/var/lib/influxdb/meta') }} 95 | 96 | # Automatically create a default retention policy when creating a database. 97 | {{ macros.config_row(config_meta, 'retention-autocreate', '# retention-autocreate = true', 0, true) }} 98 | 99 | # If log messages are printed for the meta service 100 | {{ macros.config_row(config_meta, 'logging-enabled', '# logging-enabled = true', 0, true) }} 101 | 102 | ### 103 | ### [data] 104 | ### 105 | ### Controls where the actual shard data for InfluxDB lives and how it is 106 | ### flushed from the WAL. "dir" may need to be changed to a suitable place 107 | ### for your system, but the WAL settings are an advanced configuration. The 108 | ### defaults should work for most systems. 109 | ### 110 | 111 | [data] 112 | # The directory where the TSM storage engine stores TSM files. 113 | {{ macros.config_row(config_data, 'dir', '/var/lib/influxdb/data') }} 114 | 115 | # The directory where the TSM storage engine stores WAL files. 116 | {{ macros.config_row(config_data, 'wal-dir', '/var/lib/influxdb/wal') }} 117 | 118 | # The amount of time that a write will wait before fsyncing. A duration 119 | # greater than 0 can be used to batch up multiple fsync calls. This is useful for slower 120 | # disks or when WAL write contention is seen. A value of 0s fsyncs every write to the WAL. 121 | # Values in the range of 0-100ms are recommended for non-SSD disks. 122 | {{ macros.config_row(config_data, 'wal-fsync-delay', '# wal-fsync-delay = "0s"', 0, true) }} 123 | 124 | 125 | # The type of shard index to use for new shards. The default is an in-memory index that is 126 | # recreated at startup. A value of "tsi1" will use a disk based index that supports higher 127 | # cardinality datasets. 128 | {{ macros.config_row(config_data, 'index-version', '# index-version = "inmem"', 0, true) }} 129 | 130 | # Trace logging provides more verbose output around the tsm engine. Turning 131 | # this on can provide more useful output for debugging tsm engine issues. 132 | {{ macros.config_row(config_data, 'trace-logging-enabled', '# trace-logging-enabled = false', 0, true) }} 133 | 134 | # Whether queries should be logged before execution. Very useful for troubleshooting, but will 135 | # log any sensitive data contained within a query. 136 | {{ macros.config_row(config_data, 'query-log-enabled', '# query-log-enabled = true', 0, true) }} 137 | 138 | # Validates incoming writes to ensure keys only have valid unicode characters. 139 | # This setting will incur a small overhead because every key must be checked. 140 | {{ macros.config_row(config_data, 'validate-keys', '# validate-keys = false', 0, true) }} 141 | 142 | # Settings for the TSM engine 143 | 144 | # CacheMaxMemorySize is the maximum size a shard's cache can 145 | # reach before it starts rejecting writes. 146 | # Valid size suffixes are k, m, or g (case insensitive, 1024 = 1k). 147 | # Values without a size suffix are in bytes. 148 | {{ macros.config_row(config_data, 'cache-max-memory-size', '# cache-max-memory-size = "1g"', 0, true) }} 149 | 150 | # CacheSnapshotMemorySize is the size at which the engine will 151 | # snapshot the cache and write it to a TSM file, freeing up memory 152 | # Valid size suffixes are k, m, or g (case insensitive, 1024 = 1k). 153 | # Values without a size suffix are in bytes. 154 | {{ macros.config_row(config_data, 'cache-snapshot-memory-size', '# cache-snapshot-memory-size = "25m"', 0, true) }} 155 | 156 | # CacheSnapshotWriteColdDuration is the length of time at 157 | # which the engine will snapshot the cache and write it to 158 | # a new TSM file if the shard hasn't received writes or deletes 159 | {{ macros.config_row(config_data, 'cache-snapshot-write-cold-duration', '# cache-snapshot-write-cold-duration = "10m"', 0, true) }} 160 | 161 | # CompactFullWriteColdDuration is the duration at which the engine 162 | # will compact all TSM files in a shard if it hasn't received a 163 | # write or delete 164 | {{ macros.config_row(config_data, 'compact-full-write-cold-duration', '# compact-full-write-cold-duration = "4h"', 0, true) }} 165 | 166 | # The maximum number of concurrent full and level compactions that can run at one time. A 167 | # value of 0 results in 50% of runtime.GOMAXPROCS(0) used at runtime. Any number greater 168 | # than 0 limits compactions to that value. This setting does not apply 169 | # to cache snapshotting. 170 | {{ macros.config_row(config_data, 'max-concurrent-compactions', '# max-concurrent-compactions = 0', 0, true) }} 171 | 172 | # CompactThroughput is the rate limit in bytes per second that we 173 | # will allow TSM compactions to write to disk. Note that short bursts are allowed 174 | # to happen at a possibly larger value, set by CompactThroughputBurst 175 | {{ macros.config_row(config_data, 'compact-throughput', '# compact-throughput = "48m"', 0, true) }} 176 | 177 | # CompactThroughputBurst is the rate limit in bytes per second that we 178 | # will allow TSM compactions to write to disk. 179 | {{ macros.config_row(config_data, 'compact-throughput-burst', '# compact-throughput-burst = "48m"', 0, true) }} 180 | 181 | # If true, then the mmap advise value MADV_WILLNEED will be provided to the kernel with respect to 182 | # TSM files. This setting has been found to be problematic on some kernels, and defaults to off. 183 | # It might help users who have slow disks in some cases. 184 | {{ macros.config_row(config_data, 'tsm-use-madv-willneed', '# tsm-use-madv-willneed = false', 0, true) }} 185 | 186 | # Settings for the inmem index 187 | 188 | # The maximum series allowed per database before writes are dropped. This limit can prevent 189 | # high cardinality issues at the database level. This limit can be disabled by setting it to 190 | # 0. 191 | {{ macros.config_row(config_data, 'max-series-per-database', '# max-series-per-database = 1000000', 0, true) }} 192 | 193 | # The maximum number of tag values per tag that are allowed before writes are dropped. This limit 194 | # can prevent high cardinality tag values from being written to a measurement. This limit can be 195 | # disabled by setting it to 0. 196 | {{ macros.config_row(config_data, 'max-values-per-tag', '# max-values-per-tag = 100000', 0, true) }} 197 | 198 | # Settings for the tsi1 index 199 | 200 | # The threshold, in bytes, when an index write-ahead log file will compact 201 | # into an index file. Lower sizes will cause log files to be compacted more 202 | # quickly and result in lower heap usage at the expense of write throughput. 203 | # Higher sizes will be compacted less frequently, store more series in-memory, 204 | # and provide higher write throughput. 205 | # Valid size suffixes are k, m, or g (case insensitive, 1024 = 1k). 206 | # Values without a size suffix are in bytes. 207 | {{ macros.config_row(config_data, 'max-index-log-file-size', '# max-index-log-file-size = "1m"', 0, true) }} 208 | 209 | # The size of the internal cache used in the TSI index to store previously 210 | # calculated series results. Cached results will be returned quickly from the cache rather 211 | # than needing to be recalculated when a subsequent query with a matching tag key/value 212 | # predicate is executed. Setting this value to 0 will disable the cache, which may 213 | # lead to query performance issues. 214 | # This value should only be increased if it is known that the set of regularly used 215 | # tag key/value predicates across all measurements for a database is larger than 100. An 216 | # increase in cache size may lead to an increase in heap usage. 217 | {{ macros.config_row(config_data, 'series-id-set-cache-size', 100) }} 218 | 219 | ### 220 | ### [coordinator] 221 | ### 222 | ### Controls the clustering service configuration. 223 | ### 224 | 225 | [coordinator] 226 | # The default time a write request will wait until a "timeout" error is returned to the caller. 227 | {{ macros.config_row(config_coordinator, 'write-timeout', '# write-timeout = "10s"', 0, true) }} 228 | 229 | # The maximum number of concurrent queries allowed to be executing at one time. If a query is 230 | # executed and exceeds this limit, an error is returned to the caller. This limit can be disabled 231 | # by setting it to 0. 232 | {{ macros.config_row(config_coordinator, 'max-concurrent-queries', '# max-concurrent-queries = 0', 0, true) }} 233 | 234 | # The maximum time a query will is allowed to execute before being killed by the system. This limit 235 | # can help prevent run away queries. Setting the value to 0 disables the limit. 236 | {{ macros.config_row(config_coordinator, 'query-timeout', '# query-timeout = "0s"', 0, true) }} 237 | 238 | # The time threshold when a query will be logged as a slow query. This limit can be set to help 239 | # discover slow or resource intensive queries. Setting the value to 0 disables the slow query logging. 240 | {{ macros.config_row(config_coordinator, 'log-queries-after', '# log-queries-after = "0s"', 0, true) }} 241 | 242 | # The maximum number of points a SELECT can process. A value of 0 will make 243 | # the maximum point count unlimited. This will only be checked every second so queries will not 244 | # be aborted immediately when hitting the limit. 245 | {{ macros.config_row(config_coordinator, 'max-select-point', '# max-select-point = 0', 0, true) }} 246 | 247 | # The maximum number of series a SELECT can run. A value of 0 will make the maximum series 248 | # count unlimited. 249 | {{ macros.config_row(config_coordinator, 'max-select-series', '# max-select-series = 0', 0, true) }} 250 | 251 | # The maximum number of group by time bucket a SELECT can create. A value of zero will max the maximum 252 | # number of buckets unlimited. 253 | {{ macros.config_row(config_coordinator, 'max-select-buckets', '# max-select-buckets = 0', 0, true) }} 254 | 255 | ### 256 | ### [retention] 257 | ### 258 | ### Controls the enforcement of retention policies for evicting old data. 259 | ### 260 | 261 | [retention] 262 | # Determines whether retention policy enforcement enabled. 263 | {{ macros.config_row(config_retention, 'enabled', '# enabled = true', 0, true) }} 264 | 265 | # The interval of time when retention policy enforcement checks run. 266 | {{ macros.config_row(config_retention, 'check-interval', '# check-interval = "30m"', 0, true) }} 267 | 268 | ### 269 | ### [shard-precreation] 270 | ### 271 | ### Controls the precreation of shards, so they are available before data arrives. 272 | ### Only shards that, after creation, will have both a start- and end-time in the 273 | ### future, will ever be created. Shards are never precreated that would be wholly 274 | ### or partially in the past. 275 | 276 | [shard-precreation] 277 | # Determines whether shard pre-creation service is enabled. 278 | {{ macros.config_row(config_shard_precreation, 'enabled', '# enabled = true', 0, true) }} 279 | 280 | # The interval of time when the check to pre-create new shards runs. 281 | {{ macros.config_row(config_shard_precreation, 'check-interval', '# check-interval = "10m"', 0, true) }} 282 | 283 | # The default period ahead of the endtime of a shard group that its successor 284 | # group is created. 285 | {{ macros.config_row(config_shard_precreation, 'advance-period', '# advance-period = "30m"', 0, true) }} 286 | 287 | ### 288 | ### Controls the system self-monitoring, statistics and diagnostics. 289 | ### 290 | ### The internal database for monitoring data is created automatically if 291 | ### if it does not already exist. The target retention within this database 292 | ### is called 'monitor' and is also created with a retention period of 7 days 293 | ### and a replication factor of 1, if it does not exist. In all cases the 294 | ### this retention policy is configured as the default for the database. 295 | 296 | [monitor] 297 | # Whether to record statistics internally. 298 | {{ macros.config_row(config_monitor, 'store-enabled', '# store-enabled = true', 0, true) }} 299 | 300 | # The destination database for recorded statistics 301 | {{ macros.config_row(config_monitor, 'store-database', '# store-database = "_internal"', 0, true) }} 302 | 303 | # The interval at which to record statistics 304 | {{ macros.config_row(config_monitor, 'store-interval', '# store-interval = "10s"', 0, true) }} 305 | 306 | ### 307 | ### [http] 308 | ### 309 | ### Controls how the HTTP endpoints are configured. These are the primary 310 | ### mechanism for getting data into and out of InfluxDB. 311 | ### 312 | 313 | [http] 314 | # Determines whether HTTP endpoint is enabled. 315 | {{ macros.config_row(config_http, 'enabled', '# enabled = true', 0, true) }} 316 | 317 | # Determines whether the Flux query endpoint is enabled. 318 | {{ macros.config_row(config_http, 'flux-enabled', '# flux-enabled = false', 0, true) }} 319 | 320 | # Determines whether the Flux query logging is enabled. 321 | {{ macros.config_row(config_http, 'flux-log-enabled', '# flux-log-enabled = false', 0, true) }} 322 | 323 | # The bind address used by the HTTP service. 324 | {{ macros.config_row(config_http, 'bind-address', '# bind-address = ":8086"', 0, true) }} 325 | 326 | # Determines whether user authentication is enabled over HTTP/HTTPS. 327 | {{ macros.config_row(config_http, 'auth-enabled', '# auth-enabled = false', 0, true) }} 328 | 329 | # The default realm sent back when issuing a basic auth challenge. 330 | {{ macros.config_row(config_http, 'realm', '# realm = "InfluxDB"', 0, true) }} 331 | 332 | # Determines whether HTTP request logging is enabled. 333 | {{ macros.config_row(config_http, 'log-enabled', '# log-enabled = true', 0, true) }} 334 | 335 | # Determines whether the HTTP write request logs should be suppressed when the log is enabled. 336 | {{ macros.config_row(config_http, 'suppress-write-log', '# suppress-write-log = false', 0, true) }} 337 | 338 | # When HTTP request logging is enabled, this option specifies the path where 339 | # log entries should be written. If unspecified, the default is to write to stderr, which 340 | # intermingles HTTP logs with internal InfluxDB logging. 341 | # 342 | # If influxd is unable to access the specified path, it will log an error and fall back to writing 343 | # the request log to stderr. 344 | {{ macros.config_row(config_http, 'access-log-path', '# access-log-path = ""', 0, true) }} 345 | 346 | # Filters which requests should be logged. Each filter is of the pattern NNN, NNX, or NXX where N is 347 | # a number and X is a wildcard for any number. To filter all 5xx responses, use the string 5xx. 348 | # If multiple filters are used, then only one has to match. The default is to have no filters which 349 | # will cause every request to be printed. 350 | {{ macros.config_row(config_http, 'access-log-status-filters', '# access-log-status-filters = []', 0, true) }} 351 | 352 | # Determines whether detailed write logging is enabled. 353 | {{ macros.config_row(config_http, 'write-tracing', '# write-tracing = false', 0, true) }} 354 | 355 | # Determines whether the pprof endpoint is enabled. This endpoint is used for 356 | # troubleshooting and monitoring. 357 | {{ macros.config_row(config_http, 'pprof-enabled', '# pprof-enabled = true', 0, true) }} 358 | 359 | # Enables a pprof endpoint that binds to localhost:6060 immediately on startup. 360 | # This is only needed to debug startup issues. 361 | {{ macros.config_row(config_http, 'debug-pprof-enabled', '# debug-pprof-enabled = false', 0, true) }} 362 | 363 | # Determines whether HTTPS is enabled. 364 | {{ macros.config_row(config_http, 'https-enabled', '# https-enabled = false', 0, true) }} 365 | 366 | # The SSL certificate to use when HTTPS is enabled. 367 | {{ macros.config_row(config_http, 'https-certificate', '# https-certificate = "/etc/ssl/influxdb.pem"', 0, true) }} 368 | 369 | # Use a separate private key location. 370 | {{ macros.config_row(config_http, 'https-private-key', '# https-private-key = ""', 0, true) }} 371 | 372 | # The JWT auth shared secret to validate requests using JSON web tokens. 373 | {{ macros.config_row(config_http, 'shared-secret', '# shared-secret = ""', 0, true) }} 374 | 375 | # The default chunk size for result sets that should be chunked. 376 | {{ macros.config_row(config_http, 'max-row-limit', '# max-row-limit = 0', 0, true) }} 377 | 378 | # The maximum number of HTTP connections that may be open at once. New connections that 379 | # would exceed this limit are dropped. Setting this value to 0 disables the limit. 380 | {{ macros.config_row(config_http, 'max-connection-limit', '# max-connection-limit = 0', 0, true) }} 381 | 382 | # Enable http service over unix domain socket 383 | {{ macros.config_row(config_http, 'unix-socket-enabled', '# unix-socket-enabled = false', 0, true) }} 384 | 385 | # The path of the unix domain socket. 386 | {{ macros.config_row(config_http, 'bind-socket', '# bind-socket = "/var/run/influxdb.sock"', 0, true) }} 387 | 388 | # The maximum size of a client request body, in bytes. Setting this value to 0 disables the limit. 389 | {{ macros.config_row(config_http, 'max-body-size', '# max-body-size = 25000000', 0, true) }} 390 | 391 | # The maximum number of writes processed concurrently. 392 | # Setting this to 0 disables the limit. 393 | {{ macros.config_row(config_http, 'max-concurrent-write-limit', '# max-concurrent-write-limit = 0', 0, true) }} 394 | 395 | # The maximum number of writes queued for processing. 396 | # Setting this to 0 disables the limit. 397 | {{ macros.config_row(config_http, 'max-enqueued-write-limit', '# max-enqueued-write-limit = 0', 0, true) }} 398 | 399 | # The maximum duration for a write to wait in the queue to be processed. 400 | # Setting this to 0 or setting max-concurrent-write-limit to 0 disables the limit. 401 | {{ macros.config_row(config_http, 'enqueued-write-timeout', '# enqueued-write-timeout = 0', 0, true) }} 402 | 403 | ### 404 | ### [logging] 405 | ### 406 | ### Controls how the logger emits logs to the output. 407 | ### 408 | 409 | [logging] 410 | # Determines which log encoder to use for logs. Available options 411 | # are auto, logfmt, and json. auto will use a more a more user-friendly 412 | # output format if the output terminal is a TTY, but the format is not as 413 | # easily machine-readable. When the output is a non-TTY, auto will use 414 | # logfmt. 415 | {{ macros.config_row(config_logging, 'format', '# format = "auto"', 0, true) }} 416 | 417 | # Determines which level of logs will be emitted. The available levels 418 | # are error, warn, info, and debug. Logs that are equal to or above the 419 | # specified level will be emitted. 420 | {{ macros.config_row(config_logging, 'level', '# level = "info"', 0, true) }} 421 | 422 | # Suppresses the logo output that is printed when the program is started. 423 | # The logo is always suppressed if STDOUT is not a TTY. 424 | {{ macros.config_row(config_logging, 'suppress-logo', '# suppress-logo = false', 0, true) }} 425 | 426 | ### 427 | ### [subscriber] 428 | ### 429 | ### Controls the subscriptions, which can be used to fork a copy of all data 430 | ### received by the InfluxDB host. 431 | ### 432 | 433 | [subscriber] 434 | # Determines whether the subscriber service is enabled. 435 | {{ macros.config_row(config_subscriber, 'enabled', '# enabled = true', 0, true) }} 436 | 437 | # The default timeout for HTTP writes to subscribers. 438 | {{ macros.config_row(config_subscriber, 'http-timeout', '# http-timeout = "30s"', 0, true) }} 439 | 440 | # Allows insecure HTTPS connections to subscribers. This is useful when testing with self- 441 | # signed certificates. 442 | {{ macros.config_row(config_subscriber, 'insecure-skip-verify', '# insecure-skip-verify = false', 0, true) }} 443 | 444 | # The path to the PEM encoded CA certs file. If the empty string, the default system certs will be used 445 | {{ macros.config_row(config_subscriber, 'ca-certs', '# ca-certs = ""', 0, true) }} 446 | 447 | # The number of writer goroutines processing the write channel. 448 | {{ macros.config_row(config_subscriber, 'write-concurrency', '# write-concurrency = 40', 0, true) }} 449 | 450 | # The number of in-flight writes buffered in the write channel. 451 | {{ macros.config_row(config_subscriber, 'write-buffer-size', '# write-buffer-size = 1000', 0, true) }} 452 | 453 | 454 | ### 455 | ### [[graphite]] 456 | ### 457 | ### Controls one or many listeners for Graphite data. 458 | ### 459 | 460 | [[graphite]] 461 | # Determines whether the graphite endpoint is enabled. 462 | {{ macros.config_row(config_graphite, 'enabled', '# enabled = false', 0, true) }} 463 | {{ macros.config_row(config_graphite, 'database', '# database = "graphite"', 0, true) }} 464 | {{ macros.config_row(config_graphite, 'retention-policy', '# retention-policy = ""', 0, true) }} 465 | {{ macros.config_row(config_graphite, 'bind-address', '# bind-address = ":2003"', 0, true) }} 466 | {{ macros.config_row(config_graphite, 'protocol', '# protocol = "tcp"', 0, true) }} 467 | {{ macros.config_row(config_graphite, 'consistency-level', '# consistency-level = "one"', 0, true) }} 468 | 469 | # These next lines control how batching works. You should have this enabled 470 | # otherwise you could get dropped metrics or poor performance. Batching 471 | # will buffer points in memory if you have many coming in. 472 | 473 | # Flush if this many points get buffered 474 | {{ macros.config_row(config_graphite, 'batch-size', '# batch-size = 5000', 0, true) }} 475 | 476 | # number of batches that may be pending in memory 477 | {{ macros.config_row(config_graphite, 'batch-pending', '# batch-pending = 10', 0, true) }} 478 | 479 | # Flush at least this often even if we haven't hit buffer limit 480 | {{ macros.config_row(config_graphite, 'batch-timeout', '# batch-timeout = "1s"', 0, true) }} 481 | 482 | # UDP Read buffer size, 0 means OS default. UDP listener will fail if set above OS max. 483 | {{ macros.config_row(config_graphite, 'udp-read-buffer', '# udp-read-buffer = 0', 0, true) }} 484 | 485 | ### This string joins multiple matching 'measurement' values providing more control over the final measurement name. 486 | {{ macros.config_row(config_graphite, 'separator', '# separator = "."', 0, true) }} 487 | 488 | ### Default tags that will be added to all metrics. These can be overridden at the template level 489 | ### or by tags extracted from metric 490 | {{ macros.config_row(config_graphite, 'tags', '# tags = ["region=us-east", "zone=1c"]', 0, true) }} 491 | 492 | ### Each template line requires a template pattern. It can have an optional 493 | ### filter before the template and separated by spaces. It can also have optional extra 494 | ### tags following the template. Multiple tags should be separated by commas and no spaces 495 | ### similar to the line protocol format. There can be only one default template. 496 | {{ macros.config_row(config_graphite, 'templates', '# templates = [ 497 | # "*.app env.service.resource.measurement", 498 | # # Default template 499 | # "server.*", 500 | # ]', 0, true) }} 501 | 502 | ### 503 | ### [collectd] 504 | ### 505 | ### Controls one or many listeners for collectd data. 506 | ### 507 | 508 | [[collectd]] 509 | {{ macros.config_row(config_collectd, 'enabled', '# enabled = false', 0, true) }} 510 | {{ macros.config_row(config_collectd, 'bind-address', '# bind-address = ":25826"', 0, true) }} 511 | {{ macros.config_row(config_collectd, 'database', '# database = "collectd"', 0, true) }} 512 | {{ macros.config_row(config_collectd, 'retention-policy', '# retention-policy = ""', 0, true) }} 513 | # 514 | # The collectd service supports either scanning a directory for multiple types 515 | # db files, or specifying a single db file. 516 | {{ macros.config_row(config_collectd, 'typesdb', '# typesdb = "/usr/local/share/collectd"', 0, true) }} 517 | # 518 | {{ macros.config_row(config_collectd, 'security-level', '# security-level = "none"', 0, true) }} 519 | {{ macros.config_row(config_collectd, 'auth-file', '# auth-file = "/etc/collectd/auth_file"', 0, true) }} 520 | 521 | # These next lines control how batching works. You should have this enabled 522 | # otherwise you could get dropped metrics or poor performance. Batching 523 | # will buffer points in memory if you have many coming in. 524 | 525 | # Flush if this many points get buffered 526 | {{ macros.config_row(config_collectd, 'batch-size', '# batch-size = 5000', 0, true) }} 527 | 528 | # Number of batches that may be pending in memory 529 | {{ macros.config_row(config_collectd, 'batch-pending', '# batch-pending = 10', 0, true) }} 530 | 531 | # Flush at least this often even if we haven't hit buffer limit 532 | {{ macros.config_row(config_collectd, 'batch-timeout', '# batch-timeout = "10s"', 0, true) }} 533 | 534 | # UDP Read buffer size, 0 means OS default. UDP listener will fail if set above OS max. 535 | {{ macros.config_row(config_collectd, 'read-buffer', '# read-buffer = 0', 0, true) }} 536 | 537 | # Multi-value plugins can be handled two ways. 538 | # "split" will parse and store the multi-value plugin data into separate measurements 539 | # "join" will parse and store the multi-value plugin as a single multi-value measurement. 540 | # "split" is the default behavior for backward compatibility with previous versions of influxdb. 541 | {{ macros.config_row(config_collectd, 'parse-multivalue-plugin', '# parse-multivalue-plugin = "split"', 0, true) }} 542 | ### 543 | ### [opentsdb] 544 | ### 545 | ### Controls one or many listeners for OpenTSDB data. 546 | ### 547 | 548 | [[opentsdb]] 549 | {{ macros.config_row(config_opentsdb, 'enabled', '# enabled = false', 0, true) }} 550 | {{ macros.config_row(config_opentsdb, 'bind-address', '# bind-address = ":4242"', 0, true) }} 551 | {{ macros.config_row(config_opentsdb, 'database', '# database = "opentsdb"', 0, true) }} 552 | {{ macros.config_row(config_opentsdb, 'retention-policy', '# retention-policy = ""', 0, true) }} 553 | {{ macros.config_row(config_opentsdb, 'consistency-level', '# consistency-level = "one"', 0, true) }} 554 | {{ macros.config_row(config_opentsdb, 'tls-enabled', '# tls-enabled = false', 0, true) }} 555 | {{ macros.config_row(config_opentsdb, 'certificate', '# certificate= "/etc/ssl/influxdb.pem"', 0, true) }} 556 | 557 | # Log an error for every malformed point. 558 | {{ macros.config_row(config_opentsdb, 'log-point-errors', '# log-point-errors = true', 0, true) }} 559 | 560 | # These next lines control how batching works. You should have this enabled 561 | # otherwise you could get dropped metrics or poor performance. Only points 562 | # metrics received over the telnet protocol undergo batching. 563 | 564 | # Flush if this many points get buffered 565 | {{ macros.config_row(config_opentsdb, 'batch-size', '# batch-size = 1000', 0, true) }} 566 | 567 | # Number of batches that may be pending in memory 568 | {{ macros.config_row(config_opentsdb, 'batch-pending', '# batch-pending = 5', 0, true) }} 569 | 570 | # Flush at least this often even if we haven't hit buffer limit 571 | {{ macros.config_row(config_opentsdb, 'batch-timeout', '# batch-timeout = "1s"', 0, true) }} 572 | 573 | ### 574 | ### [[udp]] 575 | ### 576 | ### Controls the listeners for InfluxDB line protocol data via UDP. 577 | ### 578 | 579 | [[udp]] 580 | {{ macros.config_row(config_udp, 'enabled', '# enabled = false', 0, true) }} 581 | {{ macros.config_row(config_udp, 'bind-address', '# bind-address = ":8089"', 0, true) }} 582 | {{ macros.config_row(config_udp, 'database', '# database = "udp"', 0, true) }} 583 | {{ macros.config_row(config_udp, 'retention-policy', '# retention-policy = ""', 0, true) }} 584 | 585 | # InfluxDB precision for timestamps on received points ("" or "n", "u", "ms", "s", "m", "h") 586 | {{ macros.config_row(config_udp, 'precision', '# precision = ""', 0, true) }} 587 | 588 | # These next lines control how batching works. You should have this enabled 589 | # otherwise you could get dropped metrics or poor performance. Batching 590 | # will buffer points in memory if you have many coming in. 591 | 592 | # Flush if this many points get buffered 593 | {{ macros.config_row(config_udp, 'batch-size', '# batch-size = 5000', 0, true) }} 594 | 595 | # Number of batches that may be pending in memory 596 | {{ macros.config_row(config_udp, 'batch-pending', '# batch-pending = 10', 0, true) }} 597 | 598 | # Will flush at least this often even if we haven't hit buffer limit 599 | {{ macros.config_row(config_udp, 'batch-timeout', '# batch-timeout = "1s"', 0, true) }} 600 | 601 | # UDP Read buffer size, 0 means OS default. UDP listener will fail if set above OS max. 602 | {{ macros.config_row(config_udp, 'read-buffer', '# read-buffer = 0', 0, true) }} 603 | 604 | ### 605 | ### [continuous_queries] 606 | ### 607 | ### Controls how continuous queries are run within InfluxDB. 608 | ### 609 | 610 | [continuous_queries] 611 | # Determines whether the continuous query service is enabled. 612 | {{ macros.config_row(config_continuous_queries, 'enabled', '# enabled = true', 0, true) }} 613 | 614 | # Controls whether queries are logged when executed by the CQ service. 615 | {{ macros.config_row(config_continuous_queries, 'log-enabled', '# log-enabled = true', 0, true) }} 616 | 617 | # Controls whether queries are logged to the self-monitoring data store. 618 | {{ macros.config_row(config_continuous_queries, 'query-stats-enabled', '# query-stats-enabled = false', 0, true) }} 619 | 620 | # interval for how often continuous queries will be checked if they need to run 621 | {{ macros.config_row(config_continuous_queries, 'run-interval', '# run-interval = "1s"', 0, true) }} 622 | 623 | ### 624 | ### [tls] 625 | ### 626 | ### Global configuration settings for TLS in InfluxDB. 627 | ### 628 | 629 | [tls] 630 | # Determines the available set of cipher suites. See https://golang.org/pkg/crypto/tls/#pkg-constants 631 | # for a list of available ciphers, which depends on the version of Go (use the query 632 | # SHOW DIAGNOSTICS to see the version of Go used to build InfluxDB). If not specified, uses 633 | # the default settings from Go's crypto/tls package. 634 | {{ macros.config_row(config_tls, 'ciphers', '# ciphers = [ 635 | # "TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305", 636 | # "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256", 637 | # ]', 0, true) }} 638 | 639 | # Minimum version of the tls protocol that will be negotiated. If not specified, uses the 640 | # default settings from Go's crypto/tls package. 641 | {{ macros.config_row(config_tls, 'min-version', '# min-version = "tls1.2"', 0, true) }} 642 | 643 | # Maximum version of the tls protocol that will be negotiated. If not specified, uses the 644 | # default settings from Go's crypto/tls package. 645 | {{ macros.config_row(config_tls, 'max-version', '# max-version = "tls1.2"', 0, true) }} 646 | 647 | {%- else -%} 648 | 649 | {{ config }} 650 | 651 | {%- endif -%} 652 | --------------------------------------------------------------------------------