Fixes #560 - Add systemctl wants to foreman.target for httpd#561
Fixes #560 - Add systemctl wants to foreman.target for httpd#561qcjames53 wants to merge 1 commit into
Conversation
| [Install] | ||
| WantedBy=foreman.target | ||
| notify: Restart httpd | ||
| - name: Add httpd to foreman.target wants |
There was a problem hiding this comment.
This is how we do it for postgres -- https://github.com/theforeman/foremanctl/blob/master/src/roles/postgresql/tasks/main.yml#L37-L41 I think we are missing the default part.
There was a problem hiding this comment.
Funnily enough that is where I stole the original approach from. I'm not a systemd expert by any means but Claude is indicating there's a difference between postgresql and httpd because the former is a quadlet and the latter is an rpm installed drop-in service; allegedly systemd does not merge "[Install]" blocks for drop-in services.
Is httpd intended to also be a quadlet? If so that's a bigger fish to fry.
There was a problem hiding this comment.
systemd is systemd. And yes, it won't merge the sections, drop-ins overwrite the previous instance of it.
Have you tried this as the drop-in?
[Install]
WantedBy=default.target foreman.target
[Unit]
PartOf=foreman.target
There was a problem hiding this comment.
I'll report back on adding default.
There was a problem hiding this comment.
I rebuilt a box from scratch and lo and behold default.target fixed everything (/etc/systemd/system/foreman.target.wants/httpd.service was properly created on deploy). I've adjusted the role to match this. Thanks Eric!
| certificate_checks_certificate: "{{ server_certificate }}" | ||
| certificate_checks_key: "{{ server_key }}" | ||
| certificate_checks_ca: "{{ server_ca_certificate }}" | ||
| - role: systemd_target |
Why are you introducing these changes? (Problem description, related links)
When running systemctl start foreman.target, Apache (httpd) does not start on it's own. I attempted to include this as a part of the fix in #536 but biffed the implementation.
What are the changes introduced in this pull request?
foreman.target's wants to properly include httpd. The old add-wants block was skipped by systemctl due to httpd being in themulti-user.target(higher prio). This was fine unless the user manually wanted to runsystemctl stop foreman.targetandsystemctl start foreman.target, which might sometimes be the case.How to test this pull request
Steps to reproduce:
vagrant ssh quadletafter VM boot.systemctl list-dependencies foreman.targetto verify httpd made the list.systemctl stop foreman.targetandsystemctl status httpdto ensure it stopped.systemctl start foreman.targetandsystemctl status httpdto ensure it is running.Checklist