Stop and disable services on boot on Linux remote hosts — Ansible module service_facts, service

How to list the available Linux services and automate the stop and disable service on boot process with Ansible playbook. Included code and demo with “chronyd.service” NTP server on a RedHat Enterprise Linux 8.

Ansible Pilot
6 min readDec 1, 2021


How to stop and disable services on boot on Linux remote hosts with Ansible?
I’m going to show you a live demo with some simple Ansible code.
I’m Luca Berton and welcome to today’s episode of Ansible Pilot.

Ansible enable services on boot on remote hosts

  • ansible.builtin.service_facts
  • Return service state information as fact data
  • ansible.builtin.service
  • Manage services

Today we’re talking about Ansible modules service_facts and service.
First, you need to acquire the information of the services on the target machine.
This task is performed by the Ansible module service_facts. You can’t enable a service that doesn’t exist, can you?
The effective actions are performed by the Ansible module service.
The full name is `ansible.builtin.service` which means that both these modules are part of the collection of modules “builtin” with Ansible and shipped with it.
This module is pretty stable and out for years and its purpose is to manage services on remote hosts.
For Windows targets, use the `` module instead.


  • name path — name of the service
  • state string — started / stopped / restarted / reloaded
  • enabled boolean — no/yes
  • arguments/args string — extra args

The parameter list is pretty wide but I’ll summarize the most useful.



Ansible Pilot

I help creative Automation DevOps, Cloud Engineer, System Administrator, and IT Professional to succeed with Ansible Technology to automate more things everyday