ansible 远程rpm/服务管理

yum模块

远程主机yum管理

格式:

ansible <host> -m yum -a "name=. state=."
  • name :要安装的软件包名

  • state :安装选项,默认为present

    • present | installed :安装

    • absent | remove :删除

    • latest :升级到最新

[root@localhost ~]# ansible 192.168.127.129 -m yum -a "name=httpd state=installed"

service模块

远程主机服务管理

格式:

ansible <host> -m service -a "name=. state=. enabled=."
  • name :服务名

  • state :操作选项,started | stopped | restarted | reloaded

  • enabled :开机启动,yes | no

[root@localhost ~]# ansible 192.168.127.129 -m service -a "name=httpd state=started enabled=yes"

最后更新于

这有帮助吗?