Infrastructure Configuration Inspector
Lay out a Terraform file and find variables that are used but not declared, work out Terraform’s cidrsubnet and cidrhost, read a saved plan as a table, check an Ansible playbook, or write an inventory. Everything happens in your browser; nothing is planned, applied or run.
Terraform file
CIDR functions
Terraform plan
Ansible playbook
Write an Ansible inventory
Terraform files
- Lay it out uses the two layout rules of the Terraform style guide: two spaces for each nesting level, and the equals signs of arguments on consecutive lines aligned. It also puts one space around =, removes spaces at line ends and keeps strings, heredocs and comments as they are.
- An unclosed string, heredoc, comment or bracket is reported with its line, and then the file is not changed.
- Find missing variables lists every var.name that has no variable "name" block and writes the blocks to add (as type = string; change the type where needed).
- Run terraform fmt and terraform validate on your machine for the final word: this page does not read providers or modules.
CIDR functions
cidrsubnet, cidrsubnets, cidrhost and cidrnetmask work as Terraform’s functions do, for IPv4 and IPv6: cidrsubnet("10.1.2.0/24", 4, 15) is 10.1.2.240/28, and cidrsubnets("10.1.0.0/16", 4, 4, 8, 4) gives 10.1.0.0/20, 10.1.16.0/20, 10.1.32.0/24 and 10.1.48.0/20 (the examples of the Terraform documentation). A negative hostnum counts from the end of the range.
Terraform plans
Save a plan and turn it into JSON: terraform plan -out=plan.out, then terraform show -json plan.out > plan.json. Paste or open plan.json to see what is created, changed, destroyed or replaced, with the changed attributes, values known only after apply, the attributes that force a replacement, and sensitive values hidden.
Ansible
- Each play has hosts and only play keywords; each task has exactly one module (any key that is not a task keyword counts as a module); block, rescue and always are followed.
- notify names a handler of the play (by name or listen); when, changed_when, failed_when and until are written without {{ }}; loop and with_… are not used together; shell commands that have a module of their own are pointed out.
- Lay it out re-indents the playbook (2 spaces, lists indented under their key) and keeps comments and quotes.
- Write inventory: one host per line, then its groups (comma-separated) and variables (name=value). You get inventory.ini and inventory.yml.