手动部署rsync服务:
1.安装rsync
2.配置rsync(配置文件提前收集)
3.创建必要数据
创建用户
创建密码文件 权限
创建目录 修改权限
4.启动
[root@ansible ansible]# cat rsync.yml - name: Configure Rsync Server - name: Create Group www - name: Create www User - name: Create Password file - name: Create /backup dir - name: Start Rsync Server |
我们切换到 backup 上测试一下 rsync:
rsync -avz root@nfs:/root/1.txt . 在41主机上下载31家目录下的1.txt到当前目录
手动配置nfs
1.安装nfs
yum -y install nfs-utils
2.配置nfs
exports(提前准备)
3.创建必要数据信息
创建www用户
创建共享目录/data/blog 修改属主属组
4.启动nfs
[root@ansible ansible]# cat nfs.yml
- hosts: nfs
tasks:
- name: Install nfs-utils Server
yum:
name: nfs-utils
state: present
- name: Configure NFS Server
copy:
src: exports
dest: /etc/exports
- name: Create Group www
group:
name: www
gid: 666
- name: Create www User
user:
name: www
uid: 666
group: www
shell: /sbin/nologin
create_home: false
- name: Create /code/blog dir
file:
path: /code/blog
state: directory
owner: www
group: www
- name: Start NFS Server
systemd:
name: nfs
state: started
enabled: yes
客户端挂载NFS(wordpress业务)
[root@ansible ansible]# cat mysql.yml
- hosts: db01
tasks:
- name: Install Mariadb-Server
yum:
name:
- mariadb-server
- MySQL-python
state: present
- name: Start Mariadb Server
systemd:
name: mariadb
state: started
enabled: yes
- name: Copy all.sql to Remote Host DB01
copy:
src: all.sql
dest: /root/all.sql
- name: import all.sql
mysql_db:
login_host: localhost
login_port: 3306
login_user: root
name: all
state: import
target: /root/all.sql
- name: Restart MariaDB Server
systemd:
name: mariadb
state: restarted
欢迎来撩 : 汇总all