[root@cs-proxy ~]# mkdir -p web-site
[root@cs-proxy ~]# cd web-site
[root@cs-proxy ~]# vim ansible.cfg
[defaults]
inventory = hostlist
host_key_checking = False
[root@ecs-proxy ~]# vim hostlist
[web]
192.168.1.[11:13]
[nfs]
192.168.1.100
[root@ecs-proxy ~]# vim install.yaml
---
- name: nfs install
hosts: nfs
tasks:
- name: install nfs-utils
yum:
name: nfs-utils
state: latest
update_cache: yes
- name: Creates directory
file:
path: /var/www/html
state: directory
owner: root
group: root
mode: 0777
recurse: yes
- name: config exports
copy:
dest: /etc/exports
content: |
/var/www/html *(rw)
- name: enable nfs service
service:
name: nfs
state: started
enabled: yes
- name: web install
hosts: web
tasks:
- name: install nfs-utils
yum:
name:
- httpd
- php
- nfs-utils
state: latest
update_cache: yes
- name: enable nfs service
service:
name: httpd
state: started
enabled: yes
- name: Mount nfs server
mount:
src: 192.168.1.100:/var/www/html
path: /var/www/html
fstype: nfs
state: mounted
[root@cs-proxy ~]# ansible-playbook install.yaml