diff --git a/src/roles/httpd/tasks/main.yml b/src/roles/httpd/tasks/main.yml index 649b31911..bbc3d633d 100644 --- a/src/roles/httpd/tasks/main.yml +++ b/src/roles/httpd/tasks/main.yml @@ -103,13 +103,11 @@ dest: /etc/systemd/system/httpd.service.d/foreman-target.conf mode: "0644" content: | + [Install] + WantedBy=default.target foreman.target [Unit] PartOf=foreman.target - [Install] - WantedBy=foreman.target - notify: Restart httpd - - name: Reload systemd daemon ansible.builtin.systemd: daemon_reload: true diff --git a/tests/httpd_test.py b/tests/httpd_test.py index 7fe1ddfa9..c086e683c 100644 --- a/tests/httpd_test.py +++ b/tests/httpd_test.py @@ -140,9 +140,13 @@ def test_httpd_headers_use_dashes(server): assert cmd.stdout.strip() == '', f"HTTP header names should use dashes, not underscores:\n{cmd.stdout}" -def test_httpd_foreman_target_drop_in(server): +def test_httpd_foreman_target_config(server): drop_in = server.file("/etc/systemd/system/httpd.service.d/foreman-target.conf") assert drop_in.exists assert drop_in.is_file assert drop_in.contains("PartOf=foreman.target") - assert drop_in.contains("WantedBy=foreman.target") + assert drop_in.contains(r"WantedBy=default\.target foreman\.target") + + wants_link = server.file("/etc/systemd/system/foreman.target.wants/httpd.service") + assert wants_link.exists + assert wants_link.is_symlink