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...