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實(shí)現(xiàn) 部署nfs服務(wù) 及在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<<EOF

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服務(wù)

web01 web02 掛載

任務(wù):
批量部署nfs服務(wù)(服務(wù)端 客戶端)
批量部署rsync服務(wù)
批量部署sersync

[web]
172.16.1.7
172.16.1.8
172.16.1.9

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容