feat: Working on not needing to supply template path when using a repo in setup-project

This commit is contained in:
2024-11-27 11:53:46 -05:00
parent e81d9b8f0c
commit ee91b060eb
4 changed files with 92 additions and 9 deletions

View File

@@ -1,12 +1,14 @@
---
# TODO: When using a template repo, we should probably clone it into
# the project directory somewhere.
# template_dir:
# path: "/path/to/template/dir
# vars: "repo_vars"
# repo: (optional if using a repo as a template)
template:
path: "/path/to/template/dir"
vars: "repo_vars"
#path: "/path/to/template/dir"
#vars: "repo_vars"
# When using a repository as a template dir. In general, it's
# probably best to pin to a particular version of the repo template
@@ -15,10 +17,10 @@ template:
# repo:
# url: "https://example.com/repo.git"
# version: "main"
repo: {}
#repo: {}
# The output directory to setup a project in.
output_dir: "{{ lookup('env', 'PWD') }}"
# The preject directory to setup in.
project_dir: "{{ lookup('env', 'PWD') }}"
# Files that are copied from the template directory to the output
# directory.

View File

@@ -1,11 +1,43 @@
---
- name: Starting setup project.
ansible.builtin.debug:
msg: "Output dir: {{ output_dir }}"
msg: "Project dir: {{ project_dir }}"
- name: Debug template vars pre parse.
ansible.builtin.debug:
var: template
tags:
- debug
- never
- name: Parse template path.
ansible.builtin.set_fact:
template:
path: "{{ project_dir }}/{{ build_dir | default('.build') }}/template"
when: not template.path is defined
- name: Parse template vars.
ansible.builtin.set_fact:
template:
vars: "repo_vars"
when: not template.vars is defined
# - name: Prepare variables.
# ansible.builtin.include_tasks:
# file: "prepare_vars.yml"
# vars:
# template: "{{ template }}"
- name: Debug template vars post parse.
ansible.builtin.debug:
var: template
tags:
- debug
- never
- name: Ensure output directory exists.
ansible.builtin.file:
path: "{{ output_dir }}"
path: "{{ project_dir }}"
state: directory
- name: Ensure repo.
@@ -37,6 +69,6 @@
file: "copy_if_not_exists.yml"
vars:
source: "{{ template.path }}/{{ item.src | default(item) }}"
destination: "{{ output_dir }}/{{ item.dest | default(item) }}"
destination: "{{ project_dir }}/{{ item.dest | default(item) }}"
mode: "{{ item.mode | default('0600') }}"
loop: "{{ copy_on_setup }}"

View File

@@ -0,0 +1,16 @@
---
- name: Parse template path.
ansible.builtin.set_fact:
template:
path: "{{ project_dir }}/{{ build_dir | default('.build') }}/template"
when: not template.path is defined
tags:
- always
- name: Parse template vars.
ansible.builtin.set_fact:
template:
vars: "repo_vars"
when: not template.vars is defined
tags:
- always