可供选择的剧本:
案例1
- name: case 1
command: mysql -u root -p "MyNewPass_123" --execute="show databases;"结果:
"stdout_lines": ["Please use --connect-expired-password option or invoke mysql in interactive mode."]如果我将“--连接-过期-密码”添加到命令中,则会得到以下错误
ERROR 1820 (HY000) at line 1: You must reset your password using ALTER USER statement before executing this statement."案例2
- name: case 2
command: mysql -u root -p --execute="show databases;"结果:剧本等输入密码。
我该怎么做呢?
发布于 2020-12-18 09:30:07
首先安装星系集合:
ansible-galaxy collection install community.mysql在您可以使用模块community.mysql.mysql_query之后
- name: Select query to db acme with positional arguments
community.mysql.mysql_query:
login_user: root
login_password: MyNewPass_123
login_db: ${DB_TO_USE}
query: SELECT * FROM table WHERE id = %s AND param = %s
positional_args:
- 1
- test有关更多信息,请参阅:https://docs.ansible.com/ansible/latest/collections/community/mysql/mysql_query_module.html
https://stackoverflow.com/questions/65353589
复制相似问题