Book Image

Infrastructure as Code (IAC) Cookbook

By : Stephane Jourdan, Pierre Pomès
Book Image

Infrastructure as Code (IAC) Cookbook

By: Stephane Jourdan, Pierre Pomès

Overview of this book

Para 1: Infrastructure as code is transforming the way we solve infrastructural challenges. This book will show you how to make managing servers in the cloud faster, easier and more effective than ever before. With over 90 practical recipes for success, make the very most out of IAC.
Table of Contents (18 chapters)
Infrastructure as Code (IAC) Cookbook
Credits
About the Authors
About the Reviewer
www.PacktPub.com
Customer Feedback
Preface
Index

Installing packages


We need some packages for our server. Now our server is configured to use Chef and talk to a Chef server, let's install a few packages such as the Apache server, PHP, and MariaDB to build a classic LAMP server on a CentOS 7.2 server.

Getting ready

To work through this recipe, you will need the following:

  • A working Chef DK installation on the workstation

  • A working Chef client configuration on the remote host

How to do it…

To install a package on a Red Hat-based system, we'd use either yum (until CentOS 7) or dnf (for Fedora after version 22). As we're using a CentOS 7 server, the Apache2 HTTP server package name is httpd, (it's apache2 on Debian-based systems). Manually, we would have typed the following:

$ dnf install httpd
$ yum install httpd

Let's see how this translates into a repeatable process with a Chef cookbook.

Generating an empty Apache cookbook

Let's start by creating an empty cookbook from inside the Chef repository cookbooks folder to install Apache2 using the chef...