Ansible 之 ansible的模块使用帮助
16lz
2021-01-22
一、查看所有模板
[root@Ansible ~]# ansible-doc -l 查看所有模块[root@Ansible ~]# ansible-doc -l | grep -w "service"service Manage services
二、查看相关模块的使用文档
[root@Ansible ~]# ansible-doc service> SERVICE (/usr/lib/python2.7/site-packages/ansible/modules/system/service.py) Controls services on remote hosts. Supported init systems include BSD init, OpenRC, SysV, Solaris SMF, systemd, upstart. For Windows targets, use the [win_service] module instead. * This module is maintained by The Ansible Core Team * note: This module has a corresponding action plugin.OPTIONS (= is mandatory):- arguments Additional arguments provided on the command line. (Aliases: args)[Default: (null)] type: str- enabled Whether the service should start on boot. *At least one of state and enabled are required.* [Default: (null)] type: bool= name Name of the service. type: str- pattern If the service does not respond to the status command, name a substring to look for as would be found in the output of the `ps' command as a stand-in for a status result. If the string is found, the service will be assumed to be started. [Default: (null)] type: str version_added: 0.7- runlevel For OpenRC init scripts (e.g. Gentoo) only. The runlevel that this service belongs to. [Default: default] type: str- sleep If the service is being `restarted' then sleep this many seconds between the stop and start command. This helps to work around badly-behaving init scripts that exit immediately after signaling a process to stop. Not all service managers support sleep, i.e when using systemd this setting will be ignored. [Default: (null)] type: int version_added: 1.3- state `started'/`stopped' are idempotent actions that will not run commands unless necessary. `restarted' will always bounce the service. `reloaded' will always reload. *At least one of state and enabled are required.* Note that reloaded will start the service if it is not already started, even if your chosen init system wouldn't normally. (Choices: reloaded, restarted, started, stopped)[Default: (null)] type: str- use The service module actually uses system specific modules, normally through auto detection, this setting can force a specific module. Normally it uses the value of the 'ansible_service_mgr' fact and falls back to the old 'service' module when none matching is found. [Default: auto] type: str version_added: 2.2
三、service 模块使用
ansible songxin_test -m service -a "name=ntpd.service state=started enabled=yes" -u cedar -b-m service : 使用service模块-a : 输入模块的参数name=ntpd.service 服务名state=stared 启动服务enabled=yes 开机启动
©著作权归作者所有:来自51CTO博客作者wx592bc92b285c7的原创作品,如需转载,请注明出处,否则将追究法律责任你的鼓励让我更有动力
赞赏
0人进行了赞赏支持
更多相关文章
- Ansible 之 通过yum模块安装软件
- 附实战代码|告别OS模块,体验Python文件操作新姿势!
- 13个知识点,系统整理Python时间处理模块Datetime
- Python实现数据写入 Excel 的三种模块!
- Ansible 之 lineinfile 模块使用
- Seata RPC 模块的重构之路
- 偷学Python第二十九|time模块和calendar模块详细用法
- 万字长文详解Python正则表达式及re模块
- 偷学Python二十六|OS.path模块的详细使用说明