Tradition IT & challenge
Buisiness -> buisness analyst -> solution architect -> Infra Team
résultat
- slow deployment
- expensive
- limited automation
- human error
- wasted ressources
- inconsistency
Type of IaC tool
-> Configuration management
- Ansible
- Puppet
- Saltstack
advantage
- designed to install and manage software
- maintain standard structure
- version contrôle
- idempotent
-> Server template’s
- Docker
- Packer
- Vagrant
Advantage
- pre installed software and dependency
- virtual machine or docker image
- immutable infra
-> provisioning tools
- Terraform
- Cloud formation
Advantage
- deploy immutable infra ressource
- server, databases
Why Terraform ?
it’s a declarative language -> init -> plan -> apply
Installation resource ??
Langage hcl2
|
|
Example of ressources
|
|
Default file
main.tf: ressource definition variable.tf: var declaration output.tf: contain output from ressource providers.tf: contain provider definition
.tfstate: très important c’est qui est en prod
Variable block
Best practice it’s to declare the type of the variable.
|
|
chapitre 26 a 30 à tester
Commande line
tf show pour voir ce qui a en place
tf plan: pour update faire un
tf output
tf refresh
tf validate
tf fmt
tf graph (le output est imbuvable il faut un soft graphviz) …
tf graph | dot -Tsvg > graph.svg
tf state show list | mv | rm pull | show
tf untaint: quand tu fais des modifications manu et tu veux pas que le tf pe
te
tw workspace:
Lifecycle
I have 3 mode of deployment:
- create_before_destroy
- prevent_destroy
- ignore_changes
|
|
Datasources
ressource=data create, update,destroy=reads managed ressources= data ressource
meta-argument ??
count
|
|
|
|
for-each
|
|
|
|
AWS
…
Remote state
state lock si le tfstate est dans le github. n’est pas bon il faut le mettre dans le s3
|
|
Logging
export TF_LOG = info | warning | error | debug | trace
export TF_LOG_PATH = /tmp/toto.log
Terraform import avec Ansible ??
Module
A voir pour le lab
Workspace parfait pour le lab