From b489fee46459d828f069b3d9b9b7c35e53e52c20 Mon Sep 17 00:00:00 2001 From: Kameron Kenny <1267885+kkenny@users.noreply.github.com> Date: Tue, 25 Jun 2024 14:39:15 -0400 Subject: [PATCH] influx/telegraf bootstrap --- Jenkinsfile | 50 ++++++++++++++++++++++++++++++++++++++++ docker-compose.yml | 36 +++++++++++++++++++++++++++++ influxv2.env | 6 +++++ telegraf/mytelegraf.conf | 19 +++++++++++++++ 4 files changed, 111 insertions(+) create mode 100644 Jenkinsfile create mode 100644 docker-compose.yml create mode 100644 influxv2.env create mode 100644 telegraf/mytelegraf.conf diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 0000000..1d31abf --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,50 @@ +pipeline { + agent { + label 'pi501.in.thelinuxpro.net' + } + + stages { + stage("verify tooling") { + steps { + sh ''' + docker version + docker info + docker compose version + ''' + } + } + + stage("Build Containers and push to registry") { + steps { + script { + sh 'docker compose build --push' + } + } + } + + stage('Create contexts') { + steps { + sh 'docker context ls | grep pi502 || docker context create pi502 --docker "host=ssh://pi502.in.thelinuxpro.net"' + } + } + + stage('Start container') { + steps { + script { + def status_s = sh(returnStatus: true, script: 'grep $(docker --context pi502 compose ps | tail -n1 | awk \'{ print $2 }\') docker-compose.yml') + + if (status_s != 0) { + sh 'docker --context pi502 compose up -d' + sh 'docker --context pi502 compose ps' + } else { + sh 'docker --context pi502 compose down + sh 'docker --context pi502 compose up -d' + sh 'docker --context pi502 compose ps' + } + } + } + } + + } +} + diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..e2cf4f4 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,36 @@ +--- + +networks: + infra_dev_net: + esternal: true + +volumes: + influxdbv2: + driver: local + +services: + influxdb: + image: influxdb:2.6-alpine + env_file: + - influxv2.env + volumes: + # Mount for influxdb data directory and configuration + - influxdbv2:/var/lib/influxdb2:rw + networks: + infra_dev_net: + ipv4_address:10.99.23.41 + ports: + - "8086:8086" + + telegraf: + image: telegraf:1.25-alpine + depends_on: + - influxdb + volumes: + # Mount for telegraf config + - ./telegraf/mytelegraf.conf:/etc/telegraf/telegraf.conf:ro + networks: + infra_dev_net: + ipv4_address:10.99.23.42 + env_file: + - influxv2.env diff --git a/influxv2.env b/influxv2.env new file mode 100644 index 0000000..952c367 --- /dev/null +++ b/influxv2.env @@ -0,0 +1,6 @@ +DOCKER_INFLUXDB_INIT_MODE=setup +DOCKER_INFLUXDB_INIT_USERNAME=flux +DOCKER_INFLUXDB_INIT_PASSWORD=forty6and2 +DOCKER_INFLUXDB_INIT_ORG=darkstar +DOCKER_INFLUXDB_INIT_BUCKET=default_bucket +DOCKER_INFLUXDB_INIT_ADMIN_TOKEN=admintoken diff --git a/telegraf/mytelegraf.conf b/telegraf/mytelegraf.conf new file mode 100644 index 0000000..3964b80 --- /dev/null +++ b/telegraf/mytelegraf.conf @@ -0,0 +1,19 @@ +# Output Configuration for telegraf agent +[[outputs.influxdb_v2]] + ## The URLs of the InfluxDB cluster nodes. + ## + ## Multiple URLs can be specified for a single cluster, only ONE of the + ## urls will be written to each interval. + ## urls exp: http://127.0.0.1:8086 + urls = ["http://influxdb.in.thelinuxpro.net:8086"] + + ## Token for authentication. + token = "$DOCKER_INFLUXDB_INIT_ADMIN_TOKEN" + + ## Organization is the name of the organization you wish to write to; must exist. + organization = "$DOCKER_INFLUXDB_INIT_ORG" + + ## Destination bucket to write into. + bucket = "$DOCKER_INFLUXDB_INIT_BUCKET" + + insecure_skip_verify = true