diff --git a/Makefile b/Makefile index cca61bc..9bbabc1 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,7 @@ PDF_TITLE ?= "Report.pdf" TEX_TITLE ?= "Report.tex" HTML_TITLE ?= "report.html" OUT_FILE ?= "Report.md" -OUT_DIR ?= "outfiles" +OUT_DIR ?= "${PWD}/outfiles" PDF_TEST_TITLE ?= "Report.test.pdf" .PHONY: gen @@ -49,7 +49,22 @@ install: @brew install pandoc \ mactex-no-gui \ imagemagick \ - gettext + gettext \ + ansible + +.PHONY: ansible +ansible: + @cd ./ansible && \ + ansible-playbook playbook.yaml \ + --extra-vars "output_path=${OUT_DIR}" + +.PHONY: ansible-vault-example +ansible-vault-example: + @cd ./ansible && \ + ansible-playbook playbook.yaml \ + --extra-vars "output_path=${OUT_DIR}" + --extra-vars "@group_vars/vault_example/vars.yaml" \ + --extra-vars "@group_vars/vault_example/vault.yaml" \ @.PHONY: clean clean: diff --git a/ansible.cfg b/ansible/ansible.cfg similarity index 100% rename from ansible.cfg rename to ansible/ansible.cfg diff --git a/roles/report/defaults/main.yml b/ansible/group_vars/all/vars.yaml similarity index 100% rename from roles/report/defaults/main.yml rename to ansible/group_vars/all/vars.yaml diff --git a/group_vars/all/vars.yml b/ansible/group_vars/vault_example/vars.yaml similarity index 100% rename from group_vars/all/vars.yml rename to ansible/group_vars/vault_example/vars.yaml diff --git a/group_vars/all/vault.yaml b/ansible/group_vars/vault_example/vault.yaml similarity index 100% rename from group_vars/all/vault.yaml rename to ansible/group_vars/vault_example/vault.yaml diff --git a/inventory.ini b/ansible/inventory.ini similarity index 100% rename from inventory.ini rename to ansible/inventory.ini diff --git a/playbook/report.yml b/ansible/playbook.yaml similarity index 100% rename from playbook/report.yml rename to ansible/playbook.yaml diff --git a/ansible/roles/report/defaults/main.yaml b/ansible/roles/report/defaults/main.yaml new file mode 100644 index 0000000..3bbbcd1 --- /dev/null +++ b/ansible/roles/report/defaults/main.yaml @@ -0,0 +1,33 @@ +--- +author_name: "Testy McTestface Jr" +document_title: "Home Performance Report" +company: + website: "https://example.com" + phone: "555-555-5555" + url_display_title: "www.Example.com" + +links: + images: + logo: "img/logo.png" + trueflow: "img/trueflow.png" + trueflow_forecast: "img/forecast.png" + documents: + loads_folder: "https://example.com/path/to/loads/folder" + trueflow_file: "https://example.com/path/to/trueflow/file" + trueflow_forecast_file: "https://example.com/path/to/trueflow/forecast/file" + document_folder: "https://example.com/path/to/document/folder" + +customer: + name: "Testy McTestface Sr" + address: + street: "1234 Seasme Street" + city: "No Mans Land" + state: "Foo" + zip: "55555" + +home: + square_feet: "3,000" + cfm50: "3,000" + lair: "1:1" + +output_path: "outfiles" diff --git a/resources/Definitions.md b/ansible/roles/report/files/Definitions.md similarity index 100% rename from resources/Definitions.md rename to ansible/roles/report/files/Definitions.md diff --git a/resources/head.tex b/ansible/roles/report/files/head.tex similarity index 100% rename from resources/head.tex rename to ansible/roles/report/files/head.tex diff --git a/ansible/roles/report/tasks/main.yaml b/ansible/roles/report/tasks/main.yaml new file mode 100644 index 0000000..69f2f51 --- /dev/null +++ b/ansible/roles/report/tasks/main.yaml @@ -0,0 +1,36 @@ +--- + +- name: Ensure output directory exists. + ansible.builtin.file: + path: "{{ output_path }}" + state: "directory" + mode: '0755' + +- name: Copy Files. + ansible.builtin.copy: + src: "files/{{ item }}" + dest: "{{ output_path }}/{{ item }}" + mode: '0600' + with_items: + - "Definitions.md" + - "head.tex" + +- name: Generate Footer File + ansible.builtin.template: + src: "templates/{{ item }}" + dest: "{{ output_path }}/footer.tex" + mode: '0600' + with_items: + - "footer.tex" + tags: + - footer + +- name: Generate Templated Report File + ansible.builtin.template: + src: "templates/{{ item }}" + dest: "{{ output_path }}/Report.md" + mode: '0600' + with_items: + - "Report.md" + tags: + - report diff --git a/roles/report/templates/Report.md b/ansible/roles/report/templates/Report.md similarity index 100% rename from roles/report/templates/Report.md rename to ansible/roles/report/templates/Report.md diff --git a/roles/report/templates/footer.tex b/ansible/roles/report/templates/footer.tex similarity index 100% rename from roles/report/templates/footer.tex rename to ansible/roles/report/templates/footer.tex diff --git a/roles/report/tasks/main.yml b/roles/report/tasks/main.yml deleted file mode 100644 index aaf0ac6..0000000 --- a/roles/report/tasks/main.yml +++ /dev/null @@ -1,22 +0,0 @@ ---- -- name: Generate Footer File - ansible.builtin.template: - src: "templates/{{ item }}" - dest: "{{ output_path }}/footer.tex" - mode: "0600" -# variable_end_string: '[%' -# variable_start_string: '%]' - with_items: - - "footer.tex" - tags: - - footer - -- name: Generate Templated Files - ansible.builtin.template: - src: "templates/{{ item }}" - dest: "{{ output_path }}/Report.md" - mode: "0600" - with_items: - - "Report.md" - tags: - - report diff --git a/vars.sh b/vars.sh deleted file mode 100755 index 9b9451b..0000000 --- a/vars.sh +++ /dev/null @@ -1,29 +0,0 @@ -#!/bin/zsh - -# Document setup. -export AUTHOR_NAME="Testy McTestface" -export COMPANY_WEBSITE="https://example.com" -export DOCUMENT_TITLE="Home Performance Report" -export COMPANY_WEBSITE_DISPLAY="www.Example.com" -export COMPANY_PHONE="555-555-5555" - -# Image paths. -export LOGO_IMAGE="img/logo.png" -export TRUEFLOW_IMAGE="img/trueflow.png" -export TRUEFLOW_FORECAST_IMAGE="img/forecast.png" - -# Customer info. -export CUSTOMER_NAME="Testy McTestface" -export CUSTOMER_STREET="1234 Seasme Street" -export CUSTOMER_CITY_STATE_ZIP="Monroe, OH 45044" - -# Home variables. -export HOME_LEAKAGE="4,186" -export HOME_SQUARE_FEET="1,350" -export HOME_LAIR="3:1" - -# File links -export LOADS_FOLDER="https://example.com/path/to/loads/folder" -export TRUEFLOW_FILE="https://example.com/path/to/trueflow/file" -export TRUEFLOW_FORECAST_FILE="https://example.com/path/to/trueflow/forecast/file" -export DOCUMENT_FOLDER="https://example.com/path/to/document/folder"