From 7a386578b7894201acda0b941850ce1ec90b5fab Mon Sep 17 00:00:00 2001 From: Nuno Esteves Date: Tue, 15 Aug 2017 22:49:44 +0100 Subject: [PATCH 1/2] Allow the use of wildcards on a user's database/table names when defining grants. --- mysql/user.sls | 1 + pillar.example | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/mysql/user.sls b/mysql/user.sls index 0b2fa18..b0f622e 100644 --- a/mysql/user.sls +++ b/mysql/user.sls @@ -97,6 +97,7 @@ include: {% endif %} - user: {{ name }} - host: '{{ host }}' + - escape: {{ db['escape'] | default(True) }} - connection_host: '{{ mysql_host }}' - connection_user: '{{ mysql_salt_user }}' {% if mysql_salt_pass -%} diff --git a/pillar.example b/pillar.example index 2b50a81..7f82ab2 100644 --- a/pillar.example +++ b/pillar.example @@ -85,6 +85,7 @@ mysql: databases: - database: foo grants: ['select', 'insert', 'update'] + escape: True - database: bar grants: ['all privileges'] bob: @@ -96,9 +97,10 @@ mysql: ssl-ISSUER: Name ssl-CIPHER: Cipher databases: - - database: foo + - database: "foo_%%" grants: ['all privileges'] grant_option: True + escape: False - database: bar table: foobar grants: ['select', 'insert', 'update', 'delete'] From e540589cb06da9d077943f953cd226f45ee0bcc2 Mon Sep 17 00:00:00 2001 From: Nuno Esteves Date: Tue, 18 Dec 2018 22:35:51 +0000 Subject: [PATCH 2/2] Include an example of using a wildcard with a reference to salt/saltstack#41178. Thanks to @scambra for the fix. --- pillar.example | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pillar.example b/pillar.example index 7f82ab2..21ebdfa 100644 --- a/pillar.example +++ b/pillar.example @@ -97,7 +97,11 @@ mysql: ssl-ISSUER: Name ssl-CIPHER: Cipher databases: - - database: "foo_%%" + # https://github.com/saltstack/salt/issues/41178 + # If you want to refer to databases using wildcards, turn off escape so + # the renderer does not escape them, enclose the string in '`' and + # use two '%' + - database: '`foo\_%%`' grants: ['all privileges'] grant_option: True escape: False