mirror of
https://github.com/saltstack-formulas/mysql-formula.git
synced 2025-04-17 10:10:30 +00:00
Add possibility of using another host (for db and user management)
This commit is contained in:
parent
1c9eb56949
commit
462c2f4034
5 changed files with 12 additions and 5 deletions
|
@ -2,6 +2,7 @@
|
||||||
{%- set mysql = salt['grains.filter_by'](rawmap, grain='os', merge=salt['pillar.get']('mysql:lookup')) %}
|
{%- set mysql = salt['grains.filter_by'](rawmap, grain='os', merge=salt['pillar.get']('mysql:lookup')) %}
|
||||||
|
|
||||||
{% set mysql_root_pass = salt['pillar.get']('mysql:server:root_password', salt['grains.get']('server_id')) %}
|
{% 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 = [] %}
|
{% set db_states = [] %}
|
||||||
|
|
||||||
include:
|
include:
|
||||||
|
@ -12,7 +13,7 @@ include:
|
||||||
{{ state_id }}:
|
{{ state_id }}:
|
||||||
mysql_database.present:
|
mysql_database.present:
|
||||||
- name: {{ database }}
|
- name: {{ database }}
|
||||||
- host: localhost
|
- connection_host: '{{ mysql_host }}'
|
||||||
- connection_user: root
|
- connection_user: root
|
||||||
{% if mysql_root_pass %}
|
{% if mysql_root_pass %}
|
||||||
- connection_pass: '{{ mysql_root_pass }}'
|
- connection_pass: '{{ mysql_root_pass }}'
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
{% set mysql_root_pass = salt['pillar.get']('mysql:server:root_password', salt['grains.get']('server_id')) %}
|
{% 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' %}
|
||||||
|
|
||||||
include:
|
include:
|
||||||
- mysql.python
|
- mysql.python
|
||||||
|
@ -6,7 +7,7 @@ include:
|
||||||
mysql remove test database:
|
mysql remove test database:
|
||||||
mysql_database.absent:
|
mysql_database.absent:
|
||||||
- name: test
|
- name: test
|
||||||
- host: localhost
|
- host: '{{ mysql_host }}'
|
||||||
- connection_user: root
|
- connection_user: root
|
||||||
{% if mysql_root_pass %}
|
{% if mysql_root_pass %}
|
||||||
- connection_pass: '{{ mysql_root_pass }}'
|
- connection_pass: '{{ mysql_root_pass }}'
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
{% set os = salt['grains.get']('os', None) %}
|
{% set os = salt['grains.get']('os', None) %}
|
||||||
{% set os_family = salt['grains.get']('os_family', None) %}
|
{% set os_family = salt['grains.get']('os_family', None) %}
|
||||||
{% set mysql_root_password = salt['pillar.get']('mysql:server:root_password', salt['grains.get']('server_id')) %}
|
{% 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') %}
|
||||||
|
|
||||||
{% if mysql_root_password %}
|
{% if mysql_root_password %}
|
||||||
{% if os_family == 'Debian' %}
|
{% if os_family == 'Debian' %}
|
||||||
|
@ -39,7 +40,7 @@ mysql_delete_anonymous_user_{{ host }}:
|
||||||
- absent
|
- absent
|
||||||
- host: {{ host or "''" }}
|
- host: {{ host or "''" }}
|
||||||
- name: ''
|
- name: ''
|
||||||
- connection_host: localhost
|
- connection_host: '{{ mysql_host }}'
|
||||||
- connection_user: root
|
- connection_user: root
|
||||||
- connection_pass: {{ mysql_root_password }}
|
- connection_pass: {{ mysql_root_password }}
|
||||||
- connection_charset: utf8
|
- connection_charset: utf8
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
{% from "mysql/defaults.yaml" import rawmap with context %}
|
{% 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 = salt['grains.filter_by'](rawmap, grain='os', merge=salt['pillar.get']('mysql:server:lookup')) %}
|
||||||
{%- set mysql_root_pass = salt['pillar.get']('mysql:server:root_password', 'somepass') %}
|
{%- set mysql_root_pass = salt['pillar.get']('mysql:server:root_password', 'somepass') %}
|
||||||
|
{%- set mysql_host = salt['pillar.get']('mysql:server:host', 'localhost') %}
|
||||||
|
|
||||||
{% set user_states = [] %}
|
{% set user_states = [] %}
|
||||||
{% set user_hosts = [] %}
|
{% set user_hosts = [] %}
|
||||||
|
@ -31,7 +32,7 @@ include:
|
||||||
{%- else %}
|
{%- else %}
|
||||||
- allow_passwordless: True
|
- allow_passwordless: True
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
- connection_host: localhost
|
- connection_host: '{{ mysql_host }}'
|
||||||
- connection_user: root
|
- connection_user: root
|
||||||
{% if mysql_root_pass %}
|
{% if mysql_root_pass %}
|
||||||
- connection_pass: '{{ mysql_root_pass }}'
|
- connection_pass: '{{ mysql_root_pass }}'
|
||||||
|
@ -47,7 +48,7 @@ include:
|
||||||
- grant_option: {{ db['grant_option'] | default(False) }}
|
- grant_option: {{ db['grant_option'] | default(False) }}
|
||||||
- user: {{ name }}
|
- user: {{ name }}
|
||||||
- host: '{{ host }}'
|
- host: '{{ host }}'
|
||||||
- connection_host: localhost
|
- connection_host: '{{ mysql_host }}'
|
||||||
- connection_user: root
|
- connection_user: root
|
||||||
{% if mysql_root_pass -%}
|
{% if mysql_root_pass -%}
|
||||||
- connection_pass: '{{ mysql_root_pass }}'
|
- connection_pass: '{{ mysql_root_pass }}'
|
||||||
|
|
|
@ -3,6 +3,9 @@ mysql:
|
||||||
# root_password: False - to have root@localhost without password
|
# root_password: False - to have root@localhost without password
|
||||||
root_password: 'somepass'
|
root_password: 'somepass'
|
||||||
user: mysql
|
user: mysql
|
||||||
|
# If you only manage the dbs and users and the server is on
|
||||||
|
# another host
|
||||||
|
host: 123.123.123.123
|
||||||
# my.cnf sections changes
|
# my.cnf sections changes
|
||||||
mysqld:
|
mysqld:
|
||||||
# you can use either underscore or hyphen in param names
|
# you can use either underscore or hyphen in param names
|
||||||
|
|
Loading…
Add table
Reference in a new issue