Skip to content
This repository has been archived by the owner on Jan 30, 2024. It is now read-only.

Commit

Permalink
Enable single systemd service for Pulp
Browse files Browse the repository at this point in the history
closes #7006
  • Loading branch information
fao89 committed Sep 20, 2021
1 parent 5d4a71e commit bb90558
Show file tree
Hide file tree
Showing 9 changed files with 52 additions and 23 deletions.
1 change: 1 addition & 0 deletions CHANGES/7006.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Added a single systemd service to restart Pulp
4 changes: 4 additions & 0 deletions roles/pulp_api/templates/pulpcore-api.service.j2
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
Description=Pulp WSGI Server
After=network-online.target
Wants=network-online.target
# When systemd stops or restarts the meta pulpcore.service, the action is propagated to this service
PartOf=pulpcore.service
# Start this service after the pulpcore.service starts
After=pulpcore.service

[Service]
Type=notify
Expand Down
24 changes: 2 additions & 22 deletions roles/pulp_common/handlers/restart_all_pulp.yml
Original file line number Diff line number Diff line change
@@ -1,29 +1,9 @@
---
# We cannot pass wildcards to the systemd module, so we have
# this hack for our dynamic include_roles users.
#
# The handlers will be flushed during pulp_database, before
# pulp_workers is called. But said users' ansible does not know
# the number of pulp-workers yet.
#
# TODO: The Pulp services *should* be refactored into a
# systemd multi-service app. That would mean a single task would
# restart all of Pulp.
- name: Reload systemd
- name: Restart pulpcore service
systemd:
daemon_reload: true
become: true

- name: Get services
service_facts:

- name: Restart all pulpcore* services
systemd:
daemon_reload: true
name: "{{ item.value.name }}"
name: "pulpcore.service"
state: restarted
when: "item.value.name != 'pulpcore-worker@.service'"
with_dict: '{{ ansible_facts.services|dict2items|selectattr("key", "contains", "pulpcore")|list|items2dict }}'
become: true

- name: Delete symlink from old artifact directory location
Expand Down
18 changes: 18 additions & 0 deletions roles/pulp_common/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -101,3 +101,21 @@
- import_tasks: repos.yml
- import_tasks: install.yml
- import_tasks: configure.yml

- name: Install pulpcore service
template:
src: pulpcore.service.j2
dest: /lib/systemd/system/pulpcore.service
owner: root
group: root
mode: 0644
become: true
notify: Restart all Pulp services

- name: Set state of pulpcore app
systemd:
daemon_reload: true
name: pulpcore.service
state: started
enabled: true
become: true
14 changes: 14 additions & 0 deletions roles/pulp_common/templates/pulpcore.service.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[Unit]
Description=Pulpcore Application

[Service]
# The dummy program will exit
Type=oneshot
# Execute a dummy program
ExecStart=/bin/true
# This service shall be considered active after start
RemainAfterExit=yes

[Install]
# Components of this application should be started at boot time
WantedBy=multi-user.target
4 changes: 4 additions & 0 deletions roles/pulp_content/templates/pulpcore-content.service.j2
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
Description=Pulp Content App
After=network-online.target
Wants=network-online.target
# When systemd stops or restarts the meta pulpcore.service, the action is propagated to this service
PartOf=pulpcore.service
# Start this service after the pulpcore.service starts
After=pulpcore.service

[Service]
Type=notify
Expand Down
2 changes: 1 addition & 1 deletion roles/pulp_health_check/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
- name: Checking Pulp services
fail:
msg: "{{ item.value.name }} state: {{ item.value.state }}"
when: "item.value.name != 'pulpcore-worker@.service' and item.value.state != 'running'"
when: "item.value.name not in ['pulpcore-worker@.service', 'pulpcore.service'] and item.value.state != 'running'"
with_dict: '{{ ansible_facts.services|dict2items|selectattr("key", "contains", "pulpcore")|list|items2dict }}'

- name: Ensure Pulp is up and healthy
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
Description=Pulp Resource Manager
After=network-online.target
Wants=network-online.target
# When systemd stops or restarts the meta pulpcore.service, the action is propagated to this service
PartOf=pulpcore.service
# Start this service after the pulpcore.service starts
After=pulpcore.service

[Service]
Environment="DJANGO_SETTINGS_MODULE=pulpcore.app.settings"
Expand Down
4 changes: 4 additions & 0 deletions roles/pulp_workers/templates/pulpcore-worker@.service.j2
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
Description=Pulp Worker
After=network-online.target
Wants=network-online.target
# When systemd stops or restarts the meta pulpcore.service, the action is propagated to this service
PartOf=pulpcore.service
# Start this service after the pulpcore.service starts
After=pulpcore.service

[Service]
EnvironmentFile=-/etc/default/pulp-workers
Expand Down

0 comments on commit bb90558

Please sign in to comment.