Skip to content

Commit

Permalink
Include blueprint import file option (#357)
Browse files Browse the repository at this point in the history
* include blueprint import file option

* include blueprint import file option

* fix meta

* Remove debug message

* Remove debug message
  • Loading branch information
luisarizmendi authored Mar 6, 2024
1 parent ef25e39 commit 6e34162
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 2 deletions.
16 changes: 16 additions & 0 deletions roles/builder/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,22 @@ Example:
builder_pub_key: ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQDA8mSWJrMW9PSy3gXpqTu/QQPB/gfahwLIvt007poNHRartDaLQPNOwfGzBRXXaaP5RVAHqwmxStP3eVkIdm1UhzJ1X50KCWz5Oq0PW2UGjxCxdgutNbBEtGqewR9N7jOulcEjV+JQG1//vSuLlPWm/5W3nAE6objc+YQ1RyBSqgN58pvvqfhh2kjBKxAS1urDSc0CUlhefWnV60dYY7dApHemEC/+XZbYP68bVznZVPf4k0s+0Tx1GAxDMxUWUj4owldO6XVwxYkEgTBaMllSYyT95Mq6wqFQZ/k3IKikczwKnqsjFTl3/AFMaWgGlyGurCrKZtPEpZVsZYLlgWUtoZWlbUJHiKgyn4V8ErHVZBzauOkyydTaBp0O2ZxOTvIWlCkzR9129hxK4C2u0eewAfw0m1x8C2sB9OboteWpVFSIKXUb9he72lDguR8rfoTrvMwYKQ27z4FQbLQeAt4I1hPY/7bL4UYnKMszpmV7GuAPfzwtz0tBt2C4uX4b7OE= resolutecoder@fedora
```


### builder_blueprint_import_file

Type: string
Required: false

Local path to the blueprint TOML file that will be used. That will be done instead of creating a new blueprint using the `builder_compose_pkgs` and `builder_compose_customizations` variables. The Blueprint name will be overwritten by the `builder_blueprint_name` variable.

Example:

```yaml
builder_blueprint_import_file: "~/microshift-embedded.toml"
```



### builder_compose_pkgs

Type: list
Expand Down
5 changes: 5 additions & 0 deletions roles/builder/meta/argument_specs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,11 @@ argument_specs:
required: false
description: "SSH public key to inject into the resulting image to allow key-based ssh functionality without extra configuration for systems installed with the resulting build media." # yamllint disable-line rule:line-length

builder_blueprint_import_file:
type: "str"
required: false
description: "Blueprint file to be imported."

builder_compose_pkgs:
type: "list"
required: false
Expand Down
32 changes: 30 additions & 2 deletions roles/builder/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,37 @@
dest: "{{ builder_blueprint_src_path }}"
name: "{{ builder_blueprint_name }}"
distro: "{{ builder_blueprint_distro | default(omit) }}"
packages: "{{ builder_compose_pkgs }}"
customizations: "{{ builder_compose_customizations }}"
packages: "{{ builder_compose_pkgs | default(omit) }}"
customizations: "{{ builder_compose_customizations | default(omit) }}"
register: builder_blueprint_output
when: builder_blueprint_import_file is not defined

- block:
- name: Copy the blueprint file

Check failure on line 102 in roles/builder/tasks/main.yml

View workflow job for this annotation

GitHub Actions / Lint Blue

102:11 [indentation] wrong indentation: expected 12 but found 10

Check failure on line 102 in roles/builder/tasks/main.yml

View workflow job for this annotation

GitHub Actions / Lint Green

102:11 [indentation] wrong indentation: expected 12 but found 10
copy:
src: "{{ builder_blueprint_import_file }}"
dest: "{{ builder_blueprint_src_path }}"

## TODO: Check the imported file TOML format
- name: Read the content of the TOML file
slurp:
src: "{{ builder_blueprint_src_path }}"
register: toml_file_content

- name: Parse TOML content
shell: "echo '{{ toml_file_content.content | b64decode }}' | python -c 'import sys, toml; print(toml.loads(sys.stdin.read())[\"version\"])'"
register: _imported_blueprint_version

- name: Set blueprint name in the imported TOML file
shell: "sed -i '0,/name =/ s/name =.*/name = \"{{ builder_blueprint_name }}\"/' {{ builder_blueprint_src_path }}"

- name: Set expected var output with current_version from TOML
set_fact:
builder_blueprint_output:
msg: "Blueprint file written to location: {{ builder_blueprint_src_path }}"
changed: true
current_version: "{{ _imported_blueprint_version.stdout }}"
when: builder_blueprint_import_file is defined

- name: Push the blueprint into image builder
infra.osbuild.push_blueprint: # noqa only-builtins
Expand Down

0 comments on commit 6e34162

Please sign in to comment.