Vendor Galaxy Roles and Collections
This commit is contained in:
parent
c1e1897cda
commit
2aed20393f
3553 changed files with 387444 additions and 2 deletions
|
|
@ -0,0 +1,21 @@
|
|||
debops.influxdb_server - Manage InfluxDB service using Ansible
|
||||
|
||||
Copyright (C) 2020 Pedro Luis Lopez <pedroluis.lopezsanchez@gmail.com>
|
||||
Copyright (C) 2020 Innobyte Bechea Leonardo <https://www.innobyte.com/>
|
||||
Copyright (C) 2020 Innobyte Alin Alexandru <https://www.innobyte.com/>
|
||||
Copyright (C) 2020 DebOps <https://debops.org/>
|
||||
SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
This repository is part of DebOps.
|
||||
|
||||
DebOps is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License version 3, as
|
||||
published by the Free Software Foundation.
|
||||
|
||||
DebOps is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with DebOps. If not, see https://www.gnu.org/licenses/.
|
||||
|
|
@ -0,0 +1,375 @@
|
|||
---
|
||||
# .. vim: foldmarker=[[[,]]]:foldmethod=marker
|
||||
|
||||
# .. Copyright (C) 2020 Pedro Luis Lopez <pedroluis.lopezsanchez@gmail.com>
|
||||
# .. Copyright (C) 2020 Innobyte Bechea Leonardo <https://www.innobyte.com/>
|
||||
# .. Copyright (C) 2020 Innobyte Alin Alexandru <https://www.innobyte.com/>
|
||||
# .. Copyright (C) 2020 DebOps <https://debops.org/>
|
||||
# .. SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
# .. _influxdb_server__ref_defaults:
|
||||
|
||||
# debops.influxdb_server default variables
|
||||
# ========================================
|
||||
|
||||
# .. contents:: Sections
|
||||
# :local:
|
||||
#
|
||||
# .. include:: ../../../../includes/global.rst
|
||||
|
||||
|
||||
# APT packages [[[
|
||||
# -------------------------------
|
||||
|
||||
# .. envvar:: influxdb_server__base_packages [[[
|
||||
#
|
||||
# List of the default APT packages to install for InfluxDB Server support.
|
||||
influxdb_server__base_packages: [ 'influxdb' ]
|
||||
|
||||
# ]]]
|
||||
# .. envvar:: influxdb_server__packages [[[
|
||||
#
|
||||
# List of additional APT packages to install with InfluxDB Server.
|
||||
influxdb_server__packages: []
|
||||
|
||||
# ]]]
|
||||
# ]]]
|
||||
# Basic configuration [[[
|
||||
# -----------------------
|
||||
|
||||
# .. envvar:: influxdb_server__allow [[[
|
||||
#
|
||||
# List of IP addresses or CIDR subnets which will be permitted to access the
|
||||
# InfluxDB server API. If the list is empty, nobody can access the service.
|
||||
influxdb_server__allow: []
|
||||
|
||||
# ]]]
|
||||
# .. envvar:: influxdb_server__bind [[[
|
||||
#
|
||||
# The ip address on which this InfluxDB listens on.
|
||||
# Leave empty to bind on all interfaces.
|
||||
influxdb_server__bind: ''
|
||||
|
||||
# ]]]
|
||||
# .. envvar:: influxdb_server__port [[[
|
||||
#
|
||||
# Port number on which this InfluxDB listens on.
|
||||
influxdb_server__port: '8086'
|
||||
|
||||
# ]]]
|
||||
# .. envvar:: influxdb_server__rpc_allow [[[
|
||||
#
|
||||
# List of IP addresses or CIDR subnets which will be permitted to access the
|
||||
# InfluxDB RPC. If the list is empty, nobody can access the service.
|
||||
influxdb_server__rpc_allow: []
|
||||
|
||||
# ]]]
|
||||
# .. envvar:: influxdb_server__rpc_bind [[[
|
||||
#
|
||||
# The ip address used by the RPC service for RPC calls made by the CLI for backup and restore operations.
|
||||
# Leave empty to bind on all interfaces.
|
||||
influxdb_server__rpc_bind: '127.0.0.1'
|
||||
|
||||
# ]]]
|
||||
# .. envvar:: influxdb_server__rpc_port [[[
|
||||
#
|
||||
# Port number used by the RPC service for RPC calls made by the CLI for backup and restore operations.
|
||||
influxdb_server__rpc_port: '8088'
|
||||
|
||||
# ]]]
|
||||
# .. envvar:: influxdb_server__default_directory [[[
|
||||
#
|
||||
# Default directory root for InfluxDB server.
|
||||
influxdb_server__default_directory: '/var/lib/influxdb'
|
||||
|
||||
# ]]]
|
||||
# .. envvar:: influxdb_server__directory [[[
|
||||
#
|
||||
# The directory root for InfluxDB server.
|
||||
influxdb_server__directory: '{{ influxdb_server__default_directory }}'
|
||||
|
||||
# ]]]
|
||||
# .. envvar:: influxdb_server__delegate_to [[[
|
||||
#
|
||||
# Inventory hostname of the server to which Ansible roles will delegate tasks.
|
||||
# Using a FQDN hostname known to Ansible. Defaults to `inventory_hostname`.
|
||||
influxdb_server__delegate_to: '{{ inventory_hostname }}'
|
||||
|
||||
# ]]]
|
||||
# ]]]
|
||||
# InfluxDB configuration file [[[
|
||||
# -------------------------------
|
||||
|
||||
# The variables below define the contents of the
|
||||
# :file:`/etc/influxdb/influxdb.conf` configuration file.
|
||||
|
||||
# .. envvar:: influxdb_server__default_configuration [[[
|
||||
#
|
||||
# The default configuration options which should be present in the main
|
||||
# configuration file.
|
||||
influxdb_server__default_configuration:
|
||||
|
||||
- name: 'global'
|
||||
options:
|
||||
- reporting-disabled: 'true'
|
||||
- bind-address: '"{{ influxdb_server__rpc_bind }}:{{ influxdb_server__rpc_port }}"'
|
||||
|
||||
- name: 'meta'
|
||||
options:
|
||||
- dir: '"{{ influxdb_server__directory }}/meta"'
|
||||
|
||||
- name: 'data'
|
||||
options:
|
||||
- dir: '"{{ influxdb_server__directory }}/data"'
|
||||
- wal-dir: '"{{ influxdb_server__directory }}/wal"'
|
||||
|
||||
- name: 'coordinator'
|
||||
options: []
|
||||
|
||||
- name: 'retention'
|
||||
options: []
|
||||
|
||||
- name: 'shard-precreation'
|
||||
options: []
|
||||
|
||||
- name: 'monitor'
|
||||
options: []
|
||||
|
||||
- name: 'http'
|
||||
options:
|
||||
- bind-address: '"{{ influxdb_server__bind }}:{{ influxdb_server__port }}"'
|
||||
- https-enabled: '{{ "true" if influxdb_server__pki else "false" }}'
|
||||
- auth-enabled: 'true'
|
||||
|
||||
- name: 'logging'
|
||||
options: []
|
||||
|
||||
- name: 'subscriber'
|
||||
options: []
|
||||
|
||||
- name: 'graphite'
|
||||
options: []
|
||||
|
||||
- name: 'collectd'
|
||||
options: []
|
||||
|
||||
- name: 'opentsdb'
|
||||
options: []
|
||||
|
||||
- name: 'udp'
|
||||
options: []
|
||||
|
||||
- name: 'continuous_queries'
|
||||
options: []
|
||||
|
||||
- name: 'tls'
|
||||
options:
|
||||
- min-version: '"tls1.2"'
|
||||
|
||||
# ]]]
|
||||
# .. envvar:: influxdb_server__configuration [[[
|
||||
#
|
||||
# List of configuration options defined on all hosts in the InfluxDB inventory.
|
||||
influxdb_server__configuration: []
|
||||
|
||||
# ]]]
|
||||
# .. envvar:: influxdb_server__combined_configuration [[[
|
||||
#
|
||||
# Actual list of InfluxDB configuration options passed to the
|
||||
# configuration template. This list defines the order in which the options from
|
||||
# different variables are processed.
|
||||
influxdb_server__combined_configuration: '{{ influxdb_server__default_configuration +
|
||||
influxdb_server__configuration +
|
||||
influxdb_server__pki_options }}'
|
||||
|
||||
# ]]]
|
||||
# ]]]
|
||||
# SSL configuration [[[
|
||||
# ---------------------
|
||||
|
||||
# .. envvar:: influxdb_server__append_groups [[[
|
||||
#
|
||||
# List of additional system groups to append to the InfluxDB system user.
|
||||
# ``ssl-cert`` group is required for access to certificate private keys.
|
||||
influxdb_server__append_groups: [ 'ssl-cert' ]
|
||||
|
||||
# ]]]
|
||||
# .. envvar:: influxdb__pki_options [[[
|
||||
#
|
||||
# Configuration of SSL support in :program:`influxdb`, managed by :ref:`debops.pki` role.
|
||||
influxdb_server__pki_options:
|
||||
|
||||
- name: 'http'
|
||||
state: '{{ "present" if influxdb_server__pki | bool else "absent" }}'
|
||||
options:
|
||||
- https-certificate: '"{{ influxdb_server__pki_path + "/" + influxdb_server__pki_realm +
|
||||
"/" + influxdb_server__pki_crt }}"'
|
||||
- https-private-key: '"{{ influxdb_server__pki_path + "/" + influxdb_server__pki_realm +
|
||||
"/" + influxdb_server__pki_key }}"'
|
||||
|
||||
- name: 'subscriber'
|
||||
state: '{{ "present" if influxdb_server__pki | bool else "absent" }}'
|
||||
options:
|
||||
- ca-certs: '"{{ influxdb_server__pki_path + "/" + influxdb_server__pki_realm +
|
||||
"/" + influxdb_server__pki_ca }}"'
|
||||
|
||||
# ]]]
|
||||
# .. envvar:: influxdb_server__pki [[[
|
||||
#
|
||||
# Enable or disable support for SSL in InfluxDB (using :ref:`debops.pki`).
|
||||
influxdb_server__pki: '{{ True
|
||||
if (ansible_local.pki.enabled | d() | bool and
|
||||
influxdb_server__pki_realm in ansible_local.pki.known_realms)
|
||||
else False }}'
|
||||
|
||||
# ]]]
|
||||
# .. envvar:: influxdb_server__pki_path [[[
|
||||
#
|
||||
# Base path for PKI directory.
|
||||
influxdb_server__pki_path: '{{ ansible_local.pki.base_path | d("/etc/pki") }}'
|
||||
|
||||
# ]]]
|
||||
# .. envvar:: influxdb_server__pki_realm [[[
|
||||
#
|
||||
# Default PKI realm used by InfluxDB server.
|
||||
influxdb_server__pki_realm: '{{ ansible_local.pki.realm | d("domain") }}'
|
||||
|
||||
# ]]]
|
||||
# .. envvar:: influxdb_server__pki_ca [[[
|
||||
#
|
||||
# Root CA certificate used by InfluxDB, relative to :envvar:`influxdb_server__pki_realm`.
|
||||
influxdb_server__pki_ca: 'CA.crt'
|
||||
|
||||
# ]]]
|
||||
# .. envvar:: influxdb_server__pki_crt [[[
|
||||
#
|
||||
# Host certificate used by InfluxDB, relative to :envvar:`influxdb_server__pki_realm`.
|
||||
influxdb_server__pki_crt: 'default.crt'
|
||||
|
||||
# ]]]
|
||||
# .. envvar:: influxdb_server__pki_key [[[
|
||||
#
|
||||
# Host private key used by InfluxDB, relative to :envvar:`influxdb_server__pki_realm`.
|
||||
influxdb_server__pki_key: 'default.key'
|
||||
|
||||
# ]]]
|
||||
# ]]]
|
||||
# Default root account [[[
|
||||
# ----------------------------
|
||||
|
||||
# .. envvar:: influxdb_server__password_length [[[
|
||||
#
|
||||
# Length of automatically generated user accounts, saved in the ``secret/``
|
||||
# directory. See :ref:`debops.secret` role for more details about passwords.
|
||||
influxdb_server__password_length: '48'
|
||||
|
||||
# ]]]
|
||||
# .. envvar:: influxdb_server__root_password [[[
|
||||
#
|
||||
# Password for default root admin user.
|
||||
influxdb_server__root_password: '{{ lookup("password", secret + "/influxdb/" + ansible_fqdn +
|
||||
"/credentials/root/password " +
|
||||
"length=" + influxdb_server__password_length) }}'
|
||||
|
||||
# ]]]
|
||||
# ]]]
|
||||
# AutoInfluxDBBackup configuration [[[
|
||||
# ---------------------------------
|
||||
|
||||
# .. envvar:: influxdb_server__backup [[[
|
||||
#
|
||||
# Enable or disable support for daily, weekly and monthly snapshots of the
|
||||
# database using :program:`autoinfluxdbbackup`.
|
||||
influxdb_server__backup: True
|
||||
|
||||
# ]]]
|
||||
# .. envvar:: influxdb_server__backup_mailaddr [[[
|
||||
#
|
||||
# Mail address to send messages to (account or alias name will be properly
|
||||
# routed by the Postfix SMTP server).
|
||||
influxdb_server__backup_mailaddr: 'backup@{{ ansible_domain }}'
|
||||
|
||||
# ]]]
|
||||
# .. envvar:: influxdb_server__backup_doweekly [[[
|
||||
#
|
||||
# Specify the day of the week to create weekly backups
|
||||
# (1 - Monday, 7 - Sunday).
|
||||
influxdb_server__backup_doweekly: '6'
|
||||
|
||||
# ]]]
|
||||
# .. envvar:: influxdb_server__backup_latest [[[
|
||||
#
|
||||
# Don't keep copies of most recent backups by default.
|
||||
influxdb_server__backup_latest: 'no'
|
||||
|
||||
# ]]]
|
||||
# .. envvar:: influxdb_server__backup_directory [[[
|
||||
#
|
||||
# Base directory where :program:`autoinfluxdbbackup` stores the database backups.
|
||||
# The directory will be created automatically by :program:`autoinfluxdbbackup`, if it
|
||||
# does not exist.
|
||||
influxdb_server__backup_directory: '/var/lib/autoinfluxdbbackup'
|
||||
|
||||
# ]]]
|
||||
# ]]]
|
||||
# Configuration for other Ansible roles [[[
|
||||
# -----------------------------------------
|
||||
|
||||
# .. envvar:: influxdb_server__influxdata__dependent_packages [[[
|
||||
#
|
||||
# Configuration for the :ref:`debops.influxdata` Ansible role.
|
||||
influxdb_server__influxdata__dependent_packages:
|
||||
- '{{ influxdb_server__base_packages }}'
|
||||
- '{{ influxdb_server__packages }}'
|
||||
|
||||
# ]]]
|
||||
# .. envvar:: influxdb_server__ferm__dependent_rules [[[
|
||||
#
|
||||
# Configuration for the :ref:`debops.ferm` Ansible role.
|
||||
influxdb_server__ferm__dependent_rules:
|
||||
|
||||
- name: 'influxdb_http'
|
||||
type: 'accept'
|
||||
saddr: '{{ influxdb_server__allow }}'
|
||||
dport: [ 'influxdb-http' ]
|
||||
accept_any: False
|
||||
role: 'influxdb_server'
|
||||
|
||||
- name: 'influxdb_rpc'
|
||||
type: 'accept'
|
||||
saddr: '{{ influxdb_server__rpc_allow }}'
|
||||
dport: [ 'influxdb-rpc' ]
|
||||
accept_any: False
|
||||
role: 'influxdb_server'
|
||||
state: '{{ "absent" if influxdb_server__rpc_bind == "127.0.0.1" else "present" }}'
|
||||
|
||||
# ]]]
|
||||
# .. envvar:: influxdb_server__etc_services__dependent_list [[[
|
||||
#
|
||||
# Configuration for the :ref:`debops.etc_services` Ansible role.
|
||||
influxdb_server__etc_services__dependent_list:
|
||||
|
||||
- name: 'influxdb-http'
|
||||
port: '{{ influxdb_server__port }}'
|
||||
|
||||
- name: 'influxdb-rpc'
|
||||
port: '{{ influxdb_server__rpc_port }}'
|
||||
state: '{{ "absent" if influxdb_server__rpc_bind == "127.0.0.1" else "present" }}'
|
||||
|
||||
# ]]]
|
||||
# .. envvar:: influxdb_server__python__dependent_packages3 [[[
|
||||
#
|
||||
# Configuration for the :ref:`debops.python` Ansible role.
|
||||
influxdb_server__python__dependent_packages3:
|
||||
|
||||
- 'python3-influxdb'
|
||||
|
||||
# ]]]
|
||||
# .. envvar:: influxdb_server__python__dependent_packages2 [[[
|
||||
#
|
||||
# Configuration for the :ref:`debops.python` Ansible role.
|
||||
influxdb_server__python__dependent_packages2:
|
||||
|
||||
- 'python-influxdb'
|
||||
# ]]]
|
||||
# ]]]
|
||||
|
|
@ -0,0 +1,481 @@
|
|||
#!/bin/bash
|
||||
set -o pipefail -o errexit
|
||||
|
||||
# Copyright (C) 2020 Pedro Luis Lopez <pedroluis.lopezsanchez@gmail.com>
|
||||
# Copyright (C) 2020 Innobyte Bechea Leonardo <https://www.innobyte.com/>
|
||||
# Copyright (C) 2020 Innobyte Alin Alexandru <https://www.innobyte.com/>
|
||||
# Copyright (C) 2020 DebOps <https://debops.org/>
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
# This file is managed remotely, all changes will be lost
|
||||
|
||||
#
|
||||
# InfluxDB Backup Script
|
||||
# VER. 0.1
|
||||
|
||||
# Note, this is a lobotomized port of AutoMySQLBackup
|
||||
# (https://sourceforge.net/projects/automysqlbackup/) for use with
|
||||
# InfluxDB.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
#
|
||||
#=====================================================================
|
||||
#=====================================================================
|
||||
# Set the following variables to your system needs
|
||||
# (Detailed instructions below variables)
|
||||
#=====================================================================
|
||||
|
||||
# Database name to specify a specific database only e.g. myawesomeapp
|
||||
# Unnecessary if backup all databases
|
||||
# DBNAME=""
|
||||
|
||||
# Host name (or IP address) of influxdb server e.g localhost
|
||||
DBHOST="127.0.0.1"
|
||||
|
||||
# Port that influxdb is listening on
|
||||
DBPORT="8088"
|
||||
|
||||
# Backup directory location e.g /backups
|
||||
BACKUPDIR="/var/backups/influxdb"
|
||||
|
||||
# Mail setup
|
||||
# What would you like to be mailed to you?
|
||||
# - log : send only log file
|
||||
# - files : send log file and sql files as attachments (see docs)
|
||||
# - stdout : will simply output the log to the screen if run manually.
|
||||
# - quiet : Only send logs if an error occurs to the MAILADDR.
|
||||
MAILCONTENT="stdout"
|
||||
|
||||
# Set the maximum allowed email size in k. (4000 = approx 5MB email [see docs])
|
||||
export MAXATTSIZE="4000"
|
||||
|
||||
# Email Address to send mail to? (user@domain.com)
|
||||
# MAILADDR=""
|
||||
|
||||
# ============================================================================
|
||||
# === SCHEDULING AND RETENTION OPTIONS ( Read the doc's below for details )===
|
||||
#=============================================================================
|
||||
|
||||
# Do you want to do hourly backups? How long do you want to keep them?
|
||||
DOHOURLY="no"
|
||||
HOURLYRETENTION=24
|
||||
|
||||
# Do you want to do daily backups? How long do you want to keep them?
|
||||
DODAILY="yes"
|
||||
DAILYRETENTION=0
|
||||
|
||||
# Which day do you want weekly backups? (1 to 7 where 1 is Monday)
|
||||
DOWEEKLY="yes"
|
||||
WEEKLYDAY=6
|
||||
WEEKLYRETENTION=4
|
||||
|
||||
# Do you want monthly backups? How long do you want to keep them?
|
||||
DOMONTHLY="yes"
|
||||
MONTHLYRETENTION=4
|
||||
|
||||
# ============================================================
|
||||
# === ADVANCED OPTIONS ( Read the doc's below for details )===
|
||||
#=============================================================
|
||||
|
||||
# Choose Compression type. (gzip or bzip2)
|
||||
COMP="gzip"
|
||||
|
||||
# Choose if the uncompressed folder should be deleted after compression has completed
|
||||
CLEANUP="yes"
|
||||
|
||||
# Additionally keep a copy of the most recent backup in a separate directory.
|
||||
LATEST="yes"
|
||||
|
||||
# Make Hardlink not a copy
|
||||
LATESTLINK="yes"
|
||||
|
||||
# Maximum files of a single backup used by split - leave empty if no split required
|
||||
# MAXFILESIZE=""
|
||||
|
||||
# Command to run before backups (uncomment to use)
|
||||
# PREBACKUP=""
|
||||
|
||||
# Command run after backups (uncomment to use)
|
||||
# POSTBACKUP=""
|
||||
|
||||
#=====================================================================
|
||||
# Options documentation
|
||||
#=====================================================================
|
||||
# Set the DBHOST option to the server you wish to backup, leave the
|
||||
# default to backup "this server".(to backup multiple servers make
|
||||
# copies of this file and set the options for that server)
|
||||
#
|
||||
# You can change the backup storage location from /backups to anything
|
||||
# you like by using the BACKUPDIR setting..
|
||||
#
|
||||
# The MAILCONTENT and MAILADDR options and pretty self explanatory, use
|
||||
# these to have the backup log mailed to you at any email address or multiple
|
||||
# email addresses in a space separated list.
|
||||
#
|
||||
# (If you set mail content to "log" you will require access to the "mail" program
|
||||
# on your server. If you set this to "files" you will have to have mutt installed
|
||||
# on your server. If you set it to "stdout" it will log to the screen if run from
|
||||
# the console or to the cron job owner if run through cron. If you set it to "quiet"
|
||||
# logs will only be mailed if there are errors reported. )
|
||||
#
|
||||
#
|
||||
# Finally copy autoinfluxdbbackup to anywhere on your server and make sure
|
||||
# to set executable permission. You can also copy the script to
|
||||
# /etc/cron.daily to have it execute automatically every night or simply
|
||||
# place a symlink in /etc/cron.daily to the file if you wish to keep it
|
||||
# somewhere else.
|
||||
#
|
||||
# NOTE: On Debian copy the file with no extension for it to be run
|
||||
# by cron e.g just name the file "autoinfluxdbbackup"
|
||||
#
|
||||
# That's it..
|
||||
#
|
||||
#
|
||||
# === Advanced options ===
|
||||
#
|
||||
# To set the day of the week that you would like the weekly backup to happen
|
||||
# set the WEEKLYDAY setting, this can be a value from 1 to 7 where 1 is Monday,
|
||||
# The default is 6 which means that weekly backups are done on a Saturday.
|
||||
#
|
||||
# Use PREBACKUP and POSTBACKUP to specify Pre and Post backup commands
|
||||
# or scripts to perform tasks either before or after the backup process.
|
||||
#
|
||||
#
|
||||
#=====================================================================
|
||||
# Backup Rotation..
|
||||
#=====================================================================
|
||||
#
|
||||
# Hourly backups are executed if DOHOURLY is set to "yes".
|
||||
# The number of hours backup copies to keep for each day (i.e. 'Monday', 'Tuesday', etc.) is set with DHOURLYRETENTION.
|
||||
# DHOURLYRETENTION=0 rotates hourly backups every day (i.e. only the most recent hourly copy is kept). -1 disables rotation.
|
||||
#
|
||||
# Daily backups are executed if DODAILY is set to "yes".
|
||||
# The number of daily backup copies to keep for each day (i.e. 'Monday', 'Tuesday', etc.) is set with DAILYRETENTION.
|
||||
# DAILYRETENTION=0 rotates daily backups every week (i.e. only the most recent daily copy is kept). -1 disables rotation.
|
||||
#
|
||||
# Weekly backups are executed if DOWEEKLY is set to "yes".
|
||||
# WEEKLYDAY [1-7] sets which day a weekly backup occurs when cron.daily scripts are run.
|
||||
# Rotate weekly copies after the number of weeks set by WEEKLYRETENTION.
|
||||
# WEEKLYRETENTION=0 rotates weekly backups every week. -1 disables rotation.
|
||||
#
|
||||
# Monthly backups are executed if DOMONTHLY is set to "yes".
|
||||
# Monthly backups occur on the first day of each month when cron.daily scripts are run.
|
||||
# Rotate monthly backups after the number of months set by MONTHLYRETENTION.
|
||||
# MONTHLYRETENTION=0 rotates monthly backups upon each execution. -1 disables rotation.
|
||||
#
|
||||
#=====================================================================
|
||||
# Please Note!!
|
||||
#=====================================================================
|
||||
#
|
||||
# I take no responsibility for any data loss or corruption when using
|
||||
# this script.
|
||||
#
|
||||
# This script will not help in the event of a hard drive crash. You
|
||||
# should copy your backups offline or to another PC for best protection.
|
||||
#
|
||||
# Happy backing up!
|
||||
#
|
||||
#=====================================================================
|
||||
# Restoring
|
||||
#=====================================================================
|
||||
# ???
|
||||
#
|
||||
#=====================================================================
|
||||
# Change Log
|
||||
#=====================================================================
|
||||
# VER 0.1 - (2020-03-01)
|
||||
# - Initial Release
|
||||
#
|
||||
#=====================================================================
|
||||
#=====================================================================
|
||||
#=====================================================================
|
||||
#
|
||||
# Should not need to be modified from here down!!
|
||||
#
|
||||
#=====================================================================
|
||||
#=====================================================================
|
||||
#=====================================================================
|
||||
|
||||
shellout () {
|
||||
if [ -n "$1" ]; then
|
||||
echo "$1"
|
||||
exit 1
|
||||
fi
|
||||
exit 0
|
||||
}
|
||||
|
||||
# External config - override default values set above
|
||||
for x in default sysconfig; do
|
||||
if [ -f "/etc/$x/autoinfluxdbbackup" ]; then
|
||||
# shellcheck source=/dev/null
|
||||
source /etc/$x/autoinfluxdbbackup
|
||||
fi
|
||||
done
|
||||
|
||||
# Include extra config file if specified on commandline, e.g. for backuping several remote dbs from central server
|
||||
# shellcheck source=/dev/null
|
||||
[ -n "$1" ] && [ -f "$1" ] && source "${1}"
|
||||
|
||||
#=====================================================================
|
||||
|
||||
PATH=/usr/local/bin:/usr/bin:/bin
|
||||
DATE=$(date +%Y-%m-%d_%Hh%Mm) # Datestamp e.g 2002-09-21
|
||||
HOD=$(date +%s) # Current timestamp for PITR backup
|
||||
DOW=$(date +%A) # Day of the week e.g. Monday
|
||||
DNOW=$(date +%u) # Day number of the week 1 to 7 where 1 represents Monday
|
||||
DOM=$(date +%d) # Date of the Month e.g. 27
|
||||
M=$(date +%B) # Month e.g January
|
||||
W=$(date +%V) # Week Number e.g 37
|
||||
VER=0.1 # Version Number
|
||||
LOGFILE=$BACKUPDIR/$DBHOST-$(date +%H%M).log # Logfile Name
|
||||
LOGERR=$BACKUPDIR/ERRORS_$DBHOST-$(date +%H%M).log # Logfile Name
|
||||
OPT="" # OPT string for use with influxd backup
|
||||
|
||||
# Do we need to backup only a specific database?
|
||||
if [ "$DBNAME" ]; then
|
||||
OPT="$OPT -database $DBNAME"
|
||||
fi
|
||||
|
||||
# Create required directories
|
||||
mkdir -p $BACKUPDIR/{hourly,daily,weekly,monthly,tmp} || shellout 'failed to create directories'
|
||||
|
||||
if [ "$LATEST" = "yes" ]; then
|
||||
rm -rf "$BACKUPDIR/latest"
|
||||
mkdir -p "$BACKUPDIR/latest" || shellout 'failed to create directory'
|
||||
fi
|
||||
|
||||
# IO redirection for logging.
|
||||
touch "$LOGFILE"
|
||||
exec 6>&1 # Link file descriptor #6 with stdout.
|
||||
# Saves stdout.
|
||||
exec > "$LOGFILE" # stdout replaced with file $LOGFILE.
|
||||
|
||||
touch "$LOGERR"
|
||||
exec 7>&2 # Link file descriptor #7 with stderr.
|
||||
# Saves stderr.
|
||||
exec 2> "$LOGERR" # stderr replaced with file $LOGERR.
|
||||
|
||||
# When a desire is to receive log via e-mail then we close stdout and stderr.
|
||||
[ "$MAILCONTENT" == "log" ] && exec 6>&- 7>&-
|
||||
|
||||
# Functions
|
||||
|
||||
# Database dump function
|
||||
dbdump () {
|
||||
COMMAND="influxd backup -portable -host $DBHOST:$DBPORT $OPT $BACKUPDIR/tmp"
|
||||
$COMMAND
|
||||
INFLUXDBBACKUPSTATUS=$?
|
||||
if [ $INFLUXDBBACKUPSTATUS -ne 0 ]; then
|
||||
echo "ERROR: influxd backup failed: $1" >&2
|
||||
return 1
|
||||
fi
|
||||
echo Tar backup to "$1"
|
||||
cd "$BACKUPDIR/tmp" || return 1
|
||||
tar cf "$1" -- *
|
||||
cd - >/dev/null || return 1
|
||||
echo Cleaning up folder at "$BACKUPDIR/tmp"
|
||||
rm "$BACKUPDIR/tmp/"*
|
||||
[ -e "$1" ] && return 0
|
||||
echo "ERROR: influxd backup failed to create backup: $1" >&2
|
||||
return 1
|
||||
}
|
||||
|
||||
if [ -n "$MAXFILESIZE" ]; then
|
||||
write_file() {
|
||||
split --bytes "$MAXFILESIZE" --numeric-suffixes - "${1}-"
|
||||
}
|
||||
else
|
||||
write_file() {
|
||||
cat > "$1"
|
||||
}
|
||||
fi
|
||||
|
||||
# Compression function plus latest copy
|
||||
compression () {
|
||||
SUFFIX=""
|
||||
dir=$(dirname "$1")
|
||||
file=$(basename "$1")
|
||||
if [ -n "$COMP" ]; then
|
||||
[ "$COMP" = "gzip" ] && SUFFIX=".tgz"
|
||||
[ "$COMP" = "bzip2" ] && SUFFIX=".tar.bz2"
|
||||
echo Tar and $COMP to "$file$SUFFIX"
|
||||
cd "$dir" || return 1
|
||||
tar -cf - "$file" | $COMP --stdout | write_file "${file}${SUFFIX}"
|
||||
cd - >/dev/null || return 1
|
||||
else
|
||||
echo "No compression option set, check advanced settings"
|
||||
fi
|
||||
|
||||
if [ "$LATEST" = "yes" ]; then
|
||||
if [ "$LATESTLINK" = "yes" ];then
|
||||
COPY="ln"
|
||||
else
|
||||
COPY="cp"
|
||||
fi
|
||||
$COPY "$1$SUFFIX" "$BACKUPDIR/latest/"
|
||||
fi
|
||||
|
||||
if [ "$CLEANUP" = "yes" ]; then
|
||||
echo Cleaning up folder at "$1"
|
||||
rm -rf "$1"
|
||||
fi
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
# Run command before we begin
|
||||
if [ "$PREBACKUP" ]; then
|
||||
echo ======================================================================
|
||||
echo "Prebackup command output."
|
||||
echo
|
||||
eval "$PREBACKUP"
|
||||
echo
|
||||
echo ======================================================================
|
||||
echo
|
||||
fi
|
||||
|
||||
echo ======================================================================
|
||||
echo AutoInfluxDBBackup VER $VER
|
||||
|
||||
echo
|
||||
echo "Backup of Database Server - $DBHOST"
|
||||
echo ======================================================================
|
||||
|
||||
echo "Backup Start $(date)"
|
||||
echo ======================================================================
|
||||
# Monthly Full Backup of all Databases
|
||||
if [[ $DOM = "01" ]] && [[ $DOMONTHLY = "yes" ]]; then
|
||||
echo Monthly Full Backup
|
||||
echo
|
||||
# Delete old monthly backups while respecting the set retention policy.
|
||||
if [[ $MONTHLYRETENTION -ge 0 ]] ; then
|
||||
NUM_OLD_FILES=$(find $BACKUPDIR/monthly -depth -not -newermt "$MONTHLYRETENTION month ago" -type f | wc -l)
|
||||
if [[ $NUM_OLD_FILES -gt 0 ]] ; then
|
||||
echo Deleting "$NUM_OLD_FILES" global setting backup file\(s\) older than "$MONTHLYRETENTION" month\(s\) old.
|
||||
find $BACKUPDIR/monthly -not -newermt "$MONTHLYRETENTION month ago" -type f -delete
|
||||
fi
|
||||
fi
|
||||
FILE="$BACKUPDIR/monthly/$DATE.$M"
|
||||
|
||||
# Weekly Backup
|
||||
elif [[ "$DNOW" = "$WEEKLYDAY" ]] && [[ "$DOWEEKLY" = "yes" ]] ; then
|
||||
echo Weekly Backup
|
||||
echo
|
||||
if [[ $WEEKLYRETENTION -ge 0 ]] ; then
|
||||
# Delete old weekly backups while respecting the set retention policy.
|
||||
NUM_OLD_FILES=$(find $BACKUPDIR/weekly -depth -not -newermt "$WEEKLYRETENTION week ago" -type f | wc -l)
|
||||
if [[ $NUM_OLD_FILES -gt 0 ]] ; then
|
||||
echo Deleting "$NUM_OLD_FILES" global setting backup file\(s\) older than "$WEEKLYRETENTION" week\(s\) old.
|
||||
find $BACKUPDIR/weekly -not -newermt "$WEEKLYRETENTION week ago" -type f -delete
|
||||
fi
|
||||
fi
|
||||
FILE="$BACKUPDIR/weekly/week.$W.$DATE"
|
||||
OPT="$OPT -since $(date -u --date='7 days ago' +'%Y-%m-%dT%H:00:00Z')"
|
||||
|
||||
# Daily Backup
|
||||
elif [[ $DODAILY = "yes" ]] ; then
|
||||
echo Daily Backup of Databases
|
||||
echo
|
||||
# Delete old daily backups while respecting the set retention policy.
|
||||
if [[ $DAILYRETENTION -ge 0 ]] ; then
|
||||
NUM_OLD_FILES=$(find $BACKUPDIR/daily -depth -not -newermt "$DAILYRETENTION days ago" -type f | wc -l)
|
||||
if [[ $NUM_OLD_FILES -gt 0 ]] ; then
|
||||
echo Deleting "$NUM_OLD_FILES" global setting backup file\(s\) made in previous weeks.
|
||||
find "$BACKUPDIR/daily" -not -newermt "$DAILYRETENTION days ago" -type f -delete
|
||||
fi
|
||||
fi
|
||||
FILE="$BACKUPDIR/daily/$DATE.$DOW"
|
||||
OPT="$OPT -since $(date -u --date='1 day ago' +'%Y-%m-%dT%H:00:00Z')"
|
||||
|
||||
# Hourly Backup
|
||||
elif [[ $DOHOURLY = "yes" ]] ; then
|
||||
echo Hourly Backup of Databases
|
||||
echo
|
||||
# Delete old hourly backups while respecting the set retention policy.
|
||||
if [[ $HOURLYRETENTION -ge 0 ]] ; then
|
||||
NUM_OLD_FILES=$(find $BACKUPDIR/hourly -depth -not -newermt "$HOURLYRETENTION hour ago" -type f | wc -l)
|
||||
if [[ $NUM_OLD_FILES -gt 0 ]] ; then
|
||||
echo "Deleting $NUM_OLD_FILES global setting backup files made in previous weeks."
|
||||
find $BACKUPDIR/hourly -not -newermt "$HOURLYRETENTION hour ago" -type f -delete
|
||||
fi
|
||||
fi
|
||||
FILE="$BACKUPDIR/hourly/$DATE.$DOW.$HOD"
|
||||
# convert timestamp to date: echo $TIMESTAMP | gawk '{print strftime("%c", $0)}'
|
||||
OPT="$OPT -since $(date -u --date='1 hour ago' +'%Y-%m-%dT%H:00:00Z')"
|
||||
|
||||
fi
|
||||
|
||||
# FILE will not be set if no frequency is selected.
|
||||
if [[ -z "$FILE" ]] ; then
|
||||
echo "ERROR: No backup frequency was chosen."
|
||||
echo "Please set one of DOHOURLY,DODAILY,DOWEEKLY,DOMONTHLY to \"yes\""
|
||||
exit 1
|
||||
fi
|
||||
|
||||
dbdump "$FILE" && compression "$FILE"
|
||||
|
||||
echo ----------------------------------------------------------------------
|
||||
echo "Backup End Time $(date)"
|
||||
echo ======================================================================
|
||||
|
||||
echo Total disk space used for backup storage..
|
||||
echo Size - Location
|
||||
du -hs "$BACKUPDIR"
|
||||
echo
|
||||
echo ======================================================================
|
||||
|
||||
# Run command when we're done
|
||||
if [ "$POSTBACKUP" ]; then
|
||||
echo ======================================================================
|
||||
echo "Postbackup command output."
|
||||
echo
|
||||
eval "$POSTBACKUP"
|
||||
echo
|
||||
echo ======================================================================
|
||||
fi
|
||||
|
||||
# Clean up IO redirection if we plan not to deliver log via e-mail.
|
||||
[ ! "$MAILCONTENT" == "log" ] && exec 1>&6 2>&7 6>&- 7>&-
|
||||
|
||||
if [ "$MAILCONTENT" = "log" ]; then
|
||||
mail -s "InfluxDB Backup Log for $DBHOST - $DATE" "$MAILADDR" < "$LOGFILE"
|
||||
|
||||
if [ -s "$LOGERR" ]; then
|
||||
cat "$LOGERR"
|
||||
mail -s "ERRORS REPORTED: InfluxDB Backup error Log for $DBHOST - $DATE" "$MAILADDR" < "$LOGERR"
|
||||
fi
|
||||
else
|
||||
if [ -s "$LOGERR" ]; then
|
||||
cat "$LOGFILE"
|
||||
echo
|
||||
echo "###### WARNING ######"
|
||||
echo "STDERR written to during influxd backup execution."
|
||||
echo "The backup probably succeeded, as influxd backup sometimes writes to STDERR, but you may wish to scan the error log below:"
|
||||
cat "$LOGERR"
|
||||
else
|
||||
cat "$LOGFILE"
|
||||
fi
|
||||
fi
|
||||
|
||||
# TODO: Would be nice to know if there were any *actual* errors in the $LOGERR
|
||||
STATUS=0
|
||||
if [ -s "$LOGERR" ]; then
|
||||
STATUS=1
|
||||
fi
|
||||
|
||||
# Clean up Logfile
|
||||
rm -f "$LOGFILE" "$LOGERR"
|
||||
|
||||
exit $STATUS
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
---
|
||||
# Copyright (C) 2020 Pedro Luis Lopez <pedroluis.lopezsanchez@gmail.com>
|
||||
# Copyright (C) 2020 Innobyte Bechea Leonardo <https://www.innobyte.com/>
|
||||
# Copyright (C) 2020 Innobyte Alin Alexandru <https://www.innobyte.com/>
|
||||
# Copyright (C) 2020 DebOps <https://debops.org/>
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
# Ensure that custom Ansible plugins and modules included in the main DebOps
|
||||
# collection are available to roles in other collections.
|
||||
collections: [ 'debops.debops' ]
|
||||
|
||||
dependencies: []
|
||||
|
||||
galaxy_info:
|
||||
|
||||
author: 'Pedro Luis López, Bechea Leonardo, Alin Alexandru'
|
||||
description: 'Install and manage InfluxDB server'
|
||||
company: 'DebOps'
|
||||
license: 'GPL-3.0-only'
|
||||
min_ansible_version: '2.9.0'
|
||||
platforms:
|
||||
- name: Debian
|
||||
versions:
|
||||
- stretch
|
||||
- buster
|
||||
galaxy_tags:
|
||||
- clustering
|
||||
- database
|
||||
- nosql
|
||||
- search
|
||||
- monitoring
|
||||
- influxdb
|
||||
|
|
@ -0,0 +1,35 @@
|
|||
---
|
||||
# Copyright (C) 2020 Pedro Luis Lopez <pedroluis.lopezsanchez@gmail.com>
|
||||
# Copyright (C) 2020 Innobyte Bechea Leonardo <https://www.innobyte.com/>
|
||||
# Copyright (C) 2020 Innobyte Alin Alexandru <https://www.innobyte.com/>
|
||||
# Copyright (C) 2020 DebOps <https://debops.org/>
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
- name: Copy autoinfluxdbbackup script
|
||||
ansible.builtin.copy:
|
||||
src: 'usr/sbin/autoinfluxdbbackup'
|
||||
dest: '/usr/sbin/autoinfluxdbbackup'
|
||||
owner: 'root'
|
||||
group: 'root'
|
||||
mode: '0755'
|
||||
|
||||
- name: Ensure that the autoinfluxdbbackup directory exists
|
||||
ansible.builtin.file:
|
||||
path: '/etc/autoinfluxdbbackup/'
|
||||
state: 'directory'
|
||||
owner: 'root'
|
||||
group: 'root'
|
||||
mode: '0755'
|
||||
|
||||
- name: Configure autoinfluxdbbackup
|
||||
ansible.builtin.template:
|
||||
src: '{{ item.template }}.j2'
|
||||
dest: '/{{ item.template }}'
|
||||
owner: 'root'
|
||||
group: 'root'
|
||||
mode: '{{ item.mode }}'
|
||||
with_items:
|
||||
- template: 'etc/cron.daily/autoinfluxdbbackup'
|
||||
mode: '0755'
|
||||
- template: 'etc/default/autoinfluxdbbackup'
|
||||
mode: '0644'
|
||||
|
|
@ -0,0 +1,127 @@
|
|||
---
|
||||
# Copyright (C) 2020 Pedro Luis Lopez <pedroluis.lopezsanchez@gmail.com>
|
||||
# Copyright (C) 2020 Innobyte Bechea Leonardo <https://www.innobyte.com/>
|
||||
# Copyright (C) 2020 Innobyte Alin Alexandru <https://www.innobyte.com/>
|
||||
# Copyright (C) 2020 DebOps <https://debops.org/>
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
- name: Import custom Ansible plugins
|
||||
ansible.builtin.import_role:
|
||||
name: 'ansible_plugins'
|
||||
|
||||
- name: Import DebOps global handlers
|
||||
ansible.builtin.import_role:
|
||||
name: 'global_handlers'
|
||||
|
||||
- name: Import DebOps secret role
|
||||
ansible.builtin.import_role:
|
||||
name: 'secret'
|
||||
|
||||
- name: Restart database server on first install (influx bug)
|
||||
ansible.builtin.service:
|
||||
name: 'influxdb'
|
||||
state: 'restarted'
|
||||
when: not (ansible_local.influxdb_server.installed | d(false) | bool)
|
||||
|
||||
- name: Wait for HTTP endpoint port to become open on the host on first install
|
||||
ansible.builtin.wait_for:
|
||||
port: '{{ influxdb_server__port }}'
|
||||
when: not (ansible_local.influxdb_server.installed | d(false) | bool)
|
||||
|
||||
- name: Create default admin user on first install
|
||||
community.general.influxdb_user:
|
||||
user_name: 'root'
|
||||
user_password: '{{ influxdb_server__root_password }}'
|
||||
state: 'present'
|
||||
admin: 'yes'
|
||||
proxies:
|
||||
http:
|
||||
https:
|
||||
when: not (ansible_local.influxdb_server.installed | d(false) | bool)
|
||||
no_log: '{{ debops__no_log | d(True) }}'
|
||||
|
||||
- name: Stop database server on first install
|
||||
ansible.builtin.service:
|
||||
name: 'influxdb'
|
||||
state: 'stopped'
|
||||
when: not (ansible_local.influxdb_server.installed | d(false) | bool)
|
||||
|
||||
- name: Add InfluxDB server user to specified groups
|
||||
ansible.builtin.user:
|
||||
name: 'influxdb'
|
||||
groups: '{{ influxdb_server__append_groups | join(",") | default(omit) }}'
|
||||
append: True
|
||||
createhome: False
|
||||
when: influxdb_server__pki | bool
|
||||
|
||||
- name: Ensure InfluxDB server directory exists
|
||||
ansible.builtin.file:
|
||||
path: '{{ influxdb_server__directory }}'
|
||||
state: 'directory'
|
||||
owner: 'influxdb'
|
||||
group: 'influxdb'
|
||||
mode: '0750'
|
||||
|
||||
- name: Move InfluxDB data files to data directory
|
||||
ansible.builtin.shell:
|
||||
'mv {{ influxdb_server__default_directory }}/* {{ influxdb_server__directory }}'
|
||||
register: influxdb_server__register_move
|
||||
changed_when: influxdb_server__register_move.changed | bool
|
||||
when: (not (ansible_local.influxdb_server.installed | d(false) | bool) and
|
||||
influxdb_server__directory != influxdb_server__default_directory)
|
||||
|
||||
- name: Divert the original influxdb configuration file
|
||||
debops.debops.dpkg_divert:
|
||||
path: '/etc/influxdb/influxdb.conf'
|
||||
state: 'present'
|
||||
delete: True
|
||||
tags: [ 'role::influxdb_server:config' ]
|
||||
|
||||
- name: Configure InfluxDB server
|
||||
ansible.builtin.template:
|
||||
src: 'etc/influxdb/influxdb.conf.j2'
|
||||
dest: '/etc/influxdb/influxdb.conf'
|
||||
owner: 'root'
|
||||
group: 'root'
|
||||
mode: '0644'
|
||||
tags: [ 'role::influxdb_server:config' ]
|
||||
notify: [ 'Restart influxdb' ]
|
||||
|
||||
- name: Start database server on first install
|
||||
ansible.builtin.service:
|
||||
name: 'influxdb'
|
||||
state: 'started'
|
||||
when: not (ansible_local.influxdb_server.installed | d(false) | bool)
|
||||
|
||||
- name: Configure autoinfluxdbbackup
|
||||
ansible.builtin.include_tasks: 'autoinfluxdbbackup.yml'
|
||||
when: influxdb_server__backup | bool
|
||||
tags: [ 'role::influxdb_server:autoinfluxdbbackup' ]
|
||||
|
||||
- name: Make sure that Ansible local facts directory exists
|
||||
ansible.builtin.file:
|
||||
path: '/etc/ansible/facts.d'
|
||||
state: 'directory'
|
||||
mode: '0755'
|
||||
|
||||
- name: Save InfluxDB server local facts
|
||||
ansible.builtin.template:
|
||||
src: 'etc/ansible/facts.d/influxdb_server.fact.j2'
|
||||
dest: '/etc/ansible/facts.d/influxdb_server.fact'
|
||||
owner: 'root'
|
||||
group: 'root'
|
||||
mode: '0755'
|
||||
notify: [ 'Refresh host facts' ]
|
||||
tags: [ 'meta::facts' ]
|
||||
|
||||
- name: Save InfluxDB local facts
|
||||
ansible.builtin.template:
|
||||
src: 'etc/ansible/facts.d/influxdb.fact.j2'
|
||||
dest: '/etc/ansible/facts.d/influxdb.fact'
|
||||
owner: 'root'
|
||||
group: 'root'
|
||||
mode: '0644'
|
||||
notify: [ 'Refresh host facts' ]
|
||||
|
||||
- name: Re-read local facts if they have been modified
|
||||
ansible.builtin.meta: 'flush_handlers'
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
{# Copyright (C) 2020 Pedro Luis Lopez <pedroluis.lopezsanchez@gmail.com>
|
||||
# Copyright (C) 2020 Innobyte Bechea Leonardo <https://www.innobyte.com/>
|
||||
# Copyright (C) 2020 Innobyte Alin Alexandru <https://www.innobyte.com/>
|
||||
# Copyright (C) 2020 DebOps <https://debops.org/>
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
#}
|
||||
{% set influxdb__tpl_delegate_to = ansible_local.influxdb.delegate_to | d(influxdb_server__delegate_to) %}
|
||||
{% set influxdb__tpl_port = ansible_local.influxdb.port | d(influxdb_server__port) %}
|
||||
{% set influxdb__tpl_server = ansible_local.influxdb.server | d(ansible_fqdn if influxdb_server__pki else "localhost") %}
|
||||
{
|
||||
"delegate_to": "{{ influxdb__tpl_delegate_to }}",
|
||||
"port": "{{ influxdb__tpl_port }}",
|
||||
"server": "{{ influxdb__tpl_server }}"
|
||||
}
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
#!{{ ansible_python['executable'] }}
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Copyright (C) 2020 Pedro Luis Lopez <pedroluis.lopezsanchez@gmail.com>
|
||||
# Copyright (C) 2020 Innobyte Bechea Leonardo <https://www.innobyte.com/>
|
||||
# Copyright (C) 2020 Innobyte Alin Alexandru <https://www.innobyte.com/>
|
||||
# Copyright (C) 2020 DebOps <https://debops.org/>
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
# {{ ansible_managed }}
|
||||
|
||||
from __future__ import print_function
|
||||
from json import dumps, loads
|
||||
import os
|
||||
|
||||
|
||||
def cmd_exists(cmd):
|
||||
return any(
|
||||
os.access(os.path.join(path, cmd), os.X_OK)
|
||||
for path in os.environ["PATH"].split(os.pathsep)
|
||||
)
|
||||
|
||||
|
||||
output = {}
|
||||
output['installed'] = cmd_exists('influxd')
|
||||
|
||||
print(dumps(output, sort_keys=True, indent=4))
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
#!/bin/sh
|
||||
|
||||
# Copyright (C) 2020 Pedro Luis Lopez <pedroluis.lopezsanchez@gmail.com>
|
||||
# Copyright (C) 2020 Innobyte Bechea Leonardo <https://www.innobyte.com/>
|
||||
# Copyright (C) 2020 Innobyte Alin Alexandru <https://www.innobyte.com/>
|
||||
# Copyright (C) 2020 DebOps <https://debops.org/>
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
# {{ ansible_managed }}
|
||||
|
||||
test -x /usr/sbin/autoinfluxdbbackup || exit 0
|
||||
/usr/sbin/autoinfluxdbbackup > /dev/null
|
||||
|
|
@ -0,0 +1,173 @@
|
|||
# Copyright (C) 2020 Pedro Luis Lopez <pedroluis.lopezsanchez@gmail.com>
|
||||
# Copyright (C) 2020 Innobyte Bechea Leonardo <https://www.innobyte.com/>
|
||||
# Copyright (C) 2020 Innobyte Alin Alexandru <https://www.innobyte.com/>
|
||||
# Copyright (C) 2020 DebOps <https://debops.org/>
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
# {{ ansible_managed }}
|
||||
|
||||
#
|
||||
# InfluxDB Backup Script
|
||||
# VER. 0.1
|
||||
|
||||
# Note, this is a lobotomized port of AutoMySQLBackup
|
||||
# (https://sourceforge.net/projects/automysqlbackup/) for use with
|
||||
# InfluxDB.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
#
|
||||
#=====================================================================
|
||||
#=====================================================================
|
||||
# Set the following variables to your system needs
|
||||
# (Detailed instructions below variables)
|
||||
#=====================================================================
|
||||
|
||||
# Database name to specify a specific database only e.g. myawesomeapp
|
||||
# Unnecessary if backup all databases
|
||||
# DBNAME=""
|
||||
|
||||
# Host name (or IP address) of influxdb server e.g localhost
|
||||
DBHOST="{{ influxdb_server__rpc_bind }}"
|
||||
|
||||
# Port that influxdb is listening on
|
||||
DBPORT="{{ influxdb_server__rpc_port }}"
|
||||
|
||||
# Backup directory location e.g /backups
|
||||
BACKUPDIR="{{ influxdb_server__backup_directory | d('/var/lib/autoinfluxdbbackup') }}"
|
||||
|
||||
# Mail setup
|
||||
# What would you like to be mailed to you?
|
||||
# - log : send only log file
|
||||
# - files : send log file and sql files as attachments (see docs)
|
||||
# - stdout : will simply output the log to the screen if run manually.
|
||||
# - quiet : Only send logs if an error occurs to the MAILADDR.
|
||||
MAILCONTENT="quiet"
|
||||
|
||||
# Set the maximum allowed email size in k. (4000 = approx 5MB email [see docs])
|
||||
export MAXATTSIZE="4000"
|
||||
|
||||
# Email Address to send mail to? (user@domain.com)
|
||||
MAILADDR="{{ influxdb_server__backup_mailaddr }}"
|
||||
|
||||
# ============================================================================
|
||||
# === SCHEDULING AND RETENTION OPTIONS ( Read the doc's below for details )===
|
||||
#=============================================================================
|
||||
|
||||
# Do you want to do hourly backups? How long do you want to keep them?
|
||||
DOHOURLY="no"
|
||||
HOURLYRETENTION=24
|
||||
|
||||
# Do you want to do daily backups? How long do you want to keep them?
|
||||
DODAILY="yes"
|
||||
DAILYRETENTION=0
|
||||
|
||||
# Which day do you want weekly backups? (1 to 7 where 1 is Monday)
|
||||
DOWEEKLY="yes"
|
||||
WEEKLYDAY={{ influxdb_server__backup_doweekly }}
|
||||
WEEKLYRETENTION=4
|
||||
|
||||
# Do you want monthly backups? How long do you want to keep them?
|
||||
DOMONTHLY="yes"
|
||||
MONTHLYRETENTION=4
|
||||
|
||||
# ============================================================
|
||||
# === ADVANCED OPTIONS ( Read the doc's below for details )===
|
||||
#=============================================================
|
||||
|
||||
# Choose Compression type. (gzip or bzip2)
|
||||
COMP="gzip"
|
||||
|
||||
# Choose if the uncompressed folder should be deleted after compression has completed
|
||||
CLEANUP="yes"
|
||||
|
||||
# Additionally keep a copy of the most recent backup in a separate directory.
|
||||
LATEST="{{ influxdb_server__backup_latest }}"
|
||||
|
||||
# Make Hardlink not a copy
|
||||
LATESTLINK="yes"
|
||||
|
||||
# Maximum files of a single backup used by split - leave empty if no split required
|
||||
# MAXFILESIZE=""
|
||||
|
||||
# Command to run before backups (uncomment to use)
|
||||
# PREBACKUP=""
|
||||
|
||||
# Command run after backups (uncomment to use)
|
||||
# POSTBACKUP=""
|
||||
|
||||
#=====================================================================
|
||||
# Options documentation
|
||||
#=====================================================================
|
||||
# Set the DBHOST option to the server you wish to backup, leave the
|
||||
# default to backup "this server".(to backup multiple servers make
|
||||
# copies of this file and set the options for that server)
|
||||
#
|
||||
# You can change the backup storage location from /backups to anything
|
||||
# you like by using the BACKUPDIR setting..
|
||||
#
|
||||
# The MAILCONTENT and MAILADDR options and pretty self explanatory, use
|
||||
# these to have the backup log mailed to you at any email address or multiple
|
||||
# email addresses in a space separated list.
|
||||
#
|
||||
# (If you set mail content to "log" you will require access to the "mail" program
|
||||
# on your server. If you set this to "files" you will have to have mutt installed
|
||||
# on your server. If you set it to "stdout" it will log to the screen if run from
|
||||
# the console or to the cron job owner if run through cron. If you set it to "quiet"
|
||||
# logs will only be mailed if there are errors reported. )
|
||||
#
|
||||
#
|
||||
# Finally copy autoinfluxdbbackup to anywhere on your server and make sure
|
||||
# to set executable permission. You can also copy the script to
|
||||
# /etc/cron.daily to have it execute automatically every night or simply
|
||||
# place a symlink in /etc/cron.daily to the file if you wish to keep it
|
||||
# somewhere else.
|
||||
#
|
||||
# NOTE: On Debian copy the file with no extension for it to be run
|
||||
# by cron e.g just name the file "autoinfluxdbbackup"
|
||||
#
|
||||
# That's it..
|
||||
#
|
||||
#
|
||||
# === Advanced options ===
|
||||
#
|
||||
# To set the day of the week that you would like the weekly backup to happen
|
||||
# set the WEEKLYDAY setting, this can be a value from 1 to 7 where 1 is Monday,
|
||||
# The default is 6 which means that weekly backups are done on a Saturday.
|
||||
#
|
||||
# Use PREBACKUP and POSTBACKUP to specify Pre and Post backup commands
|
||||
# or scripts to perform tasks either before or after the backup process.
|
||||
#
|
||||
#
|
||||
#=====================================================================
|
||||
# Backup Rotation..
|
||||
#=====================================================================
|
||||
#
|
||||
# Hourly backups are executed if DOHOURLY is set to "yes".
|
||||
# The number of hours backup copies to keep for each day (i.e. 'Monday', 'Tuesday', etc.) is set with DHOURLYRETENTION.
|
||||
# DHOURLYRETENTION=0 rotates hourly backups every day (i.e. only the most recent hourly copy is kept). -1 disables rotation.
|
||||
#
|
||||
# Daily backups are executed if DODAILY is set to "yes".
|
||||
# The number of daily backup copies to keep for each day (i.e. 'Monday', 'Tuesday', etc.) is set with DAILYRETENTION.
|
||||
# DAILYRETENTION=0 rotates daily backups every week (i.e. only the most recent daily copy is kept). -1 disables rotation.
|
||||
#
|
||||
# Weekly backups are executed if DOWEEKLY is set to "yes".
|
||||
# WEEKLYDAY [1-7] sets which day a weekly backup occurs when cron.daily scripts are run.
|
||||
# Rotate weekly copies after the number of weeks set by WEEKLYRETENTION.
|
||||
# WEEKLYRETENTION=0 rotates weekly backups every week. -1 disables rotation.
|
||||
#
|
||||
# Monthly backups are executed if DOMONTHLY is set to "yes".
|
||||
# Monthly backups occur on the first day of each month when cron.daily scripts are run.
|
||||
# Rotate monthly backups after the number of months set by MONTHLYRETENTION.
|
||||
# MONTHLYRETENTION=0 rotates monthly backups upon each execution. -1 disables rotation.
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
{# Copyright (C) 2020 Pedro Luis Lopez <pedroluis.lopezsanchez@gmail.com>
|
||||
# Copyright (C) 2020 Innobyte Bechea Leonardo <https://www.innobyte.com/>
|
||||
# Copyright (C) 2020 Innobyte Alin Alexandru <https://www.innobyte.com/>
|
||||
# Copyright (C) 2020 DebOps <https://debops.org/>
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
#}
|
||||
# {{ ansible_managed }}
|
||||
{% for element in influxdb_server__combined_configuration | debops.debops.parse_kv_items %}
|
||||
{% if element.name | d() and element.state | d('present') not in [ 'absent', 'ignore' ] %}
|
||||
|
||||
{% if element.name in [ 'graphite', 'collectd', 'opentsdb', 'udp' ] %}
|
||||
{{ '[[{}]]'.format(element.name) }}
|
||||
{% else %}
|
||||
{{ '[{}]'.format(element.name) }}
|
||||
{% endif %}
|
||||
{% if element.options | d() %}
|
||||
{% for thing in element.options %}
|
||||
{% if thing.name | d() and thing.value | d() and thing.state | d('present') != 'absent' %}
|
||||
{{ ' {} = {}'.format(thing.name, thing.value) }}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
Loading…
Add table
Add a link
Reference in a new issue