Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add possibility to give package versions in blueprint #465

Merged
merged 1 commit into from
Feb 18, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
minor_changes:
- add possibility to define a version glob for packages in module create_blueprint, closes #463

Check warning on line 3 in changelogs/fragments/312-add-create_blueprint-package_version.yaml

View workflow job for this annotation

GitHub Actions / Lint Green

3:94 [comments] too few spaces before comment

Check warning on line 3 in changelogs/fragments/312-add-create_blueprint-package_version.yaml

View workflow job for this annotation

GitHub Actions / Lint Blue

3:94 [comments] too few spaces before comment
11 changes: 9 additions & 2 deletions plugins/modules/create_blueprint.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
packages:
description:
- List of package names to add to the blueprint
- Each name can be followed by two equal signs and a version glob
type: list
elements: str
default: []
Expand Down Expand Up @@ -102,7 +103,7 @@
packages:
- "vim-enhanced"
- "ansible-core"
- "git"
- "git==2.*"
customizations:
kernel:
append: "nomst=force"
Expand Down Expand Up @@ -174,7 +175,13 @@ def create_blueprint(module, weldr):
if module.params["packages"]:
toml_data["packages"]: list = []
for package in module.params["packages"]:
toml_data["packages"].append({"name": f"{package}", "version": "*"})
if "==" in package:
package_name, package_version = package.split("==")
toml_data["packages"].append(
{"name": f"{package_name}", "version": f"{package_version}"}
)
else:
toml_data["packages"].append({"name": f"{package}", "version": "*"})

if module.params["groups"]:
toml_data["groups"]: list = []
Expand Down
4 changes: 2 additions & 2 deletions tests/utils/playbooks/edge-installer-e2e-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@

packages:
- "vim-enhanced"
- "git"
- "git==2.*"
- "ansible-core"
run_once: true

Expand Down Expand Up @@ -151,7 +151,7 @@
ansible.builtin.assert:
that:
- item in package_installed.stdout_lines
loop: "{{ packages }}"
loop: "{{ packages | map('ansible.builtin.regex_replace', '==.*', '') }}"

always:
- name: Cleanup test environment
Expand Down
Loading