zabbix http/s checks from yaml dict

Posted on Sun 11 April 2021 in devops • Tagged with ansible, zabbix, gitlab, monitoring

motivation

to maintain the principle of configuration-as-code this tools helps to bulk create and update http/s checks from your zabbix server

imagine you need to monitor many different http/s microservice endpoints
you can create them using the zabbix gui, or note them down in a simple yaml dict. this automation uses ansible to utilize the zabbix api to create zabbix http/s checks with graphs and alert trigger

health_checks:
    - check_url:              "https://www.example.com/blog/"
    - check_url:              "https://api.example.com/endpoint/search?query=token"
      check_searchstring:     "Results for: token"
    - check_url:              "https://api.example.com/long/running/api"
      check_timeout:          "10s"
    - check_url:              "https://api.example.com/special/returncode"
      check_returncode:       "200,206"
    - check_url:              "https://static.example.com/images/"

source

the sources, documentation and examples are located here


Running Ansible inside Docker

Posted on Tue 22 December 2020 in devops • Tagged with ansible, docker, bash

why

Sometimes it is important to be independent from your local dev machines setup.
I wrote a small wrapper script to run ansible tasks inside a docker container.

wrapper

#!/bin/bash
vault=~/.ansible-vault-pass
# check if argument was supplied
if [ $# -eq 0 ]
  then
    echo "No arguments supplied; usage: $0 'ansible-playbook playbook.yaml' # The QUOTES are important here! "
    exit 1
fi

if [ -f "$vault" ]; then
    docker container run -it --rm \
    -v $(pwd)/../:/data \
    -v $vault:/root/.ansible-vault-pass \
    -e ANSIBLE_VAULT_PASSWORD_FILE=/root/.ansible-vault-pass \
    cytopia/ansible:latest $1
else
    echo "$vault file does not exist."
fi