Skip to content

Commit

Permalink
Adhoc (post import sql) Do not print pw
Browse files Browse the repository at this point in the history
As ansible is printing the passwords into the log,
we need to prevent this to happen. Therefor we
disable logging, save the output to a variable
and remove the password from the output before
printing it.

This also fixes a syntax error.
  • Loading branch information
Zeno F. Pensky committed Jul 1, 2019
1 parent aa67118 commit 107fc02
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion tasks/post_import.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
---
- name: "Execute sql query"
command: >
mysql --user=root --password={{ import_db_root_password }}" {{ import_db_database_name }}"
env MYSQL_PWD={{ import_db_root_password }}
mysql --user=root {{ import_db_database_name }}
--execute="{{ import_db_post_import_sql_query.query }}"
no_log: true
ignore_errors: true
register: import_db_post_import_sql_query_result

- debug:
msg: '{{ import_db_post_import_sql_query_result.stderr | regex_replace(import_db_root_password) }}'
when: import_db_post_import_sql_query_result.stderr != ""

- debug:
msg: '{{ import_db_post_import_sql_query_result.stdout | regex_replace(import_db_root_password) }}'
when: import_db_post_import_sql_query_result.stdout != ""

- fail:
msg: "error in sql querry"
when: import_db_post_import_sql_query_result.stderr != ""

0 comments on commit 107fc02

Please sign in to comment.