From 1a87e7455f860e5515d82d383442b1c047381c74 Mon Sep 17 00:00:00 2001 From: Daniel Wallace Date: Mon, 7 May 2018 08:31:54 -0500 Subject: [PATCH] allow pulling the mysql_query.run_file to pull from the fileserver --- salt/states/mysql_query.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/salt/states/mysql_query.py b/salt/states/mysql_query.py index b2ea6c1c3c..a558b7c46e 100644 --- a/salt/states/mysql_query.py +++ b/salt/states/mysql_query.py @@ -56,10 +56,13 @@ def run_file(name, grain=None, key=None, overwrite=True, + saltenv=None, **connection_args): ''' Execute an arbitrary query on the specified database + .. versionadded:: 2017.7.0 + name Used only as an ID @@ -84,13 +87,17 @@ def run_file(name, overwrite: The file or grain will be overwritten if it already exists (default) - .. versionadded:: 2017.7.0 + saltenv: + The saltenv to pull the query_file from ''' ret = {'name': name, 'changes': {}, 'result': True, 'comment': 'Database {0} is already present'.format(database)} + if any([query_file.startswith(proto) for proto in ['http://', 'https://', 'salt://', 's3://', 'swift://']]): + query_file = __salt__['cp.cache_file'](query_file, saltenv=saltenv or __env__) + if not os.path.exists(query_file): ret['comment'] = 'File {0} does not exist'.format(query_file) ret['result'] = False