Deployment pipeline is an integral part of Devops toolchain, enabling best practices like continuous integration and continuous delivery.
- Continuous integration is a practice to continuously integrate and build the code.
- Continuous delivery means building the code, deploying to another environment and testing the code to make it ready for deploying to the production environment.
Automation is a crucial aspect of Deployment pipeline and can be achieved using Jenkins pipeline and tools like puppet, chef or ansible which can turn infrastructure into code. To quote Paul Venezia: “Puppet, Chef, Ansible, and Salt were all built with that very goal in mind: to make it much easier to configure and maintain dozens, hundreds, or even thousands of servers.”
Infrastructure as code
"The enabling idea of Infrastructure as Code is that the systems and devices used to run software can be treated as if they, themselves, are software." -- Kief Morris
Infrastructure as code (IaC) is a mechanism to make the infrastructure reliable, repeatable and fast by writing code for configuring environments and automating the provisioning of infrastructure.
- Infrastructure should never be resistant to changes, which should be made in a regular and automated fashion.
- Repetitive tasks should done via automation.
- Spinning up new environments should be self service.
- Focus should be on failure recovery rather than failure avoidance.
- It helps delivering stable environments rapidly and scalably.
- Since the desired state of the environment is represented by code, no manual configuration is required.
- As opposed to manual provisioning, which are harder to debug because of different configurations and imprecise instructions, IaC makes servers more consistent, as their configuration is defined using code.
As described in detail in the book "Infrastructure as Code" by Kief Morris, following are the principles of IaC.
- Reproducibility: One should be able to build or rebuild any part of the infrastructure.
- Consistency: All servers should run the same version of software and configurations.
- Disposability: It should be possible to destroy servers for cases like hardware failures, reducing capacity, replacing servers etc.
- Service Continuity: Even if infrastructure pieces fail, service should be able to handle user requests. Having backup servers are required to prevent interruption of service in case a server goes down.
- Self-testing systems: Automated testing is one of the key practices that enables fast feedback to developers in order to assess whether their changes would work correctly without causing any breakages.
- Self-documenting systems: With IaC, the documentation is implicit in the scripts and tools carrying out the process.
- Versioning infrastructure code: Just like in application code, version control helps in keeping track of changes to infrastructure code and rolling them back if required.