ansible.builtin.service – Manage services¶
Note
This module is part of ansible-base
and included in all Ansible
installations. In most cases, you can use the short module name
service even without specifying the collections:
keyword.
Despite that, we recommend you use the FQCN for easy linking to the module
documentation and to avoid conflicting with other collections that may have
the same module name.
New in version 0.1: of ansible.builtin
Synopsis¶
Controls services on remote hosts. Supported init systems include BSD init, OpenRC, SysV, Solaris SMF, systemd, upstart.
For Windows targets, use the ansible.windows.win_service module instead.
Note
This module has a corresponding action plugin.
Parameters¶
See Also¶
See also
- ansible.windows.win_service
The official documentation on the ansible.windows.win_service module.
Examples¶
- name: Start service httpd, if not started
ansible.builtin.service:
name: httpd
state: started
- name: Stop service httpd, if started
ansible.builtin.service:
name: httpd
state: stopped
- name: Restart service httpd, in all cases
ansible.builtin.service:
name: httpd
state: restarted
- name: Reload service httpd, in all cases
ansible.builtin.service:
name: httpd
state: reloaded
- name: Enable service httpd, and not touch the state
ansible.builtin.service:
name: httpd
enabled: yes
- name: Start service foo, based on running process /usr/bin/foo
ansible.builtin.service:
name: foo
pattern: /usr/bin/foo
state: started
- name: Restart network service for interface eth0
ansible.builtin.service:
name: network
state: restarted
args: eth0
Authors¶
Ansible Core Team
Michael DeHaan