mirror of
https://github.com/ublue-os/forge.git
synced 2025-04-18 20:43:43 +03:00
feat(ansible): allow for input variable files to configure forge behavior (#13)
This commit is contained in:
parent
7ae5826f4a
commit
cb4d82c7cf
|
@ -1,10 +0,0 @@
|
||||||
---
|
|
||||||
# variables used for all groups and hosts
|
|
||||||
|
|
||||||
## container registry
|
|
||||||
forge_registry_url: registry.ublue.local
|
|
||||||
|
|
||||||
## Git
|
|
||||||
forge_git_repository_url: https://github.com/ublue-os/bluefin.git
|
|
||||||
forge_git_repository_destination: "{{ ansible_facts.env.HOME }}/ublue-os/forge/bluefin"
|
|
||||||
forge_git_repository_version: main
|
|
4
ansible/group_vars/all/data.yml
Normal file
4
ansible/group_vars/all/data.yml
Normal file
|
@ -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"
|
5
ansible/group_vars/all/git.yml
Normal file
5
ansible/group_vars/all/git.yml
Normal file
|
@ -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') }}"
|
3
ansible/group_vars/all/registry.yml
Normal file
3
ansible/group_vars/all/registry.yml
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
---
|
||||||
|
# container registry variables
|
||||||
|
forge_registry_url: "{{ lookup('ansible.builtin.env', 'FORGE_REGISTRY_URL', default='registry.ublue.local') }}"
|
|
@ -1,2 +0,0 @@
|
||||||
---
|
|
||||||
# variables used in playbooks with target host.ublue.local
|
|
|
@ -1,2 +1,4 @@
|
||||||
|
---
|
||||||
|
# localhost variables
|
||||||
ansible_connection: local
|
ansible_connection: local
|
||||||
ansible_python_interpreter: "{{ ansible_playbook_python }}"
|
ansible_python_interpreter: "{{ ansible_playbook_python }}"
|
||||||
|
|
|
@ -24,3 +24,26 @@
|
||||||
cmd: update-ca-trust
|
cmd: update-ca-trust
|
||||||
changed_when: false
|
changed_when: false
|
||||||
become: true
|
become: true
|
||||||
|
|
||||||
|
- name: Create default directory for forge content
|
||||||
|
ansible.builtin.file:
|
||||||
|
path: "{{ forge_data_path }}"
|
||||||
|
state: directory
|
||||||
|
mode: "0755"
|
||||||
|
|
||||||
|
- name: Create default configuration variable file
|
||||||
|
ansible.builtin.copy:
|
||||||
|
dest: "{{ forge_data_default_variables_file_path }}"
|
||||||
|
content: |
|
||||||
|
## ublue-os forge configuration variables defaults
|
||||||
|
## For more details got to https://github.com/ublue-os/forge/blob/main/docs/variables.md
|
||||||
|
|
||||||
|
{% for item in __vars_used %}
|
||||||
|
#{{ item | upper }}={{ lookup('ansible.builtin.vars', item) }}
|
||||||
|
{% endfor %}
|
||||||
|
backup: true
|
||||||
|
owner: "{{ ansible_facts.env.USER }}"
|
||||||
|
mode: "0644"
|
||||||
|
vars:
|
||||||
|
__vars_used: "{{ lookup('ansible.builtin.varnames', __regex_search, wantlist=true) }}"
|
||||||
|
__regex_search: ^forge_.+
|
||||||
|
|
|
@ -2,10 +2,15 @@
|
||||||
- name: Build project
|
- name: Build project
|
||||||
hosts: host.ublue.local
|
hosts: host.ublue.local
|
||||||
gather_facts: true
|
gather_facts: true
|
||||||
|
pre_tasks:
|
||||||
|
- name: DEBUG - forge variables
|
||||||
|
ansible.builtin.include_role:
|
||||||
|
name: debug_forge_vars
|
||||||
|
|
||||||
tasks:
|
tasks:
|
||||||
- name: Build and push an image to registry
|
- name: Build and push image to registry
|
||||||
containers.podman.podman_image:
|
containers.podman.podman_image:
|
||||||
name: bluefin
|
name: "{{ forge_git_repository_url | regex_search(__regex_search) }}"
|
||||||
tag: latest
|
tag: latest
|
||||||
path: "{{ forge_git_repository_destination }}"
|
path: "{{ forge_git_repository_destination }}"
|
||||||
build:
|
build:
|
||||||
|
@ -15,3 +20,10 @@
|
||||||
push: true
|
push: true
|
||||||
push_args:
|
push_args:
|
||||||
dest: "{{ forge_registry_url }}"
|
dest: "{{ forge_registry_url }}"
|
||||||
|
vars:
|
||||||
|
__regex_search: (?<=/)[^/]+(?=\.git)
|
||||||
|
register: __podman_image_info
|
||||||
|
|
||||||
|
- name: INFO | Status from build and push
|
||||||
|
ansible.builtin.debug:
|
||||||
|
msg: "{{ __podman_image_info }}"
|
||||||
|
|
|
@ -2,9 +2,18 @@
|
||||||
- name: Clone project
|
- name: Clone project
|
||||||
hosts: host.ublue.local
|
hosts: host.ublue.local
|
||||||
gather_facts: true
|
gather_facts: true
|
||||||
|
pre_tasks:
|
||||||
|
- name: DEBUG - forge variables
|
||||||
|
ansible.builtin.include_role:
|
||||||
|
name: debug_forge_vars
|
||||||
tasks:
|
tasks:
|
||||||
- name: Clone project
|
- name: Clone project
|
||||||
ansible.builtin.git:
|
ansible.builtin.git:
|
||||||
repo: "{{ forge_git_repository_url }}"
|
repo: "{{ forge_git_repository_url }}"
|
||||||
dest: "{{ forge_git_repository_destination }}"
|
dest: "{{ forge_git_repository_destination }}"
|
||||||
version: "{{ forge_git_repository_version }}"
|
version: "{{ forge_git_repository_version }}"
|
||||||
|
register: __git_clone_info
|
||||||
|
|
||||||
|
- name: INFO | Status from git clone
|
||||||
|
ansible.builtin.debug:
|
||||||
|
msg: "{{ __git_clone_info }}"
|
||||||
|
|
Loading…
Reference in a new issue