问题原文
原帖链接 · claus · CC BY-SA 3.0
I am setting up a MySQL server and want Ansible to set the mysql-root password during installation.
With the help of the internet I came up with this solution:
- name: Set MySQL root password before installing
debconf: name='mysql-server' question='mysql-server/root_password' value='{{mysql_root_pwd | quote}}' vtype='password'
- name: Confirm MySQL root password before installing
debconf: name='mysql-server' question='mysql-server/root_password_again' value='{{mysql_root_pwd | quote}}' vtype='password'
- name: Install Mysql
apt: pkg=mysql-server state=latest
mysql_root_pwd is a variable loaded from the Ansible Vault. This runs fine, but now on the server there are many lines in the log:
Apr 10 14:39:59 servername ansible-debconf: Invoked with value=THEPASSWORD vtype=password question=mysql-server/root_password name=mysql-server unseen=None
Apr 10 14:39:59 servername ansible-debconf: Invoked with value=THEPASSWORD vtype=password question=mysql-server/root_password_again name=mysql-server unseen=None
How can I stop Ansible from writing clear text passwords to the logfiles?
社区高分解答
原帖链接 · Bill Carlson · CC BY-SA 4.0
To prevent a task with confidential information from being logged, in syslog or other, set no_log: true on the task:
- name: secret stuff
command: "echo {{secret_root_password}} | sudo su -"
no_log: true
The running of the task will still be logged, but with little details. Also, the module used has to support no_log, so test custom modules.
See Ansible FAQ for further details. It can be applied to an entire playbook, however the output gets a little nasty with "censored!" messages.
摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。
