saltstack / saltstack/salt

systemd module misses some files when checking for new unit files

Open
#51,107 6 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

bug severity-medium
Dominant language
Python
Stars
15.7k
Forks
5.6k
Avg merge
2d 44m
Merged PRs (30d)
80

Description

Description of Issue/Question

The systemd module seems to only check for new unit files in /etc/systemd/system. This causes issues with new managed unit files that are placed in other valid locations for systemd. service.running and other related states fail to detect the new unit files and reload systemd before starting/stopping or otherwise managing services thus causing the entire state to fail.

There are multiple valid paths for unit files. Personally I was using /usr/local/lib/systemd/system/ (which seems to be ubuntu specific?) but the systemd.unit man page lists a bunch for both user and system modes. The three main system mode ones seem to be:

  • /etc/systemd/system
  • /run/systemd/system
  • /lib/systemd/system

The relevant code seems to be in _untracked_custom_unit_found() in modules/systemd.py:
https://github.com/saltstack/salt/blob/develop/salt/modules/systemd.py#L375

Setup
service-test:
  file.managed:
    - name: /usr/local/lib/systemd/system/blah.service
    - source: salt://blah.service
  service.running:
    - enable: true
    - require:
      - file: service-test
Versions Report
Salt Version:
           Salt: 2018.3.3
 
Dependency Versions:
           cffi: Not Installed
       cherrypy: Not Installed
       dateutil: 2.6.1
      docker-py: Not Installed
          gitdb: 2.0.3
      gitpython: 2.1.8
          ioflo: Not Installed
         Jinja2: 2.10
        libgit2: Not Installed
        libnacl: Not Installed
       M2Crypto: Not Installed
           Mako: 1.0.7
   msgpack-pure: Not Installed
 msgpack-python: 0.5.6
   mysql-python: Not Installed
      pycparser: Not Installed
       pycrypto: 2.6.1
   pycryptodome: Not Installed
         pygit2: Not Installed
         Python: 2.7.15rc1 (default, Nov 12 2018, 14:31:15)
   python-gnupg: 0.4.1
         PyYAML: 3.12
          PyZMQ: 16.0.2
           RAET: Not Installed
          smmap: 2.0.3
        timelib: Not Installed
        Tornado: 4.5.3
            ZMQ: 4.2.5
 
System Versions:
           dist: Ubuntu 18.04 bionic
         locale: UTF-8
        machine: x86_64
        release: 4.15.0-43-generic
         system: Linux
        version: Ubuntu 18.04 bionic
 

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in salt/modules/systemd.py at _untracked_custom_unit_found(), then compare its checks with the systemd.unit paths listed in the issue. Reproduce the service-test setup using /usr/local/lib/systemd/system/blah.service and verify service.running detects the new unit and reloads systemd before managing it.

Written by the indexing model from the issue text.

Assessment

Tech stack
linux, python
Domain
devops, infrastructure
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.