Skip to content

Latest commit

 

History

History
63 lines (44 loc) · 1.59 KB

File metadata and controls

63 lines (44 loc) · 1.59 KB

Example 1: Automatic management of services

Services in the list lp_service_auto will be automatically set according the below variables

lp_<service_name> ........... included if true (default=false)
lp_<service_name>_service ... Os specific name (see defaults and vars)
lp_<service_name>_enable .... enabled if true (default=false)
lp_<service_name>_state ..... started if true (default=<fn(enabled)>)
lp_<service_name>_module .... module used (default=auto)

For example, given the below variables, the service udev will be set enabled and started by module service

lp_udev: true
lp_udev_service: udev
lp_udev_enable: true
lp_udev_module: service

Create playbook

shell> cat lp.yml
- hosts: test_01
  become: true
  roles:
    - vbotka.linux_postinstall

Create variables

Create the file host_vars/test_01/lp-service.yml and create the list of services lp_service_auto that shall be managed by this task

shell> cat host_vars/test_01/lp-service.yml
lp_service_auto:
  - smart
  - udev

Hint

Use the variable lp_service to set other parameters.

Show variables

examples/service-ex1-debug.yaml.example

Manage the services and show the results

examples/service-ex1-manage.yaml.example