Giter VIP home page Giter VIP logo

systemd-formula's Introduction

systemd-formula

Travis CI Build Status Semantic Release

Formula to set up and configure systemd including
  • units
  • networkd
  • timesyncd
  • resolved
  • journald

See the full SaltStack Formulas installation and usage instructions.

If you are interested in writing or contributing to formulas, please pay attention to the Writing Formula Section.

If you want to use this formula, please pay attention to the FORMULA file and/or git tag, which contains the currently released version. This formula is versioned according to Semantic Versioning.

See Formula Versioning Section for more details.

Commit message formatting is significant!!

Please see How to contribute for more details.

Because systemd config files aren't easy to recreate in jinja based on multiple keys and different needs, I'm using TOFS.

Template Override and Files Switch (TOFS) pattern as described in the documentation file TOFS_pattern.md.

Note

See the full Salt Formulas doc.

Installs the systemd packages and libraries.

This state manages systemd-journald configuration

This state installs systemd-timesyncd and configures both NTP and timezone

This state installs systemd-timesyncd and adds the timesyncd.conf from pillar (see pillar.example)

This state installs systemd-networkd and recursively adds files per os_family/minion_id

This state installs systemd-networkd profile files from pillar (see pillar.example)

This state installs systemd-resolved and recursively adds files per os_family/minion_id

This state installs systemd-resolved and adds the resolved.conf from pillar (see pillar.example)

This formula provides a state to configure systemd units

Linux testing is done with kitchen-salt.

  • Ruby
  • Docker
$ gem install bundler
$ bundle install
$ bin/kitchen test [platform]

Where [platform] is the platform name defined in kitchen.yml, e.g. debian-9-2019-2-py3.

Creates the docker instance and runs the systemd main state, ready for testing.

Runs the inspec tests on the actual instance.

Removes the docker instance.

Runs all of the stages above in one go: i.e. destroy + converge + verify + destroy.

Gives you SSH access to the instance for manual testing.

systemd-formula's People

Contributors

aanriot avatar aboe76 avatar baby-gnu avatar dafyddj avatar javierbertoli avatar kossmac avatar myii avatar n-rodriguez avatar noelmcloughlin avatar r-pufky avatar semantic-release-bot avatar toanju avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

systemd-formula's Issues

systemd-formula don't create the service file in target system

I have created this Pillar file, based on https://github.com/saltstack-formulas/systemd-formula/blob/master/pillar.example:

systemd:
  service:
    test:
      enabled: true
      status: running
      Unit:
        Description: Test service
        After: network.target

      Service:
        ExecStart: osrm-routed /home/brick-osm/osrm-data/RU.osrm
        WorkingDirectory: /home/brick-osm/osrm-data
        User: brick-osm
        Group: brick-osm

      Install:
        WantedBy: multi-user.target

It's included successfully when applying configuration, and produce no errors. But as result, no service is created on target minion. Can you please help to find, where is can be the problem?

Maybe I need to add some additional required parameter to yaml for make this works? Or maybe move the service configuration to 'systemd.units' group?

OS: Ubuntu 20.04, Solr 3002.2+ds-1

[BUG] Formula try do start/stop multiinstance service - it won't work

https://www.stevenrombauts.be/2019/01/run-multiple-instances-of-the-same-systemd-unit/
I needed to start multiple instances of a single unit automatically with systemd, write config like this:

systemctl cat browser.target
[Install]
WantedBy=multi-user.target

[Unit]
After=network.target
Description=Chromium target
[email protected]
[email protected]
[email protected]

systemctl cat [email protected]
[Service]
ExecStart=some_command
Group=chromium
...
Type=simple

[Unit]
After=network.target
Description=Browser runner %i
PartOf=browser-runner.target

Multiinstance unit service didn't support enable/disable or start/stop (it's like a template). Start/stop or enable/disable I can only with target or explicitly given instances:

systemctl  status [email protected]
systemctl  is-enabled browser-runner.target

systemctl  status [email protected]
Failed to get properties: Unit name [email protected] is missing the instance name.

systemctl  status [email protected][email protected] - Browser runner 1
   Loaded: loaded (/etc/systemd/system/[email protected]; static; vendor preset: enabled)

In this code state try start start/stop only for service unittypes, but In my example it's need doing and for target unittypes. I think can be done like this:

-      {% if unittype == 'service' %}
-        {% set activation_status = unitconfig.status if unitconfig.status is defined and unitconfig.status == 'start' else 'stop' %}
+      {% if unittype == 'service' or unittype == 'target' %}
+      {% if unitconfig.status is defined %}
        {% set activation_status = unitconfig.status if unitconfig.status == 'start' else 'stop' %}
systemd_systemd_units_activate_or_deactivate_{{ unit }}_{{ unittype }}:
  cmd.wait:
    - name: systemctl {{ activation_status }} {{ unit }}.{{ unittype }}
...
+     {% endif %}

In pillar explicitly define status variable.

[FEATURE] manage systemd overrides

Is your feature request related to a problem?

Describe the solution you'd like

A way to manage systemd overrides in pillar.

Describe alternatives you've considered

Additional context

systemd-resolved bypassed by default on Debian and RedHat families

Hi,

Applying the systemd.resolved formula on Debian / RedHat nodes results in the /etc/resolv.conf symlink pointing to /run/systemd/resolve/resolv.conf, which forwards DNS queries to external DNS servers instead of the local systemd-resolved service.

Two observations:

  1. While symlinking /etc/resolv.conf to /run/systemd/resolve/resolv.conf is perfectly fine, it would result in systemd-resolved being bypassed by most DNS consumers. Since the systemd-resolved state explicitly configures and enables systemd-resolved, I suppose most people would also expect the state to also promote systemd-resolved as the main DNS resolver on the configured system.

  2. In osfamilymap.yaml, different defaults apply on Arch systems. On such systems, the /etc/resolv.conf symlink will be configured to target /run/systemd/resolve/stub-resolv.conf, which will result in systemd-resolved actually becoming the main DNS resolver.

Shouldn't we:

  1. Use the same defaults (whatever they might be) for all OS families ?

  2. Change the target of /etc/resolv.conf to /run/systemd/resolve/stub-resolv.conf to enable the use of systemd-resolved by default ?

[BUG] Formula try do enable for all unittypes

Formula support this unittypes - https://github.com/saltstack-formulas/systemd-formula/blob/master/systemd/units/unittypes.yaml.
In this state https://github.com/saltstack-formulas/systemd-formula/blob/master/systemd/units/init.sls#L21 formula try doing enable for all types, but it is not always possible to do this, for example:

systemctl cat browser.target
[Install]
WantedBy=multi-user.target

[Unit]
After=network.target
Description=Chromium target
[email protected]
[email protected]
[email protected]

systemctl cat [email protected]
[Service]
ExecStart=some_command
Group=chromium
...
Slice=chromium.slice
Type=simple

[Unit]
After=network.target
Description=Browser runner %i
PartOf=browser-runner.target


systemctl cat chromium.slice
[Slice]
MemoryLimit=20G

[Unit]
Before=slices.target
DefaultDependencies=False
Description=Limited resources for Chromiums

I can enable target unit, but this action not valid for the current config service(service with multiple instances) and slice units. Code where define unit_status. I think can be done like this:

systemd/units/init.sls
 -     {% set unit_status = 'disable' if unitconfig.enabled is defined and unitconfig.enabled == false else 'enable' %}
+ {#      {% set unit_status = 'disable' if unitconfig.enabled is defined and unitconfig.enabled == false else 'enable' %} #}
...
+      {% if unitconfig.enabled is defined %}
 +     {% set unit_status = 'disable' if unitconfig.enabled == false else 'enable' %}
systemd_systemd_units_cmd_enable_or_disable_{{ unit }}_{{ unittype }}:
  cmd.wait:
    - name: systemctl {{ unit_status }} {{ unit }}.{{ unittype }}
    - watch:
      - cmd: reload_systemd_configuration
+      {% endif %}

In pillar explicitly define enabled variable.
This way state will try enable only necessary unittypes.

enable_{{ unit }}_{{ unittype}} fails for systemd path units.

The enable state does not include the unittype, hence when creating a path based-unit, enable will fail, as systemctl assumes .service.

systemd:
  path:
    test_watch_changes:
      Path:
        PathModified: /path/to/monitor
        Unit: some_service_to_trigger.service
      Install:
        WantedBy: multi-user.target

This will result in the following error when applying the state:

----------
          ID: enable_test_watch_changes_path
    Function: cmd.wait
        Name: systemctl enable test_watch_changes
      Result: False
     Comment: Command "systemctl enable test_watch_changes" run
     Started: 19:19:58.136892
    Duration: 7.458 ms
     Changes:

Fix

Did a quick patch and tested with service, path definitions.

  | @@ -18,7 +18,7 @@ include:
-- | --
18 | 18 |  
19 | 19 | enable_{{ unit }}_{{ unittype }}:
20 | 20 | cmd.wait:
21 |   | -    - name: systemctl enable {{ unit }}
  | 21 | +    - name: systemctl enable {{ unit }}.{{ unittype }}
22 | 22 | - watch:
23 | 23 | - cmd: reload_systemd_configuration

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.