@camratchford's profile
- Loves Pizza
- Writes code occasionally
- Python
- Frontend
- Infrastructre as Code
- PowerShell
- Informing the public about propper clubhouse sandwich composition
Quick and Dirty Jinja templating from the CLI with YAML
License: Creative Commons Zero v1.0 Universal
Since windows task scheduler likes to output UTF-16F for it's XML outputs, and Python defaults to UTF-8, we should check which encoding method the template file uses before attempting to read the file.
Config option 'sql_server_type`:
Then config options for authentication:
It will populate the globals of the Jinja environment with a list of dicts (one for each row where the key is the column name and the value is the row value). The name of the variable is provided with the SQL query.
The cli commands that accept path variables should be using the built-in click.Path type (which adds validation).
This whole project was published with very little testing.
Which variables are required
What the required variables do
What jinja options should not be passed through, or wont have any effect
What logging options are recommended, provide additional examples for formatting, stack trace, different handlers.
How global variables work, when to use them.
Dynamic variables, like:
Collect the following:
Add them to a dictionary that is automatically provided in vars:
I don't like gnu-cpp, the macros are ugly.
# Where the values provided to the -o argument is the absolute path of the file ezt will output
ext -c ./config.yml -v vars.yml -o /home/cam/projects/new_project/config.py config.py.j2
# With no -o argument provided, the output file will land in the output directory specified in ./config.yml
ext -c ./config.yml -v vars.yml config.py.j2
[ ] Formatting / Linting
[ ] Test runners
[ ] Linux compiling tests with make
[ ] Windows compiling tests with pester (for powershell)
There are 4 directories specified in the config file
The user should have the option to override the path of templates, vars, and outputs with cli arugments
Proposed args to add:
CLI Argument | Description |
---|---|
--template-dir |
Absolute path to the template directory, where relative paths provided in the template argument are relative to |
--vars-dir |
Absolute path to the vars directory, where relative paths provided in the vars argument are relative to |
--output-dir |
Absolute path to the outputdirectory, where output files will land if the output path argument is not specified |
ezt --tree ~/project/input_dir -o ~/project/output_dir --var-file ~/project/vars.yml
For example:
Shell Script
for i in staging-1 dns-1 dns-2; do
ezt --var-file=vars.yml -v "host=${i}" -t build_container.yml.j2 -o "plays/build_${i}.yml"
done
vars.yml
hosts:
staging-1:
container_host: lxdhost-1
dns-1:
container_host: lxdhost-1
dns-2:
container_host: lxdhost-2
build_container.yml.j2
---
- name: Build {{ host }} container
hosts: {{ hosts[host].container_host }}
var_files: /opt/monorepo/ansible/inventories/host_vars/{{ host }}.yml
tasks:
- name: Provision LXD container
include_role:
name: lxd-lifecycle
tasks_from: build.yml
The config object already has the ability to configure logging using logging.dictConfig, it's just missing from the example config.yml file.
Untested in Linux, but in Windows the compiled binaries do not have any output on the terminal. Logging (the file handler at least) and error handling otherwise work as expected.
Query AD/LDAP objects as dynamic variables
Ether AD or LDAP, not both. Whichever is the least complicated for the user configuration.
Can be used to collect User object data such as email address, phone number, group membership, etc.
Can be used to collect Computer object data as well.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.