Ansible
2.模块的使用
authorized_key模块添加sshkey认证
YUM模块的使用
COPY模块的使用
file
cron
firewalld
pam_limits
mysql_db
mysql_user
selinux
sysctl
yum
3.playbooks
初始化新安装CentOS7
模块文档工具ansible-doc
shell+register+when+模块RETURN变量
本文档使用 MrDoc 发布
-
+
首页
mysql_user
需要mysql服务器安装python模块 PyMySQL (Python 2.7 and Python 3.X) MySQLdb (Python 2.x) # mysql_user ## 删除匿名用户 ```yaml - name: 清理全部匿名用户 mysql_user: config_file: '{{ MYSQL_CONFIG_FILE }}' login_user: root login_password: '{{ MYSQL_ROOT_PWD }}' name: '' host_all: yes state: absent - name: 创建ro,rw用户 mysql_user: config_file: '{{ MYSQL_CONFIG_FILE }}' login_user: root login_password: '{{ MYSQL_ROOT_PWD }}' name: '{{ item.user }}' password: '{{ item.pwd }}' priv: '{{ item.priv }}' update_password: always host: '%' state: present with_items: - { "user": '{{ MYSQL_UQER_RO_USER }}', "pwd": '{{ MYSQL_UQER_RO_PWD }}', "priv": '{{ MYSQL_UQER_RO_PRIV }}' } - { "user": '{{ MYSQL_UTS_RW_USER }}', "pwd": '{{ MYSQL_UTS_RW_PWD }}', "priv": '{{ MYSQL_UTS_RW_PRIV }}' } ``` ## 帮助文档 `ansible-doc mysql_user` ```yaml EXAMPLES: - name: Removes anonymous user account for localhost mysql_user: name: '' host: localhost state: absent - name: Removes all anonymous user accounts mysql_user: name: '' host_all: yes state: absent - name: Create database user with name 'bob' and password '12345' with all database privileges mysql_user: name: bob password: 12345 priv: '*.*:ALL' state: present - name: Create database user using hashed password with all database privileges mysql_user: name: bob password: '*EE0D72C1085C46C5278932678FBE2C6A782821B4' encrypted: yes priv: '*.*:ALL' state: present - name: Create database user with password and all database privileges and 'WITH GRANT OPTION' mysql_user: name: bob password: 12345 priv: '*.*:ALL,GRANT' state: present # Note that REQUIRESSL is a special privilege that should only apply to *.* by itself. - name: Modify user to require SSL connections. mysql_user: name: bob append_privs: yes priv: '*.*:REQUIRESSL' state: present - name: Ensure no user named 'sally'@'localhost' exists, also passing in the auth credentials. mysql_user: login_user: root login_password: 123456 name: sally state: absent - name: Ensure no user named 'sally' exists at all mysql_user: name: sally host_all: yes state: absent - name: Specify grants composed of more than one word mysql_user: name: replication password: 12345 priv: "*.*:REPLICATION CLIENT" state: present - name: Revoke all privileges for user 'bob' and password '12345' mysql_user: name: bob password: 12345 priv: "*.*:USAGE" state: present # Example privileges string format # mydb.*:INSERT,UPDATE/anotherdb.*:SELECT/yetanotherdb.*:ALL - name: Example using login_unix_socket to connect to server mysql_user: name: root password: abc123 login_unix_socket: /var/run/mysqld/mysqld.sock - name: Example of skipping binary logging while adding user 'bob' mysql_user: name: bob password: 12345 priv: "*.*:USAGE" state: present sql_log_bin: no # Example .my.cnf file for setting the root password # [client] # user=root # password=n<_665{vS43y ```
zhangky
2022年3月2日 11:33
分享文档
收藏文档
上一篇
下一篇
微信扫一扫
复制链接
手机扫一扫进行分享
复制链接
关于 MrDoc
觅思文档MrDoc
是
州的先生
开发并开源的在线文档系统,其适合作为个人和小型团队的云笔记、文档和知识库管理工具。
如果觅思文档给你或你的团队带来了帮助,欢迎对作者进行一些打赏捐助,这将有力支持作者持续投入精力更新和维护觅思文档,感谢你的捐助!
>>>捐助鸣谢列表
微信
支付宝
QQ
PayPal
Markdown文件
分享
链接
类型
密码
更新密码