# rsync 安装与配置
~~~
---
- hosts: 10.0.0.22
tasks:
- name: ensure rsync is at the latest version
yum:
name: rsync
state: latest
- name: add rsync user
user:
name: rsync
shell: /sbin/nologin
create_home: no
- name: copy rsyncd.conf to desc
copy:
src: /server/files/rsyncd.conf
dest: /etc/rsyncd.conf
- name: set password file
copy:
content: 'rsync_backup:123456'
dest: /etc/rsync.password
mode: 0600
- name: make backup dir
file:
path: /backup
state: directory
owner: rsync
group: rsync
- name: autorun
shell: 'echo "/usr/bin/rsync --daemon" >>/etc/rc.local'
~~~
~~~
#模板
---
- hosts: webservers
vars:
http_port: 80
max_clients: 200
remote_user: root
tasks:
- name: ensure apache is at the latest version
yum:
name: httpd
state: latest
- name: write the apache config file
template:
src: /srv/httpd.j2
dest: /etc/httpd.conf
notify:
- restart apache
- name: ensure apache is running
service:
name: httpd
state: started
handlers:
- name: restart apache
service:
name: httpd
state: restarted
~~~