ansible-service模块使用方法

应用

管理远程主机上的服务

参数

  • name:指定操作服务的名称
  • state=started|stopped|restarted|reloaded:指定服务的状态
  • enabled=yes|no:指定服务是否为开机启动项

示例

  1. 启动nginx服务
]# ansible all -m service -a 'name=nginx state=started'
  1. 停止nginx服务
]# ansible all -m service -a 'name=nginx state=stopped'
  1. 将nginx服务设置为开机启动项
]# ansible all -m service -a 'name=nginx enabled=yes'

猜你喜欢

转载自www.cnblogs.com/wanwz/p/12922991.html