Skip to content

Commit 27c5a57

Browse files
authored
Merge pull request #117 from nickanderson/CFE-3635/master
CFE-3635: Prototyped dnf_appstream custom promise type
2 parents 9eff4e3 + 39bda6c commit 27c5a57

7 files changed

Lines changed: 974 additions & 1 deletion

File tree

.github/workflows/ci.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ on:
44
push:
55
branches: [master]
66
pull_request:
7-
branches: [master]
7+
types: [opened, reopened, synchronize]
88

99
jobs:
1010
unit_tests:
@@ -31,3 +31,7 @@ jobs:
3131
run: cfbs --check pretty ./cfbs.json
3232
- name: Linting
3333
run: ./ci/linting.sh
34+
- name: Install pytest
35+
run: pip install pytest
36+
- name: Run promise type tests
37+
run: python3 -m pytest promise-types/ -v

cfbs.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,15 @@
282282
"append enable.cf services/init.cf"
283283
]
284284
},
285+
"promise-type-appstreams": {
286+
"description": "Promise type to manage AppStream modules.",
287+
"subdirectory": "promise-types/appstreams",
288+
"dependencies": ["library-for-promise-types-in-python"],
289+
"steps": [
290+
"copy appstreams.py modules/promises/",
291+
"append init.cf services/init.cf"
292+
]
293+
},
285294
"promise-type-git": {
286295
"description": "Promise type to manage git repos.",
287296
"subdirectory": "promise-types/git",

promise-types/appstreams/README.md

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
# AppStreams Promise Type
2+
3+
A CFEngine custom promise type for managing AppStream modules on compatible systems.
4+
5+
## Overview
6+
7+
The `appstreams` promise type allows you to manage AppStream modules, which are a key feature of RHEL 8+ and compatible systems. AppStreams provide multiple versions of software components that can be enabled or disabled as needed.
8+
9+
## Features
10+
11+
- Enable, disable, install, and remove AppStream modules
12+
- Support for specifying streams and profiles
13+
14+
## Installation
15+
16+
To install this promise type, copy the `appstreams.py` file to your CFEngine masterfiles directory and configure the promise agent:
17+
18+
```
19+
promise agent appstreams
20+
{
21+
interpreter => "/usr/bin/python3";
22+
path => "$(sys.workdir)/modules/promises/appstreams.py";
23+
}
24+
```
25+
26+
## Usage
27+
28+
### Ensure a module is enabled
29+
30+
```
31+
bundle agent main
32+
{
33+
appstreams:
34+
"nodejs"
35+
state => "enabled",
36+
stream => "12";
37+
}
38+
```
39+
40+
### Ensure a module is disabled
41+
42+
```
43+
bundle agent main
44+
{
45+
appstreams:
46+
"nodejs"
47+
state => "disabled";
48+
}
49+
```
50+
51+
### Ensure a module is installed with a specific profile
52+
53+
```
54+
bundle agent main
55+
{
56+
appstreams:
57+
"python36"
58+
state => "installed",
59+
stream => "3.6",
60+
profile => "minimal";
61+
}
62+
```
63+
64+
### Ensure a module is removed
65+
66+
```
67+
bundle agent main
68+
{
69+
appstreams:
70+
"postgresql"
71+
state => "removed";
72+
}
73+
```
74+
75+
### Reset a module to default
76+
77+
```
78+
bundle agent main
79+
{
80+
appstreams:
81+
"nodejs"
82+
state => "default";
83+
}
84+
```
85+
86+
## Attributes
87+
88+
The promise type supports the following attributes:
89+
90+
- `state` (optional) - Desired state of the module: `enabled`, `disabled`, `installed`, `removed`, `default`, or `reset` (default: `enabled`)
91+
- `stream` (optional) - Specific stream of the module to use. Set to `default` to use the module's default stream.
92+
- `profile` (optional) - Specific profile of the module to install. Set to `default` to use the module stream's default profile.
93+
94+
## Requirements
95+
96+
- CFEngine 3.18 or later
97+
- Python 3
98+
- DNF Python API (python3-dnf package)
99+
- DNF/YUM package manager (RHEL 8+, Fedora, CentOS 8+)
100+
- AppStream repositories configured

0 commit comments

Comments
 (0)