stages/systemd:support for user service dropin
systemd unit stage will now be able to add user unit dropin, this is done by adding an additional field:unit-type which is set to system by default. It also adds ability to update the unit config with ConditionPathExists. Relevant testing updated for the new workflow. Signed-off-by: Sayan Paul <paul.sayan@gmail.com>
This commit is contained in:
parent
ed926ecc71
commit
61da6124ed
4 changed files with 46 additions and 2 deletions
|
|
@ -39,6 +39,17 @@ SCHEMA = r"""
|
|||
"type": "object",
|
||||
"description": "Drop-in configuration for a '.service' unit.",
|
||||
"properties": {
|
||||
"Unit": {
|
||||
"additionalProperties": false,
|
||||
"type": "object",
|
||||
"description": "'Unit' configuration section of a unit file.",
|
||||
"properties": {
|
||||
"ConditionPathExists": {
|
||||
"type": "string",
|
||||
"description": "Check for the existence of a file. If the specified absolute path name does not exist, the condition will fail."
|
||||
}
|
||||
}
|
||||
},
|
||||
"Service": {
|
||||
"additionalProperties": false,
|
||||
"type": "object",
|
||||
|
|
@ -51,6 +62,12 @@ SCHEMA = r"""
|
|||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"unit-type": {
|
||||
"type": "string",
|
||||
"enum": ["system", "global"],
|
||||
"default": "system",
|
||||
"description": "Selects between systemd system or global unit to add dropin"
|
||||
}
|
||||
}
|
||||
"""
|
||||
|
|
@ -60,12 +77,16 @@ def main(tree, options):
|
|||
unit = options["unit"]
|
||||
dropin_file = options["dropin"]
|
||||
cfg = options["config"]
|
||||
unit_type = options.get("unit-type", "system")
|
||||
|
||||
# ensure the unit name + ".d" does not exceed maximum filename length
|
||||
if len(unit + ".d") > 255:
|
||||
raise ValueError(f"Error: the {unit} unit drop-in directory exceeds the maximum filename length.")
|
||||
|
||||
unit_dropins_dir = f"{tree}/usr/lib/systemd/system/{unit}.d"
|
||||
if unit_type == "system":
|
||||
unit_dropins_dir = f"{tree}/usr/lib/systemd/system/{unit}.d"
|
||||
elif unit_type == "global":
|
||||
unit_dropins_dir = f"{tree}/usr/lib/systemd/user/{unit}.d"
|
||||
os.makedirs(unit_dropins_dir, exist_ok=True)
|
||||
|
||||
config = configparser.ConfigParser()
|
||||
|
|
|
|||
|
|
@ -470,6 +470,19 @@
|
|||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "org.osbuild.systemd.unit",
|
||||
"options": {
|
||||
"unit": "grub-boot-success.timer",
|
||||
"dropin": "10-disable-if-greenboot.conf",
|
||||
"unit-type": "global",
|
||||
"config": {
|
||||
"Unit": {
|
||||
"ConditionPathExists": "/usr/lib/greenboot/greenboot"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
|
|
|
|||
|
|
@ -26,3 +26,11 @@ pipeline:
|
|||
config:
|
||||
Service:
|
||||
Environment: NM_CLOUD_SETUP_EC2=yes
|
||||
- name: org.osbuild.systemd.unit
|
||||
options:
|
||||
unit: grub-boot-success.timer
|
||||
dropin: 10-disable-if-greenboot.conf
|
||||
unit-type: global
|
||||
config:
|
||||
Unit:
|
||||
ConditionPathExists: /usr/lib/greenboot/greenboot
|
||||
|
|
|
|||
|
|
@ -1,7 +1,9 @@
|
|||
{
|
||||
"added_files": [
|
||||
"/usr/lib/systemd/system/nm-cloud-setup.service.d",
|
||||
"/usr/lib/systemd/system/nm-cloud-setup.service.d/10-rh-enable-for-ec2.conf"
|
||||
"/usr/lib/systemd/system/nm-cloud-setup.service.d/10-rh-enable-for-ec2.conf",
|
||||
"/usr/lib/systemd/user/grub-boot-success.timer.d",
|
||||
"/usr/lib/systemd/user/grub-boot-success.timer.d/10-disable-if-greenboot.conf"
|
||||
],
|
||||
"deleted_files": [],
|
||||
"differences": {}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue