mirror of
https://github.com/saltstack-formulas/mysql-formula.git
synced 2025-04-17 10:10:30 +00:00
Add support for fetching user hosts from salt mine.
This commit is contained in:
parent
7c683825e6
commit
22d08ec1f3
2 changed files with 19 additions and 0 deletions
|
@ -21,6 +21,16 @@ include:
|
||||||
{% set user_hosts = salt['pillar.get']('mysql:user:%s:hosts'|format(name)) %}
|
{% set user_hosts = salt['pillar.get']('mysql:user:%s:hosts'|format(name)) %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
{% if not user_hosts %}
|
||||||
|
{% set mine_target = salt['pillar.get']('mysql:user:%s:mine_hosts:target'|format(name)) %}
|
||||||
|
{% set mine_function = salt['pillar.get']('mysql:user:%s:mine_hosts:function'|format(name)) %}
|
||||||
|
{% set mine_expression_form = salt['pillar.get']('mysql:user:%s:mine_hosts:expr_form'|format(name)) %}
|
||||||
|
|
||||||
|
{% if mine_target and mine_function and mine_expression_form %}
|
||||||
|
{% set user_hosts = salt['mine.get'](mine_target, mine_function, mine_expression_form).values() %}
|
||||||
|
{% endif %}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
{% for host in user_hosts %}
|
{% for host in user_hosts %}
|
||||||
|
|
||||||
{% set state_id = 'mysql_user_' ~ name ~ '_' ~ host%}
|
{% set state_id = 'mysql_user_' ~ name ~ '_' ~ host%}
|
||||||
|
|
|
@ -81,6 +81,15 @@ mysql:
|
||||||
password: ~
|
password: ~
|
||||||
host: localhost
|
host: localhost
|
||||||
databases: []
|
databases: []
|
||||||
|
application:
|
||||||
|
password: 'somepass'
|
||||||
|
mine_hosts:
|
||||||
|
target: "G@role:database and *.example.com"
|
||||||
|
function: "network.get_hostname"
|
||||||
|
expr_form: compound
|
||||||
|
databases:
|
||||||
|
- database: foo
|
||||||
|
grants: ['select', 'insert', 'update']
|
||||||
|
|
||||||
# Override any names defined in map.jinja
|
# Override any names defined in map.jinja
|
||||||
lookup:
|
lookup:
|
||||||
|
|
Loading…
Add table
Reference in a new issue