安装httpd
- hosts: target_servers #针对target_servers组
tasks:
- name: 安装httpd #任务名称
yum: name=httpd state=installed #使用了yum模块
- name: httpd is running and enabled #任务名称
service: name=httpd state=started enabled=yes #使用了service模块查看httpd服务是否运行且开启自启动
查看是否安装成功
ansible target_servers -k -m shell -a "rpm -qa | grep httpd"
SSH password: 输入密码
ansible target_servers -k -m shell -a "systemctl list-unit-files | grep httpd"
SSH password:输入密码
卸载httpd
- hosts: target_servers
tasks:
- name: 卸载httpd #任务名称
yum: #使用yum模块
name: httpd
state: remove
- hosts: target_servers
tasks:
name: 卸载httpd #任务名称
shell: rpm -e httpd #使用shell模块
网友评论