Skip to content

Fixes #560 - Add systemctl wants to foreman.target for httpd#561

Open
qcjames53 wants to merge 1 commit into
theforeman:masterfrom
qcjames53:560
Open

Fixes #560 - Add systemctl wants to foreman.target for httpd#561
qcjames53 wants to merge 1 commit into
theforeman:masterfrom
qcjames53:560

Conversation

@qcjames53

Copy link
Copy Markdown
Contributor

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?

  • Corrects foreman.target's wants to properly include httpd. The old add-wants block was skipped by systemctl due to httpd being in the multi-user.target (higher prio). This was fine unless the user manually wanted to run systemctl stop foreman.target and systemctl start foreman.target, which might sometimes be the case.

How to test this pull request

Steps to reproduce:

  1. Pull changes and rebuild the VMs.
  2. Run vagrant ssh quadlet after VM boot.
  3. Wait for services to spin up, then run systemctl list-dependencies foreman.target to verify httpd made the list.
  4. Run systemctl stop foreman.target and systemctl status httpd to ensure it stopped.
  5. Run systemctl start foreman.target and systemctl status httpd to ensure it is running.
  6. Validate unit test changes.

Checklist

  • Tests added/updated (if applicable)
  • Documentation updated (if applicable) N/A

Comment thread src/roles/httpd/tasks/main.yml Outdated
[Install]
WantedBy=foreman.target
notify: Restart httpd
- name: Add httpd to foreman.target wants

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll report back on adding default.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did this need to move?

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