-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #31 from ublue-os/tepene/ansible-vars
feat(main): configure input variables via environment variable file
- Loading branch information
Showing
18 changed files
with
223 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,5 +27,7 @@ rvproxy | |
serverstransport | ||
traefik | ||
ublue | ||
varnames | ||
venvs | ||
wantlist | ||
websecure |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
--- | ||
# data variables | ||
forge_data_path: "{{ lookup('ansible.builtin.env', 'FORGE_DATA_PATH', default=ansible_facts.env.HOME + '/ublue-os_forge') }}" | ||
forge_data_default_variables_file_path: "{{ forge_data_path }}/forge_default_vars.env" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
# git variables | ||
forge_git_repository_url: "{{ lookup('ansible.builtin.env', 'FORGE_GIT_REPOSITORY_URL', default='https://github.com/ublue-os/bluefin.git') }}" | ||
forge_git_repository_destination: "{{ lookup('ansible.builtin.env', 'FORGE_GIT_REPOSITORY_DESTINATION', default=forge_data_path + '/bluefin') }}" | ||
forge_git_repository_version: "{{ lookup('ansible.builtin.env', 'FORGE_GIT_REPOSITORY_VERSION', default='main') }}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
--- | ||
# container registry variables | ||
forge_registry_url: "{{ lookup('ansible.builtin.env', 'FORGE_REGISTRY_URL', default='registry.ublue.local') }}" |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
--- | ||
# localhost variables | ||
ansible_connection: local | ||
ansible_python_interpreter: "{{ ansible_playbook_python }}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# Role - debug_forge_vars | ||
|
||
This role is used for debugging purposes only. | ||
|
||
## Variables | ||
|
||
The role has the following variables defined. | ||
|
||
### default/main.yml | ||
|
||
In the [main.yml](./defaults/main.yml/) all variables are defined which are | ||
used in the context of debugging. Usually end-users should not worry about them to much. | ||
|
||
<!-- markdownlint-disable MD013 --> | ||
|
||
| name | type | default value | description | | ||
| ------------------------------- | ---- | ------------- | ------------------------------------------------------------------------------------------- | | ||
| `forge_debug_vars_regex_search` | str | ^forge\_.+ | Python regex search term. Useful if you want to print out all variables starting with `xyz` | | ||
|
||
<!-- markdownlint-enable MD013 --> | ||
|
||
## Example Playbook Usage | ||
|
||
This role is best included in a playbook as pre-task: | ||
|
||
```yaml | ||
pre_tasks: | ||
- name: DEBUG - forge variables | ||
ansible.builtin.include_role: | ||
name: debug_forge_vars | ||
``` | ||
With the role included you can launch the playbook in verbose mode `ansible-playbook -v`. | ||
This will print all variables found with the regex search term defined in the `forge_debug_vars_regex_search` | ||
variable. | ||
|
||
You can modify the `forge_debug_vars_regex_search` term by changing it via the vars statement | ||
|
||
```yaml | ||
pre_tasks: | ||
- name: DEBUG - forge git variables | ||
ansible.builtin.include_role: | ||
name: debug_forge_vars | ||
vars: | ||
forge_debug_vars_regex_search: ^forge_git.+ | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# Default vars for this role | ||
forge_debug_vars_regex_search: "{{ lookup('ansible.builtin.env', 'FORGE_DEBUG_VARS_REGEX_SEARCH', default='^forge_.+') }}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
--- | ||
# main task file for this role | ||
|
||
- name: DEBUG | forge variables | ||
ansible.builtin.debug: | ||
msg: "{{ item }}: {{ lookup('ansible.builtin.vars', item) }}" | ||
verbosity: 1 | ||
loop: "{{ __forge_vars_used }}" | ||
loop_control: | ||
extended: true | ||
label: "{{ ansible_loop.index }}/{{ ansible_loop.length }}" | ||
vars: | ||
__forge_vars_used: "{{ lookup('ansible.builtin.varnames', forge_debug_vars_regex_search, wantlist=true) }}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
# Variables | ||
|
||
The following sections contains all important variables defined for daily usage. | ||
All variables mentioned here can be declared in a line-delimited file of environment variables. | ||
|
||
An example file on the host system with all variables available will be created on setup | ||
for you. By default it can be found under `$HOME/ublue-os_forge/forge_default_vars.env`. | ||
|
||
On playbook launch the variable file will be imported into the ansible container so that | ||
the settings are available during playbook execution. | ||
|
||
## group_vars/all/data.yml | ||
|
||
In the [data.yml](../ansible/group_vars/all/data.yml) all variables are defined | ||
which are used in the context of the data handling. | ||
|
||
<!-- markdownlint-disable MD013 --> | ||
|
||
| name | type | environment variable | default value | description | | ||
| ---------------------------------------- | ---- | -------------------- | ------------------------------------------- | --------------------------------------------- | | ||
| `forge_data_path` | str | `FORGE_DATA_PATH` | $HOME/ublue-os_forge | Path where forge will store files per default | | ||
| `forge_data_default_variables_file_path` | str | | $HOME/ublue-os_forge/forge_default_vars.env | Path to default configuration file | | ||
|
||
<!-- markdownlint-enable MD013 --> | ||
|
||
## group_vars/all/git.yml | ||
|
||
In the [git.yml](../ansible/group_vars/all/git.yml/) all variables are defined which are | ||
used in the context of the git repositories. | ||
|
||
<!-- markdownlint-disable MD013 --> | ||
|
||
| name | type | environment variable | default value | description | | ||
| ---------------------------------- | ---- | ---------------------------------- | ----------------------------------------- | ---------------------------------------------- | | ||
| `forge_git_repository_url` | str | `FORGE_GIT_REPOSITORY_URL` | <https://github.com/ublue-os/bluefin.git> | Git repository url | | ||
| `forge_git_repository_destination` | str | `FORGE_GIT_REPOSITORY_DESTINATION` | $HOME/ublue-os/forge/bluefin | Git destination where repository is cloned to | | ||
| `forge_git_repository_version` | str | `FORGE_GIT_REPOSITORY_VERSION` | main | Git repository branch or tag or commit version | | ||
|
||
<!-- markdownlint-enable MD013 --> | ||
|
||
## group_vars/all/registry.yml | ||
|
||
In the [registry.yml](../ansible/group_vars/all/registry.yml) all variables are defined | ||
which are used in the context of the container registry. | ||
|
||
<!-- markdownlint-disable MD013 --> | ||
|
||
| name | type | environment variable | default value | description | | ||
| -------------------- | ---- | -------------------- | -------------------- | ---------------------- | | ||
| `forge_registry_url` | str | `FORGE_REGISTRY_URL` | registry.ublue.local | Container registry url | | ||
|
||
<!-- markdownlint-enable MD013 --> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,13 @@ | ||
# ublue-os forge just configuration | ||
|
||
# Show all messages from this boot | ||
forge_clone-repository: | ||
podman exec ublue-os_forge-anvil-ansible.ublue.local ansible-playbook playbooks/project_clone.yml | ||
## default | ||
|
||
forge_build-image: | ||
podman exec ublue-os_forge-anvil-ansible.ublue.local ansible-playbook playbooks/project_build.yml | ||
default := "'${HOME}'/ublue-os_forge/forge_default_vars.env" | ||
|
||
## recipes | ||
|
||
forge_project-clone forge_config_var_file=default: | ||
podman exec --env-file '{{forge_config_var_file}}' ublue-os_forge-anvil-ansible.ublue.local ansible-playbook playbooks/project_clone.yml | ||
|
||
forge_project-build forge_config_var_file=default: | ||
podman exec --env-file '{{forge_config_var_file}}' ublue-os_forge-anvil-ansible.ublue.local ansible-playbook playbooks/project_build.yml |