mirror of
https://github.com/saltstack-formulas/mysql-formula.git
synced 2025-04-16 09:40:26 +00:00
Allow to remove DB user
This commit is contained in:
parent
49e4a81956
commit
d1de0fdfc6
2 changed files with 26 additions and 14 deletions
|
@ -34,22 +34,28 @@ include:
|
|||
|
||||
{% set state_id = 'mysql_user_' ~ name ~ '_' ~ host%}
|
||||
{{ state_id }}:
|
||||
mysql_user.present:
|
||||
- name: {{ name }}
|
||||
- host: '{{ host }}'
|
||||
{%- if user['password_hash'] is defined %}
|
||||
- password_hash: '{{ user['password_hash'] }}'
|
||||
{%- elif user['password'] is defined and user['password'] != None %}
|
||||
- password: '{{ user['password'] }}'
|
||||
{%- if user.get('present', True) %}
|
||||
mysql_user.present:
|
||||
- name: {{ name }}
|
||||
- host: '{{ host }}'
|
||||
{%- if user['password_hash'] is defined %}
|
||||
- password_hash: '{{ user['password_hash'] }}'
|
||||
{%- elif user['password'] is defined and user['password'] != None %}
|
||||
- password: '{{ user['password'] }}'
|
||||
{%- else %}
|
||||
- allow_passwordless: True
|
||||
{%- endif %}
|
||||
{%- else %}
|
||||
- allow_passwordless: True
|
||||
mysql_user.absent:
|
||||
- name: {{ name }}
|
||||
- host: '{{ host }}'
|
||||
{%- endif %}
|
||||
- connection_host: '{{ mysql_host }}'
|
||||
- connection_user: '{{ mysql_salt_user }}'
|
||||
{% if mysql_salt_pass %}
|
||||
- connection_pass: '{{ mysql_salt_pass }}'
|
||||
{% endif %}
|
||||
- connection_charset: utf8
|
||||
- connection_host: '{{ mysql_host }}'
|
||||
- connection_user: '{{ mysql_salt_user }}'
|
||||
{%- if mysql_salt_pass %}
|
||||
- connection_pass: '{{ mysql_salt_pass }}'
|
||||
{%- endif %}
|
||||
- connection_charset: utf8
|
||||
|
||||
{%- if 'grants' in user %}
|
||||
{{ state_id ~ '_grants' }}:
|
||||
|
|
|
@ -143,6 +143,12 @@ mysql:
|
|||
- database: foo
|
||||
grants: ['select', 'insert', 'update']
|
||||
|
||||
# Remove a user
|
||||
obsoleteuser:
|
||||
host: localhost
|
||||
# defaults to True
|
||||
present: False
|
||||
|
||||
# Override any names defined in map.jinja
|
||||
# serverpkg: mysql-server
|
||||
# clientpkg: mysql-client
|
||||
|
|
Loading…
Add table
Reference in a new issue