salt.pillar.mysql

Retrieve Pillar data by doing a MySQL query

MariaDB provides Python support through the MySQL Python package. Therefore, you may use this module with both MySQL or MariaDB.

This module is a concrete implementation of the sql_base ext_pillar for MySQL.

maturity:

new

depends:

python-mysqldb

platform:

all

Configuring the mysql ext_pillar

Use the 'mysql' key under ext_pillar for configuration of queries.

MySQL configuration of the MySQL returner is being used (mysql.db, mysql.user, mysql.pass, mysql.port, mysql.host) for database connection info.

Required python modules: MySQLdb

Complete example

mysql:
  user: 'salt'
  pass: 'super_secret_password'
  db: 'salt_db'
  port: 3306
  ssl:
    cert: /etc/mysql/client-cert.pem
    key: /etc/mysql/client-key.pem

ext_pillar:
  - mysql:
      fromdb:
        query: 'SELECT col1,col2,col3,col4,col5,col6,col7
                  FROM some_random_table
                 WHERE minion_pattern LIKE %s'
        depth: 5
        as_list: True
        with_lists: [1,3]
class salt.pillar.mysql.MySQLExtPillar

This class receives and processes the database rows from MySQL.

extract_queries(args, kwargs)

This function normalizes the config block into a set of queries we can use. The return is a list of consistently laid out dicts.

salt.pillar.mysql.ext_pillar(minion_id, pillar, *args, **kwargs)

Execute queries against MySQL, merge and return as a dict