Skip to content

Impossible to enable parameterized/templated systemd services #8444

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
uvsmtid opened this issue Nov 12, 2013 · 2 comments
Closed

Impossible to enable parameterized/templated systemd services #8444

uvsmtid opened this issue Nov 12, 2013 · 2 comments
Labels
Bug broken, incorrect, or confusing behavior help-wanted Community help is needed to resolve this

Comments

@uvsmtid
Copy link
Contributor

uvsmtid commented Nov 12, 2013

Example

The following state file for parameterized/templated openvpn service will fail with systemd:

openvpn:
    service.running:
        - name: [email protected]
        - enable: True

Service openvpn is parameterized/templated, and its unit file name [email protected] is different from instantiated service names like [email protected]:

systemctl enable [email protected]

Because Salt lists unit files before running any systemd command to manage services, it will report this problem:

[INFO    ] Executing command 'systemctl --full list-unit-files | col -b' in directory '/root'
[ERROR   ] The named service [email protected] is not available

Versions

Fedora 19 x86_64

salt --versions-report
           Salt: 0.17.1
         Python: 2.7.5 (default, Oct  8 2013, 12:19:40)
         Jinja2: 2.6
       M2Crypto: 0.21.1
 msgpack-python: 0.1.13
   msgpack-pure: Not Installed
       pycrypto: 2.6.1
         PyYAML: 3.10
          PyZMQ: 13.0.0
            ZMQ: 3.2.4
rpm -qf /bin/systemd
systemd-204-17.fc19.x86_64

See Also

The following issues seem related:

Links:

Workaround

For basic service management (enable/disable, start/stop) explicit systemctl commands can be used:

...
openvpn_enable:
    cmd.run:
        - name: "systemctl enable [email protected]"
        - require:
            - pkg: openvpn
            - file: /etc/openvpn/example.com.conf
            ...

openvpn_start:
    cmd.run:
        - name: "systemctl start [email protected]"
        - require:
            - cmd: openvpn_enable
...
@uvsmtid
Copy link
Contributor Author

uvsmtid commented Nov 12, 2013

I believe Salt should take optimistic approach and try to call systemctl enable for such parameterized/templated services regardless of any evidence that such service may be configured.

To give some protection and analytical output in the logs, before running the systemctl command, Salt may ensure that [email protected] unit file actually exists when it sees @ sign in strings like [email protected].

@basepi
Copy link
Contributor

basepi commented Dec 11, 2013

Wow, sorry we took so long to respond to this one! Somehow I missed it in my normal issue triage routine.

Looks like this is a pretty reasonable fix, we'll get it in! Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug broken, incorrect, or confusing behavior help-wanted Community help is needed to resolve this
Projects
None yet
Development

No branches or pull requests

3 participants