Skip to content
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

implement a detect_virt grain #387

Merged
merged 1 commit into from
Jul 17, 2024
Merged

implement a detect_virt grain #387

merged 1 commit into from
Jul 17, 2024

Conversation

ewdurbin
Copy link
Member

@ewdurbin ewdurbin commented Jul 17, 2024

This is useful for things we may not want or be able to run when operating in a docker container.

Specific example is systemd-timesyncd, which refuses to start in a container:

[Unit]
Description=Network Time Synchronization
Documentation=man:systemd-timesyncd.service(8)
ConditionCapability=CAP_SYS_TIME
ConditionVirtualization=!container
DefaultDependencies=no
...

Note the ConditionVirtualization blocking.

Useful state might be something like:

systemd-timesyncd:
  pkg:
    - installed
  service:
    - enabled
    {% if grains["detect_virt"] not in ["docker"] %}
    - running
    {% endif %}

Which would enable the service but not fail when it fails to start.

This is useful for things we may not want or be able to run when operating in a docker container.

Specific example is systemd-timesyncd, which refuses to start in a container:

```
[Unit]
Description=Network Time Synchronization
Documentation=man:systemd-timesyncd.service(8)
ConditionCapability=CAP_SYS_TIME
ConditionVirtualization=!container
DefaultDependencies=no
...
```

Note the `ConditionVirtualization` blocking.

Useful state might be something like:

```
systemd-timesyncd:
  pkg:
    - installed
  service:
    - enable: True
    {% if grains["detect_virt"] not in ["docker"] %}
    - running
    {% endif %}
```

Which would _enable_ the service but not fail when it fails to start.
@ewdurbin ewdurbin merged commit 4df4a07 into main Jul 17, 2024
2 checks passed
@ewdurbin ewdurbin deleted the detect_virt branch July 17, 2024 14:01
Copy link
Contributor

Don't forget to pull the latest changes on salt.nyc1.psf.io!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants