--- # The Service Module
- hosts: apacheweb
user: test
sudo: yes
connection: ssh
tasks:
- name: Install Web Server
action: yum name=httpd state=installed
- name: Start the Web Server
service: name=httpd state=started
- name: Stop the Web Server
service: name=httpd state=stopped
- name: Enable HTTPD After Reboot
service: name=httpd enabled=yes
其中隨開機啟動的設(shè)置很實用 如果選擇遠程配置 就不要做二次加工的事情。