role安装
ansible-galaxy install geerlingguy.mysql
修改配置
vars/main.yml:1
2
3
4
5
6
7
8
9
10mysql_root_password: super-secure-password
mysql_databases:
- name: example_db
encoding: utf8mb4
collation: utf8mb4_bin
mysql_users:
- name: example_user
host: "%"
password: similarly-secure-password
priv: "example_db.*:ALL"
playbook安装
install.yml1
2
3
4
5
6
7- hosts: dbservers
become: yes
vars_files:
- vars/main.yml
roles:
- { role: geerlingguy.mysql }
Inside
执行mysql安装
ansible-playbook install.yml