Ansible自动化运维----部署http(命令行方式)

本文介绍了如何使用Ansible通过命令行方式向远程主机部署Apache服务,包括安装httpd,配置防火墙允许HTTP服务,以及传输配置文件,确保在目标主机上能够正常运行并可以通过浏览器访问。
摘要由CSDN通过智能技术生成

Ansible主机已经安装完成Ansible自动化运维----yum源的方式安装ansible(国内镜像)
现在我们来尝试用ansible向远程主机172.25.65.11 \ 172.25.65.12部署Apache服务

[devops@server10 ansible]# cat hosts
[test]
172.25.65.11
172.25.65.12
  • 使用下面命令对组test中的主机安装httpd
[devops@server10 ansible]# ansible test -m yum -a "name=httpd state=present"

-m:接方式
-a:command
state:present 状态表示安装

  • 使用下面命令允许组test中的主机的火墙接受http服务
[root@server10 ansible]# ansible test -m firewalld -a "service=http state=enabled"
server11 | CHANGED => {
    "ansible_facts": {
        "discovered_interpreter_python": "/usr/bin/python"
    }, 
    "changed": true, 
    "msg": "Non-permanent operati
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值