Yaml FTW! Infrastructure as code is eating the world (well, part of it). YAML, JSON, TOML, HCL and several other languages tend to describe the desired state of your infrastructure controlled by the STATE MACHINE. How does it work? Let’s dive into an illustrated journey behind the machinery of various tools like Terraform, Ansible, Kubernetes.
Declarations, not actions
Yaml is good for defining serialized data and declared state
But it does not support constructs for variables, functions, deep
And it is not so good for imperative/sequential scripts (I'm looking at
$ use apply solar_system.yml
use: Modifying Pluto...
use: Pluto's metadata modified in 10ns
fume: libraries on Earth have been updated
to reflect changes in Pluto's status
Signs of state management, idempotance is not always achievable.
Can be parallel only on node level, not resource (task) level.
No model for resource dependencies.
Imperative logic elements implemented in a declarative, but hardly
readable way ( register , set_fact , when ).
api-server will accept any valid object definition.
Will it be created and running? Eventually, it should.
Run-time state validation.
Not all attributes are changeable.
Custom resource definitions (+ operators).
Queries and dependencies only through labels.
Side effects are real
Know the tool
Know which resources you are managing
Know the side effects
There are tools for tools: linters, IDE plugins, schema validators.
Everything is a spectrum
Avoid dichotomy (bad/good, persistent/volatlie etc.), use a spectrum to
define your relationship with a tool/language.
Keep it sane
If you need a complex logic, use a %&?# programming language or a
better declarative language with functions and variables.
Infrastructure-as-code does not mean you should use the same data
language all over the place.
Do not use YAML for imperative logic. Do not let the history repeating.