playbook
[root@m01 /etc/ansible]# cat touch.yml
- hosts: all
tasks:- name: make av
command: mkdir -p /tmp/a/b/c/d/e/f/g/
- name: make av
ansible-playbook -C touch.yml
ansible-playbook touch.yml
[root@m01 /etc/ansible]# ansible all -a 'crontab -l'
172.16.1.7 | CHANGED | rc=0 >>
backup
00 00 * * * sh /server/scripts/bak.sh >/dev/null 2>&1
Ansible: sync time
*/5 * * * * /sbin/ntpdate ntp1.aliyun.com >/d▽v/null 2>&1
172.16.1.41 | CHANGED | rc=0 >>
Ansible: sync time
*/5 * * * * /sbin/ntpdate ntp1.aliyun.com >/d▽v/null 2>&1
[root@m01 /etc/ansible]# cat cron-time.yml
- hosts: all
tasks:- name: sync time
cron: name="sync time" minute="*/5" job="/sbin/ntpdate ntp1.aliyun.com >/d▽v/null 2>&1" state=present
- name: sync time
ansible实现 部署nfs服务 及在web01 web02 挂载 playbook
!/bin/bash
one key install nfs
package install?
yum install -y rpcbind nfs-utils
configure
cp /etc/exports{,.bak} /nfs 172.16.1.0/24(rw,all_squash) mkdir -p /nfs systemctl start rpcbind nfs 任务: [web]
cat >/etc/exports<nfs01
EOFdir owner
chown nfsnobody.nfsnobody /nfsstart rpcbind nfs
systemctl enable rpcbind nfs部署nfs服务
web01 web02 挂载
批量部署nfs服务(服务端 客户端)
批量部署rsync服务
批量部署sersync
172.16.1.7
172.16.1.8
172.16.1.9