community.general.influxdb_retention_policy (8.5.0) — module

Manage InfluxDB retention policies

Authors: Kamil Szczygiel (@kamsz)

Install collection

Install with ansible-galaxy collection install community.general:==8.5.0


Add to requirements.yml

  collections:
    - name: community.general
      version: 8.5.0

Description

Manage InfluxDB retention policies.


Requirements

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
# Example influxdb_retention_policy command from Ansible Playbooks
- name: Create 1 hour retention policy
  community.general.influxdb_retention_policy:
      hostname: "{{ influxdb_ip_address }}"
      database_name: "{{ influxdb_database_name }}"
      policy_name: test
      duration: 1h
      replication: 1
      ssl: true
      validate_certs: true
      state: present
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Create 1 day retention policy with 1 hour shard group duration
  community.general.influxdb_retention_policy:
      hostname: "{{ influxdb_ip_address }}"
      database_name: "{{ influxdb_database_name }}"
      policy_name: test
      duration: 1d
      replication: 1
      shard_group_duration: 1h
      state: present
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Create 1 week retention policy with 1 day shard group duration
  community.general.influxdb_retention_policy:
      hostname: "{{ influxdb_ip_address }}"
      database_name: "{{ influxdb_database_name }}"
      policy_name: test
      duration: 1w
      replication: 1
      shard_group_duration: 1d
      state: present
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Create infinite retention policy with 1 week of shard group duration
  community.general.influxdb_retention_policy:
      hostname: "{{ influxdb_ip_address }}"
      database_name: "{{ influxdb_database_name }}"
      policy_name: test
      duration: INF
      replication: 1
      ssl: false
      shard_group_duration: 1w
      state: present
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Create retention policy with complex durations
  community.general.influxdb_retention_policy:
      hostname: "{{ influxdb_ip_address }}"
      database_name: "{{ influxdb_database_name }}"
      policy_name: test
      duration: 5d1h30m
      replication: 1
      ssl: false
      shard_group_duration: 1d10h30m
      state: present
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Drop retention policy
  community.general.influxdb_retention_policy:
      hostname: "{{ influxdb_ip_address }}"
      database_name: "{{ influxdb_database_name }}"
      policy_name: test
      state: absent

Inputs

    
ssl:
    default: false
    description:
    - Use https instead of http to connect to InfluxDB server.
    type: bool

path:
    default: ''
    description:
    - The path on which InfluxDB server is accessible.
    - Only available when using python-influxdb >= 5.1.0.
    type: str
    version_added: 0.2.0
    version_added_collection: community.general

port:
    default: 8086
    description:
    - The port on which InfluxDB server is listening.
    type: int

state:
    choices:
    - absent
    - present
    default: present
    description:
    - State of the retention policy.
    type: str
    version_added: 3.1.0
    version_added_collection: community.general

default:
    default: false
    description:
    - Sets the retention policy as default retention policy.
    type: bool

proxies:
    default: {}
    description:
    - HTTP(S) proxy to use for Requests to connect to InfluxDB server.
    type: dict

retries:
    default: 3
    description:
    - Number of retries client will try before aborting.
    - V(0) indicates try until success.
    - Only available when using python-influxdb >= 4.1.0.
    type: int

timeout:
    description:
    - Number of seconds Requests will wait for client to establish a connection.
    type: int

use_udp:
    default: false
    description:
    - Use UDP to connect to InfluxDB server.
    type: bool

duration:
    description:
    - Determines how long InfluxDB should keep the data. If specified, it should be V(INF)
      or at least one hour. If not specified, V(INF) is assumed. Supports complex duration
      expressions with multiple units.
    - Required only if O(state) is set to V(present).
    type: str

hostname:
    default: localhost
    description:
    - The hostname or IP address on which InfluxDB server is listening.
    type: str

password:
    aliases:
    - login_password
    default: root
    description:
    - Password that will be used to authenticate against InfluxDB server.
    type: str

udp_port:
    default: 4444
    description:
    - UDP port to connect to InfluxDB server.
    type: int

username:
    aliases:
    - login_username
    default: root
    description:
    - Username that will be used to authenticate against InfluxDB server.
    type: str

policy_name:
    description:
    - Name of the retention policy.
    required: true
    type: str

replication:
    description:
    - Determines how many independent copies of each point are stored in the cluster.
    - Required only if O(state) is set to V(present).
    type: int

database_name:
    description:
    - Name of the database.
    required: true
    type: str

validate_certs:
    default: true
    description:
    - If set to V(false), the SSL certificates will not be validated.
    - This should only set to V(false) used on personally controlled sites using self-signed
      certificates.
    type: bool

shard_group_duration:
    description:
    - Determines the time range covered by a shard group. If specified it must be at least
      one hour. If none, it's determined by InfluxDB by the rentention policy's duration.
      Supports complex duration expressions with multiple units.
    type: str
    version_added: 2.0.0
    version_added_collection: community.general