mirror of
https://github.com/saltstack-formulas/mysql-formula.git
synced 2025-04-15 17:20:25 +00:00
Merge pull request #116 from M2Mobi/mine
Add support for fetching user hosts from salt mine.
This commit is contained in:
commit
4cb99e9bd9
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)) %}
|
||||
{% 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 %}
|
||||
|
||||
{% set state_id = 'mysql_user_' ~ name ~ '_' ~ host%}
|
||||
|
|
|
@ -81,6 +81,15 @@ mysql:
|
|||
password: ~
|
||||
host: localhost
|
||||
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
|
||||
lookup:
|
||||
|
|
Loading…
Add table
Reference in a new issue