Code Snippets Jinja

Short texts Jinja 🧑‍💻 Code snippets Jinja ✍️ Reading lists Jinja 👀

API Code Generation From SQLAlchemy Models

# Automatic SQL API Generation First of all make sure you use `python` 3.8 and install the packages in `requirements.txt`. ## Step 1 ### Define Models Define your SQLAlchemt models in the `models.py` file. “`py from datetime import datetime, timedelta from sqlalchemy import (Column, DateTime, ForeignKey, Integer, Numeric, String, Table, create_engine) from sqlalchemy.ext.declarative import declarative_base […]

CloudFormation template using by Ansible to create single Windows Server 2016 instance + enable WinRM (ssl)

— AWSTemplateFormatVersion: “2010-09-09” Description: Windows 2016 Template Resources: alltraffic: Type: AWS::EC2::SecurityGroup Properties: GroupDescription: SG Permitting All Traffic VpcId: {{ aws_cf_vpc_id }} SecurityGroupIngress: CidrIp: 0.0.0.0/0 IpProtocol: -1 FromPort: -1 ToPort: -1 SecurityGroupEgress: CidrIp: 0.0.0.0/0 IpProtocol: -1 FromPort: -1 ToPort: -1 Tags: – Key: Name Value: “All Traffic SG” – Key: Costcenter Value: {{ aws_cf_tags.Costcenter }} win01: […]

bgp.j2

{% macro render_neighbors(parent, indent) %} {% if ‘neighbors’ in parent %} {% for neighbor_id, neighbor in parent[‘neighbors’]|sort_by_ip_as_int() %} {# ############################################## activate #} {% if ‘activate’ in neighbor and neighbor[‘activate’] %} – “{{indent}}neighbor {{ neighbor[‘ipv4_address’] }} activate” {% endif %} {# ############################################## remote_as #} {% if ‘remote_as’ in neighbor %} – “{{indent}}neighbor {{ neighbor[‘ipv4_address’] }} remote-as […]

Ansible files for Joggler dashboard configuration

homeassistant: customize: !include customize.yaml auth_providers: # Don’t require login on local network – type: trusted_networks trusted_networks: – 192.168.1.0/24 – 2001:xxxx:xxxx::/64 – fe80::/10 allow_bypass_login: true – type: homeassistant #!/bin/bash sh -c “echo 0 > /sys/class/rtc/rtc0/wakealarm” sh -c “echo `date ‘+%s’ -d ‘+ 450 minutes’` > /sys/class/rtc/rtc0/wakealarm” /sbin/shutdown -h now — – name: Install X etc apt: […]