ansible使用yum源安装http服务

2025-11-23 00:54:57

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服务

声明:本网站引用、摘录或转载内容仅供网站访问者交流或参考,不代表本站立场,如存在版权或非法内容,请联系站长删除,联系邮箱:site.kefu@qq.com。
猜你喜欢