mirror of
https://github.com/saltstack-formulas/mysql-formula.git
synced 2025-04-15 17:20:25 +00:00
Merge pull request #71 from irtnog/connect-with-users-other-than-root
Allow changing connection_user by setting the 'mysql:server:root_user…
This commit is contained in:
commit
83aa37f055
5 changed files with 14 additions and 6 deletions
|
@ -1,6 +1,7 @@
|
|||
{% from "mysql/defaults.yaml" import rawmap with context %}
|
||||
{%- set mysql = salt['grains.filter_by'](rawmap, grain='os', merge=salt['pillar.get']('mysql:lookup')) %}
|
||||
|
||||
{% set mysql_root_user = salt['pillar.get']('mysql:server:root_user', 'root') %}
|
||||
{% set mysql_root_pass = salt['pillar.get']('mysql:server:root_password', salt['grains.get']('server_id')) %}
|
||||
{% set mysql_host = salt['pillar.get']('mysql:server:host', 'localhost') %}
|
||||
{% set db_states = [] %}
|
||||
|
@ -14,7 +15,7 @@ include:
|
|||
mysql_database.present:
|
||||
- name: {{ database }}
|
||||
- connection_host: '{{ mysql_host }}'
|
||||
- connection_user: root
|
||||
- connection_user: '{{ mysql_root_user }}'
|
||||
{% if mysql_root_pass %}
|
||||
- connection_pass: '{{ mysql_root_pass }}'
|
||||
{% endif %}
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
{% set mysql_root_user = salt['pillar.get']('mysql:server:root_user', 'root') %}
|
||||
{% set mysql_root_pass = salt['pillar.get']('mysql:server:root_password', salt['grains.get']('server_id')) %}
|
||||
{% set mysql_host = salt['pillar.get']('mysql:server:host', 'localhost') %}
|
||||
|
||||
|
@ -8,7 +9,7 @@ mysql remove test database:
|
|||
mysql_database.absent:
|
||||
- name: test
|
||||
- host: '{{ mysql_host }}'
|
||||
- connection_user: root
|
||||
- connection_user: '{{ mysql_root_user }}'
|
||||
{% if mysql_root_pass %}
|
||||
- connection_pass: '{{ mysql_root_pass }}'
|
||||
{% endif %}
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
{% set os = salt['grains.get']('os', None) %}
|
||||
{% set os_family = salt['grains.get']('os_family', None) %}
|
||||
{% set mysql_root_user = salt['pillar.get']('mysql:server:root_user', 'root') %}
|
||||
{% set mysql_root_password = salt['pillar.get']('mysql:server:root_password', salt['grains.get']('server_id')) %}
|
||||
{% set mysql_host = salt['pillar.get']('mysql:server:host', 'localhost') %}
|
||||
|
||||
|
@ -41,8 +42,10 @@ mysql_delete_anonymous_user_{{ host }}:
|
|||
- host: {{ host or "''" }}
|
||||
- name: ''
|
||||
- connection_host: '{{ mysql_host }}'
|
||||
- connection_user: root
|
||||
- connection_pass: {{ mysql_root_password }}
|
||||
- connection_user: '{{ mysql_root_user }}'
|
||||
{% if mysql_root_password %}
|
||||
- connection_pass: '{{ mysql_root_password }}'
|
||||
{% endif %}
|
||||
- connection_charset: utf8
|
||||
- require:
|
||||
- service: mysqld
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
{% from "mysql/defaults.yaml" import rawmap with context %}
|
||||
{%- set mysql = salt['grains.filter_by'](rawmap, grain='os', merge=salt['pillar.get']('mysql:server:lookup')) %}
|
||||
{%- set mysql_root_user = salt['pillar.get']('mysql:server:root_user', 'root') %}
|
||||
{%- set mysql_root_pass = salt['pillar.get']('mysql:server:root_password', 'somepass') %}
|
||||
{%- set mysql_host = salt['pillar.get']('mysql:server:host', 'localhost') %}
|
||||
|
||||
|
@ -33,7 +34,7 @@ include:
|
|||
- allow_passwordless: True
|
||||
{%- endif %}
|
||||
- connection_host: '{{ mysql_host }}'
|
||||
- connection_user: root
|
||||
- connection_user: '{{ mysql_root_user }}'
|
||||
{% if mysql_root_pass %}
|
||||
- connection_pass: '{{ mysql_root_pass }}'
|
||||
{% endif %}
|
||||
|
@ -49,7 +50,7 @@ include:
|
|||
- user: {{ name }}
|
||||
- host: '{{ host }}'
|
||||
- connection_host: '{{ mysql_host }}'
|
||||
- connection_user: root
|
||||
- connection_user: '{{ mysql_root_user }}'
|
||||
{% if mysql_root_pass -%}
|
||||
- connection_pass: '{{ mysql_root_pass }}'
|
||||
{% endif %}
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
mysql:
|
||||
server:
|
||||
# Use this account for database admin (defaults to root)
|
||||
root_user: 'admin'
|
||||
# root_password: False - to have root@localhost without password
|
||||
root_password: 'somepass'
|
||||
user: mysql
|
||||
|
|
Loading…
Add table
Reference in a new issue