DevOps Fundamentals



Section 1: DevOps and Infrastructure as Code

DevOps Culture and Practices
Chapter 02: Provisioning Cloud Infrastructure with Terraform
Chapter 03: Using Ansible for Configuring IaaS Infrastructure
Chapter 04: Optimizing Infrastructure Deployment with Packer
	
Chapter 1: DevOps Culture and Practices 8
Getting started with DevOps 9
Implementing CI/CD and continuous deployment 12
Continuous integration (CI) 12
Implementing CI 13
Continuous delivery (CD) 15
Continuous deployment 17
Understanding IaC practices 19
The benefits of IaC 19
IaC languages and tools 20
Scripting types 20
Declarative types 20
The IaC topology 22
The deployment and provisioning of the infrastructure 22
Server configuration 22
Immutable infrastructure with containers 24
Configuration and deployment in Kubernetes 24
IaC best practices 25
Summary 27
Questions 28
Further reading 28


Chapter 2: Provisioning Cloud Infrastructure with Terraform 29
Technical requirements 29
Installing Terraform 30
Manual installation 30
Installation by script 31
Installing Terraform by script on Linux 31
Installing Terraform by script on Windows 32
Installing Terraform by script on macOS 35
Integrating Terraform with Azure Cloud Shell 35
Configuring Terraform for Azure 37
Creating the Azure SP 37
Configuring the Terraform provider 39
Terraform configuration for local development and testing 40
Writing a Terraform script to deploy Azure infrastructure 41
Following some Terraform good practices 45
Better visibility with the separation of files 45
Protection of sensitive data 45
Dynamizing the code with variables and interpolation functions 46
Deploying the infrastructure with Terraform 47
Initialization 49
Previewing changes 50
Applying the changes 52
Terraform command lines and life cycle 54
Using destroy to better rebuild 54
Formatting and validating the code 56
Formatting the code 56
Validating the code 57
Terraform's life cycle in a CI/CD process 58
Protecting tfstate in a remote backend 60
Summary 64
Questions 65
Further reading 65


Chapter 3: Using Ansible for Configuring IaaS Infrastructure 66
Technical requirements 67
Installing Ansible 67
Installing Ansible with a script 68
Integrating Ansible into Azure Cloud Shell 70
Ansible artifacts 71
Configuring Ansible 72
Creating an inventory for targeting Ansible hosts 74
The inventory file 74
Configuring hosts in the inventory 76
Testing the inventory 77
Writing the first playbook 79
Writing a basic playbook 79
Understanding Ansible modules 80
Improving your playbooks with roles 81
Executing Ansible 83
Using the preview or dry run option 85
Increasing the log level output 86
Protecting data with Ansible Vault 87
Using variables in Ansible for better configuration 87
Protecting sensitive data with Ansible Vault 91
Using a dynamic inventory for Azure infrastructure 93
Summary 102
Questions 102
Further reading 102

Chapter 4: Optimizing Infrastructure Deployment with Packer 104
Technical requirements 105
An overview of Packer 106
Installing Packer 106
Installing manually 106
Installing by script 107
Installing Packer by script on Linux 107
Installing Packer by script on Windows 108
Installing Packer by script on macOS 109
Integrating Packer with Azure Cloud Shell 109
Checking the Packer installation 110
Creating Packer templates for Azure VMs with scripts 111
The structure of the Packer template 111
The builders section 112
The provisioners section 113
The variables section 115
Building an Azure image with the Packer template 117
Using Ansible in a Packer template 120
Writing the Ansible playbook 120
Integrating an Ansible playbook in a Packer template 121
Executing Packer 122
Configuring Packer to authenticate to Azure 123
Checking the validity of the Packer template 124
Running Packer to generate our VM image 124
Using a Packer image with Terraform 127
Summary 128
Questions 129
Further reading 129
	

Eninam BAGNABANA     |         |     bagnadavid@outlook.fr     |