From ee134d3ce822b1f2f7d9e0a993228fcc436bfa3a Mon Sep 17 00:00:00 2001 From: Michael Housh Date: Wed, 27 Nov 2024 19:55:49 -0500 Subject: [PATCH] feat: Adds setup project to the justfile --- justfile | 17 ++++++++++++----- main.yml | 1 - roles/setup-project/tasks/main.yml | 24 ++++++++++++++++++++++++ test/justfile | 2 ++ 4 files changed, 38 insertions(+), 6 deletions(-) create mode 100644 test/justfile diff --git a/justfile b/justfile index 1672d52..5ba90ec 100644 --- a/justfile +++ b/justfile @@ -6,12 +6,13 @@ default: [group('plays')] run *ARGS: @ansible-playbook ./main.yml \ + --inventory ./inventory.ini \ {{ARGS}} # Run the repo-template option in the `dir` with the passed in arguements. [group('plays')] create-repo-template dir *ARGS: - @just run-playbook \ + @just run \ --tags repo-template \ --extra-vars output_dir={{dir}} \ {{ARGS}} @@ -19,11 +20,17 @@ create-repo-template dir *ARGS: # Run the build-project option in the `dir` with the passed in arguements. [group('plays')] build-project dir *ARGS: - @just run-playbook \ + @just run \ --tags build-project \ --extra-vars project_dir={{dir}} \ {{ARGS}} -[group('test')] -test *ARGS: - @ansible-playbook ./test/test.yml {{ARGS}} +# Setup a new consult project from a template repo. +[group('plays')] +setup-project repo-url version project-dir *ARGS: + @ansible-playbook ./main.yml \ + --inventory ./inventory.ini \ + --tags setup-project \ + --extra-vars "{'template': {'repo': {'url': '{{repo-url}}', 'version': '{{version}}' }}}" \ + --extra-vars "project_dir={{project-dir}}" \ + {{ARGS}} diff --git a/main.yml b/main.yml index 33d4184..dde12ca 100644 --- a/main.yml +++ b/main.yml @@ -12,5 +12,4 @@ - never # makes it so a tag must be supplied to run. - role: setup-project tags: - - setup-project - never # makes it so a tag must be supplied to run. diff --git a/roles/setup-project/tasks/main.yml b/roles/setup-project/tasks/main.yml index 53112a6..5ad635b 100644 --- a/roles/setup-project/tasks/main.yml +++ b/roles/setup-project/tasks/main.yml @@ -2,6 +2,8 @@ - name: Starting setup project. ansible.builtin.debug: msg: "Project dir: {{ project_dir }}" + tags: + - always - name: Debug template vars pre parse. ansible.builtin.debug: @@ -20,6 +22,10 @@ - name: Parse template facts. ansible.builtin.include_role: name: "prepare-template-facts" + tags: + - setup-project + - never + - name: Debug template path post parse. ansible.builtin.debug: @@ -32,10 +38,16 @@ ansible.builtin.file: path: "{{ project_dir }}" state: directory + tags: + - setup-project + - never - name: Load template vars. ansible.builtin.include_role: name: "load-template-vars" + tags: + - setup-project + - never - name: Debug on_setup. ansible.builtin.debug: @@ -55,6 +67,9 @@ ansible.builtin.stat: path: "{{ project_dir }}/.setup" register: setup_file + tags: + - setup-project + - never - name: Debug setup file stat. ansible.builtin.debug: @@ -70,6 +85,9 @@ with_items: "{{ copy_directory_on_setup }}" when: setup_file.stat.exists is false register: copy_directory_stat + tags: + - setup-project + - never - name: Debug copy directory stat. ansible.builtin.debug: @@ -86,6 +104,9 @@ destination: "{{ project_dir }}/{{ item.dest | default(item) }}" mode: "{{ item.mode | default('0600') }}" loop: "{{ copy_on_setup }}" + tags: + - setup-project + - never - name: Create setup file. ansible.builtin.template: @@ -93,3 +114,6 @@ dest: "{{ project_dir }}/.setup" mode: '0600' when: not setup_file.stat.exists + tags: + - setup-project + - never diff --git a/test/justfile b/test/justfile new file mode 100644 index 0000000..3bd54d8 --- /dev/null +++ b/test/justfile @@ -0,0 +1,2 @@ +test *ARGS: + @ansible-playbook ./test.yml {{ARGS}}