ansible使用yum源安装http服务

 时间:2026-04-23 06:46:24

1、部署两台centos7系统:

192.168.1.8作为ansible节点

192.168.1.4作为服务节点

ansible使用yum源安装http服务

2、在服务节点编写yum配置文件:                                        

[server]

name=server

baseurl=file:///mnt

gpgcheck=0

enabled=1                                                                       

ansible使用yum源安装http服务

3、在服务节点准备yum源

ansible使用yum源安装http服务

4、在ansible节点编写yml脚本:

---

- name: install

  hosts: 192.168.1.4

  tasks:

    - name: install http  #安装

      yum: 

        name: httpd

        state: latest

    - name: start httpd  #启动服务

      service: 

        name: httpd

        state: started

    - name: touch index file   #定义测试页面

      shell: echo "install httpd" > /var/www/html/index.html

ansible使用yum源安装http服务

5、执行yml脚本

ansible使用yum源安装http服务

6、从服务节点确认服务已安装成功并已启动

ansible使用yum源安装http服务

7、从ansible节点访问服务节点,确认访问内容是定义的内容,与预期一致,httpd服务安装成功

ansible使用yum源安装http服务

  • 老铁扎心了卖火柴的小女孩怎么过?
  • 老铁扎心了嫦娥奔月彩蛋
  • 老铁扎心了寒号鸟攻略
  • 老铁扎心了智擒鳌拜全部彩蛋
  • 《老铁扎心了2》第32关通关攻略
  • 热门搜索
    六一儿童节手抄报内容资料 手抄报的图案 小手牵大手手抄报 五四青年节手抄报内容 三爱手抄报图片 建军节手抄报内容20字 快乐的暑假手抄报 宪法手抄报图片大全 经典诵读手抄报图片 鲁迅的手抄报