ansible]# vim http.yml
---
- hosts: cache
remote_user: root
tasks:
- name: install one specific version of Apache
yum:
name: httpd //安装Apache
state: installed
- lineinfile:
path: /etc/httpd/conf/httpd.conf
regexp: '^Listen '
line: 'Listen 8080' //修改端口为8080
- replace:
path: /etc/httpd/conf/httpd.conf
regexp: '^#(ServerName).*' //配置ServerName
replace: '\1 localhost'
- service:
name: httpd
enabled: yes //开机自启
state: restarted
- copy:
src: /root/index.html //修改主页,可以自己写个页面
dest: /var/www/html/index.html
ansible]# ansible-playbook http.yml