ansible 编写mysql_use模块的使用
今天使用ansible安装管理mariadb数据库的时候,碰到问题,在网上找不到对应的解决办法。然后自己查资料,终于写出,
查阅资料:编写如下脚本
[root@manager-161 playbook]# cat mysql.yaml
- hosts: mysql
tasks:
- name: install mariadb
yum: name=mariadb-devel,mariadb-server state=installed
- name: install python-devel pip
yum: name=python-devel,python2-pip state=installed
- name: shell mtsql-python
shell: 'pip install MySQL-python'
- name: statr mariadb
service: name=mariadb state=started enabled=yes
- mysql_user:
user: root
password: sf123
update_password: always
- name: create wordpress
mysql_db:
name: 'root'
login_host: 'localhost'
login_password: 'zsf123'
name: 'wordpress'
state: 'present'
- mysql_user:
user: 'root'
login_host: 'localhost'
login_password: 'zsf123'
user: 'zzsf'
password: 'zsf124'
priv: '*.*:ALL'
state: present
- mysql_user:
user: 'root'
login_host: 'localhost'
login_password: 'zsf123'
user: 'zzsf'
password: 'zsf124'
priv: '*.*:ALL'
host_all: yes
state: present
- mysql_db:
user: 'root'
login_host: 127.0.0.1
login_password: zsf123
name: lt
state: present
#mariadb安装之后没有密码,我们必须先更改root的密码
然后mysql需要安装mysql-python的模块
yum -y install python-devel,python2-pip
pip install mysql
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。
扫码关注腾讯云开发者
领取腾讯云代金券
Copyright © 2013 - 2025 Tencent Cloud. All Rights Reserved. 腾讯云 版权所有
深圳市腾讯计算机系统有限公司 ICP备案/许可证号:粤B2-20090059 深公网安备号 44030502008569
腾讯云计算(北京)有限责任公司 京ICP证150476号 | 京ICP备11018762号 | 京公网安备号11010802020287
Copyright © 2013 - 2025 Tencent Cloud.
All Rights Reserved. 腾讯云 版权所有