Jinja Templates
Idem allows you to use Jinja Templating in your state SLS files
Create an Azure Virtual Networks : my_virtual_networkstate.sls
{% set address_Prefixes = "10.0.0.0/24" %}
{% set vn_name = "TMM-VirtualNetwork-vRA" %}
{% set rg_name = "Moff-RG01-CAS" %}
{% set local_tags = {"createdWith":"idem", "owner":"tmm" } %}
{{ vn_name }}:
azure.virtual_networks.virtual_networks.absent:
- force_update: True
- resource_group_name: {{ rg_name }}
- virtual_network_name: {{ vn_name }}
- parameters:
location: centralus
name: {{ vn_name }}
properties:
addressSpace:
addressPrefixes:
- {{ address_Prefixes }}
enableDdosProtection: false
tags: {{ local_tags }}
The State SLS file can be executed with:
idem state my_virtual_networkstate.sls
idem state with Jinja Templating can significantly boost the scalability and performance of the run.
Let’s use this new state which verifies that 100 vpcs are absent : vpc_verify_absent.sls
{% for i in range(100) %}
idem_aws_test_vpc_{{i}}:
aws.ec2.vpc.absent:
- name: "idem_aws_test_vpc_{{i}}"
{% endfor -%}
The State SLS file can be executed with –runtime parallel to make full use of idem’s async execution calls:
idem state --runtime parallel vpc_verify_absent.sls