This repo holds custom callback plugin, so your Ansible could write everything in the PostgreSQL database.

Overview

English

What is it?

This is callback plugin that dumps most of the Ansible internal state to the external PostgreSQL database.

What is this for?

If you ever had to:

  • know the value of the certain variable before the role or task starts;
  • implement an audit soultion which should send data to some remote storage for unchangeability;
  • investigate into some Ansible function while dreaming of looking under the hood

...then this plugin is right for you.

Requirements

  • CentOS/RHEL 7.x;
  • Ansible 2.9.x;
  • Python >=3.6.x;
  • PostgreSQL >=10.x (this was debugged with Postgres 12, though)

Quick start guide

  1. Copy to your project directory:
    1. playbooks/callback_plugins/logdb.py
    2. playbooks/module_utils/pg8000/*
    3. playbooks/module_utils/scramp/*
  2. Add settings to the ansible.cfg as follows:
[defaults]
stdout_callback = log2db
callable_plugins = log2db
callback_whitelist = log2db

[log2db_callback]
host = <your PostgreSQL server hostname>
port = <your PostgreSQL server port, usually 5432>
user = <database account with insert privilege>
pass = <database account password>
db = <database name, default is "ansible">
table = <table name, default is "logs">
  1. Do not forget to setup a database and a table before the first launch. Also, an account with proper rights is a must:
[[email protected]]> sudo -u postgres psql
postgres=# CREATE DATABASE <my_db_name> WITH OWNER postgres;
postgres=# CREATE USER <my_db_user>;
postgres=# GRANT CONNECT, CREATE, TEMPORARY ON DATABASE <my_db_name> to <my_db_user>;
postgres=# CREATE TABLE IF NOT EXISTS <my_table_name> (
   uuid uuid not null,
   data jsonb,
   timestamp timestamp with time zone,
   id bigserial
   constraint logs_pk
   primary key,
   origin text);
postgres=# ALTER TABLE <my_table_name> OWNER to <my_db_account>;
postgres=# CREATE INDEX IF NOT EXISTS <my_table_name>_uuid_index on <my_table_name> (uuid);
postgres=# ALTER USER <my_db_user> WITH PASSWORD '<my_db_password>';

How to send a donation to the author

If you want to thank the author - this is a donate link. Any sum is happily accepted.

Legal information

This project is conceived and performed by me, Sergey Pechenko, on my own will, out of working hours, using own hardware.

Copyright: (С) 2021, Sergey Pechenko

Based on "default.py" callback plugin for Ansible, which has own copyrights:

(C) 2012-2014, Michael DeHaan [email protected]

(C) 2017 Ansible Project

This project uses MIT-licensed components as follows:

  • pg8000 (c) 2007-2009, Mathieu Fenniak

  • scramp (C) 2019 Tony Locke

Portions for these components that provide possibility for Ansible to load and run them are also (C) 2021, Sergey Pechenko.

License

GPLv3+ (please see LICENSE)

Contact

You can ask your questions about this plugin at the Ansible chat, or PM me

Русский

Что это?

Коллбэк-плагин для Ansible, который позволяет сохранять бОльшую часть внутренних данных Ansible во внешнюю БД.

Зачем это?

Если тебе когда-нибудь:

  • требовалось при отладке знать значение конкретной переменной перед исполнением таска или вызовом роли;
  • приходилось организовывать аудит с сохранением данных в отдельном от Ansible внешнем хранилище;
  • случалось разбираться с какой-то функций Ansible в мечтах о возможности "заглянуть под капот" -

...то этот плагин - для тебя.

Что требуется?

  • CentOS/RHEL 7.x;
  • Ansible 2.9.x;
  • Python >=3.6.x;
  • PostgreSQL >=10 (отлаживалось на 12);

Как запустить?

  1. Скопируй в каталог с проектом:
    1. playbooks/callback_plugins/logdb.py
    2. playbooks/module_utils/pg8000/*
    3. playbooks/module_utils/scramp/*
  2. Укажи в ansible.cfg следующее:
[defaults]
stdout_callback = logdb
callable_plugins = logdb
callback_whitelist = logdb

[logdb_callback]
host = <имя хоста PostgreSQL>
port = <порт сервера PostgreSQL, обычно 5432>
user = <учётная запись в БД с правами на INSERT>
pass = <пароль этой учётной записи>
db = <название БД, по умолчанию "ansible">
table = <название таблицы, по умолчанию "logs">
  1. Перед запуском не забудь создать БД и таблицу. А ещё понадобится создать учётку и дать ей права:
[[email protected]]> sudo -u postgres psql
postgres=# CREATE DATABASE <название БД> WITH OWNER postgres;
postgres=# CREATE USER <учётная запись>;
postgres=# GRANT CONNECT, CREATE, TEMPORARY ON DATABASE <название БД> to <учётная запись>;
postgres=# CREATE TABLE IF NOT EXISTS <название таблицы> (
   uuid uuid not null,
   data jsonb,
   timestamp timestamp with time zone,
   id bigserial
   constraint logs_pk
   primary key,
   origin text);
postgres=# ALTER TABLE <название таблицы> OWNER to <учётная запись>;
postgres=# CREATE INDEX IF NOT EXISTS <название таблицы>_uuid_index on <название таблицы> (uuid);
postgres=# ALTER USER <учётная запись> WITH PASSWORD '<пароль учётной записи>';

Поблагодарить автора

Если хочешь поблагодарить автора - вот ссылка для донатов. Буду рад любой сумме.

Правовая информация

Этот проект задуман и выполнен мною, Сергеем Печенко, по личной инициативе в нерабочее время на личном оборудовании.

Авторские права: (С) 2021, Sergey Pechenko

Проект выполнен на основе коллбэк-плагина "default.py" для Ansible. Авторские права на оригинальный файл:

(C) 2012-2014, Michael DeHaan [email protected]

(C) 2017 Ansible Project

При создании проекта по лицензии MIT использованы следующие компоненты:

  • pg8000 (C) Mathieu Fenniak
  • scramp (C) Tony Locke

Авторские права на части этих компонентов, обеспечивающие Ansible возможность их загрузки и выполнения: (С) 2021, Сергей Печенко

Лицензия

GPLv3+

Контакты

Можешь задать свои вопросы в чате по Ansible, или написать мне в ЛС.

Owner
Sergey Pechenko
Sergey Pechenko
Transpiles some Python into human-readable Golang.

pytago Transpiles some Python into human-readable Golang. Try out the web demo Installation and usage There are two "officially" supported ways to use

Michael Phelps 318 Jan 03, 2023
🔵Open many google dorks in a fasted way

Dorkinho 🔵 The author is not responsible for misuse of the tool, use it in good practices like Pentest and CTF OSINT challenges. Dorkinho is a script

SidHawks 2 May 02, 2022
Blender Addon for Snapping a UV to a specific part of a Tilemap

UVGridSnapper A simple Blender Addon for easier texturing. A menu in the UV editor allows a square UV to be snapped to an Atlas texture, or Tilemap. P

2 Jul 17, 2022
Clear merged pull requests ref (branch) on GitHub

GitHub PR Cleansing This tool is used to clear merged pull requests ref (branch) on GitHub. GitHub has no feature to auto delete branches on pull requ

Andi N. Dirgantara 12 Apr 19, 2022
Excel cell checker with python

excel-cell-checker Description This tool checks a given .xlsx file has the struc

Paul Aumann 1 Jan 04, 2022
A calculator developed in Python.

Calculadora Uma simples calculadora... ( + − × ÷ ) 💻 Situação do projeto: Projeto finalizado ✔️ 🛠 Tecnologias: Python Tkinter (GUI) ⚙️ Pré-requisito

Arthur V.B.S. 1 Jan 27, 2022
Twikoo自定义表情列表 | HexoPlusPlus自定义表情列表(其实基于OwO的项目都可以用的啦)

Twikoo-Magic 更新说明 2021/1/15 基于2021/1/14 Twikoo 更新1.1.0-beta,所有表情都将以缩写形式(如:[ text ]:)输出。1/14之前本仓库有部分表情text缺失及重复, 导致无法正常使用表情 1/14后的所有表情json列表已全部更新

noionion 90 Jan 05, 2023
Automation of VASP DFT workflows with ASE - application scripts

This repo contains a library that aims at automatizing some Density Functional Theory (DFT) workflows in VASP by using the ASE toolkit.

Frank Niessen 5 Sep 06, 2022
Better firefox bookmarks script for rofi

rofi-bookmarks Small python script to open firefox bookmarks with rofi. Features Icons! Only show bookmarks in a specified bookmark folder Show entire

32 Nov 10, 2022
Cirq is a Python library for writing, manipulating, and optimizing quantum circuits and running them against quantum computers and simulators

Cirq is a Python library for writing, manipulating, and optimizing quantum circuits and running them against quantum computers and simulators. Install

quantumlib 3.6k Jan 07, 2023
Developer guide for Hivecoin project

Hivecoin-developer Developer guide for Hivecoin project. Install Content are writen in reStructuredText (RST) and rendered with Sphinx. Much of the co

tweetyf 1 Nov 22, 2021
A program made in PYTHON🐍 that automatically performs data insertions into a POSTGRES database 🐘 , using as base a .CSV file 📁 , useful in mass data insertions

A program made in PYTHON🐍 that automatically performs data insertions into a POSTGRES database 🐘 , using as base a .CSV file 📁 , useful in mass data insertions.

Davi Galdino 1 Oct 17, 2022
Herramienta para poder automatizar reuniones en Zoom.

Crear Reunión Zoom con Python Herramienta para poder automatizar reuniones en Zoom. Librerías Requeridas Nombre Comando PyAutoGui pip install pyautogu

JkDev 3 Nov 12, 2022
Short, introductory guide for the Python programming language

100 Page Python Intro This book is a short, introductory guide for the Python programming language.

Sundeep Agarwal 185 Dec 26, 2022
Make your Discord Account Online 24/7!

Online-Forever Make your Discord Account Online 24/7! A Code written in Python that helps you to keep your account 24/7. The main.py is the main file.

SealedSaucer 0 Mar 16, 2022
Make after-work Mending More flexible In Python

Mending Make after-work Mending More flexible In Python A Lite Package focuses on making project's after-post mending pythonic and flexible. Certainly

2 Jun 15, 2022
Packages of Example Data for The Effect

causaldata This repository will contain R, Stata, and Python packages, all called causaldata, which contain data sets that can be used to implement th

103 Dec 24, 2022
Find the remote website version based on a git repository

versionshaker Versionshaker is a tool to find a remote website version based on a git repository This tool will help you to find the website version o

Orange Cyberdefense 110 Oct 23, 2022
A simple program to recolour simple png icon-like pictures with just one colour + transparent or white background. Resulting images all have transparent background and a new colour.

A simple program to recolour simple png icon-like pictures with just one colour + transparent or white background. Resulting images all have transparent background and a new colour.

Anna Tůmová 0 Jan 30, 2022
Magenta: Music and Art Generation with Machine Intelligence

Magenta is a research project exploring the role of machine learning in the process of creating art and music. Primarily this involves developing new

Magenta 18.1k Jan 05, 2023