一、ansible自动化部署
MySQL安装:playbook安装
httpd:使用roles角色
本次实验ansible目录下文件
[root@ansible-server ansible]# tree
.
├── ansible.cfg #ansible配置文件,当前目录下生效
├── files
│ ├── my.cnf #数据库配置文件
│ ├── mysql-5.7.33-linux-glibc2.12-x86_64.tar.gz #mysql数据库5.7.33压缩包
│ └── mysql-8.0.23-linux-glibc2.12-x86_64.tar.xz #mysql数据库8.0.23压缩包
├── hosts #主机清单
├── install_mysql5.7or8.0-lw.yml #数据库安装脚本
├── role_httpd.yml #apache安装脚本
├── roles
│ └── httpd
│ ├── files
│ │ └── httpd.conf #apache配置文件
│ ├── handlers
│ │ └── main.yml #
│ ├── tasks
│ │ ├── config.yml
│ │ ├── group.yml
│ │ ├── index.yml
│ │ ├── install.yml
│ │ ├── main.yml
│ │ ├── service.yml
│ │ └── user.yml
│ └── templates
│ └── index.html
└── test1.yml
7 directories, 18 files
[root@ansible-server ansible]# pwd
/data/ansible
[root@ansible-server ansible]# cat hosts
[websrvs]
10.0.0.28
10.0.0.38
[dbsrvs]
10.0.0.18
10.0.0.7
[local]
10.0.0.8 ansible_connection=ssh
[root@ansible-server ansible]# ansible --version
ansible 2.9.27
config file = /data/ansible/ansible.cfg
configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /usr/lib/python3.6/site-packages/ansible
executable location = /usr/bin/ansible
python version = 3.6.8 (default, Aug 24 2020, 17:57:11) [GCC 8.3.1 20191121 (Red Hat 8.3.1-5)]
[root@ansible-server ansible]# cat hosts
[websrvs]
10.0.0.28
10.0.0.38
[dbsrvs]
10.0.0.18
10.0.0.7
[local]
10.0.0.8 ansible_connection=ssh
1.1、ansible-playbook实现MySQL的二进制部署
[root@ansible-server ansible]# cat files/my.cnf
[mysqld]
server-id=1
log-bi