gpt4 book ai didi

mysql - Ansible设置root用户密码

转载 作者:行者123 更新时间:2023-11-29 05:16:23 25 4
gpt4 key购买 nike

我是ansible的新手,我需要在服务器上安装mysql,因为我写了一个剧本

---

- hosts: webservice
tasks:
- name: Install MYSQL Server
apt: name=mysql-server update_cache=yes state=latest

- name: Install MYSQL Client
apt: name=mysql-client update_cache=yes state=latest

它安装成功,但我想写 ansible playbook,其中提到了 mysql root 密码,我该怎么做。

最佳答案

您尝试过 mysql_user module 吗? ?

- mysql_user: name="root"
password="your-NEW-password"
check_implicit_admin=yes
login_user="root"
login_password=""
state=present

使用空白密码,不确定模块期望什么。如果失败,请尝试删除带有 login_password 的行。

它需要远程主机上的 MySQLdb Python 包。对于 Ubuntu,此命令将起作用:apt-get install python-mysqldb,或作为 Ansible 任务:

- apt: name=python-mysqldb
state=present

关于mysql - Ansible设置root用户密码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32213427/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com