2019-05-29playbook

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/

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

ansible实现 部署nfs服务 及在web01 web02 挂载 playbook

!/bin/bash

one key install nfs

package install?

yum install -y rpcbind nfs-utils

configure

cp /etc/exports{,.bak}
cat >/etc/exports<

nfs01

/nfs 172.16.1.0/24(rw,all_squash)
EOF

dir owner

mkdir -p /nfs
chown nfsnobody.nfsnobody /nfs

start rpcbind nfs

systemctl start rpcbind nfs
systemctl enable rpcbind nfs

部署nfs服务

web01 web02 挂载

任务:
批量部署nfs服务(服务端 客户端)
批量部署rsync服务
批量部署sersync

[web]
172.16.1.7
172.16.1.8
172.16.1.9

你可能感兴趣的:(2019-05-29playbook)