前提:node1node2已经挂载好光盘且搭建好yum仓库

ansible实验:剧本,安装httpd服务_ansible

- name: install httpd
hosts: node1,node2,node3 #被控主机
remote_user: devops #用什么用户执行
gather_facts: false #获取主机信息
tasks:
- name: yum install httpd
yum:
name: httpd
state: present
- name: start httpd
systemd:
name: httpd
state: started
enabled: yes