ansible代码实现远程部署httpd代码
时间: 2023-05-17 15:04:12 浏览: 98
可以使用Ansible的yum模块安装httpd,然后使用copy模块将httpd.conf文件复制到远程主机上,最后使用systemd模块启动httpd服务。以下是示例代码:
```
- name: Install httpd
yum:
name: httpd
state: present
- name: Copy httpd.conf
copy:
src: /path/to/httpd.conf
dest: /etc/httpd/conf/httpd.conf
- name: Start httpd
systemd:
name: httpd
state: started
```
注意:在运行此代码之前,需要确保已经在Ansible的inventory文件中定义了远程主机。
阅读全文