systemd_service - Add the machine parameter (#82958) - #82959
Conversation
|
The test |
8ceea6f to
ec6688e
Compare
bcoca
left a comment
There was a problem hiding this comment.
I would ask for tests but this seems to be very involved in setting up, I would at least add more verification to the parameter passed.
|
Hi, |
ec6688e to
f398017
Compare
|
@jimmy-lt All commits must have verified signatures. Please see this Ansible Forum post for more information. |
f398017 to
1da3284
Compare
pkingstonxyz
left a comment
There was a problem hiding this comment.
Looks good to me, but I'm torn on the issue of tests. I agree with @bcoca that this seems too convoluted to fully exercise in the integration test suite, but I don't think it's impossible to add something. The diff I pasted with the basic "current user+localhost" case would at least provide a smoke test if machine gets removed from a systemd version/is incompatible with the oldest supported target.
Something like v would do the trick without much overhead, I think.
@@ -112,11 +112,27 @@
enabled: true
register: systemd_enable_ssh_2
+- name: Disable ssh 2 with machine
+ systemd:
+ name: '{{ ssh_service }}'
+ enabled: false
+ machine: "@.host"
+ register: systemd_disable_ssh_2_machine
+
+- name: Enable ssh 2 with machine
+ systemd:
+ name: '{{ ssh_service }}'
+ enabled: true
+ machine: "@.host"
+ register: systemd_enable_ssh_2_machine
+
- assert:
that:
- systemd_disable_ssh_2 is not changed
- systemd_enable_ssh_1 is changed
- systemd_enable_ssh_2 is not changed
+ - systemd_disable_ssh_2_machine is changed
+ - systemd_enable_ssh_2_machine is changed
- import_tasks: test_unit_template.yml
- import_tasks: test_indirect_service.yml1da3284 to
9ce5902
Compare
7a1e193 to
daf3322
Compare
systemctl's `--machine` option execute the operation in the context of a local user session or a local container. This provides a failsafe way to run systemd on behalf of another user than setting the `XDG_RUNTIME_DIR` variable. Signed-off-by: Jimmy Thrasibule <dev@jimmy.lt>
daf3322 to
e75af5d
Compare
|
I've added the tests but for them to pass, |
Fixes #82958
systemctl's
--machineoption execute the operation in the context of a local user session or a local container.This provides a failsafe way to run systemd on behalf of another user than setting the
XDG_RUNTIME_DIRvariable.SUMMARY
When trying to run systemd as another user, the following is advised:
However, this may not always work and can fail in various ways, typically:
Since systemd 248, the
--machineoption is available to to open a connection to the session bus of a specific user.ISSUE TYPE
ADDITIONAL INFORMATION