Reader small image

You're reading from  Infrastructure as Code (IAC) Cookbook

Product typeBook
Published inFeb 2017
PublisherPackt
ISBN-139781786464910
Edition1st Edition
Right arrow
Authors (2):
Stephane Jourdan
Stephane Jourdan
author image
Stephane Jourdan

Stephane Jourdan is a passionate infrastructure engineer, enthusiastic entrepreneur, zealous trainer, and continuous learner, working on innovative infrastructures since the early 2000s. He focuses equally on tools and culture, in environments as different as startups, online audio/video media, e-commerce, and semi-conductors. The common point between all these experiences is that success comes with rigor, technical repeatability, communication, and a shared team culture. He co-founded an infrastructure automation consultancy (https://www.linkedin.com/company/green-alto), a web radio (http://phauneradio.com/), a container/serverless platform for developers (https://www.squarescale.com/), and a sound design studio (http://www.tarabust.com/). When Stephane isn't starting or contributing to new open source projects, he's usually found hiking in remote places with his camera.
Read more about Stephane Jourdan

Pierre Pomès
Pierre Pomès
author image
Pierre Pomès

Pierre Pomès is a senior enthusiastic engineer of open source technologies and a Linux adept since 1994. He has been working in the IT industry for the last twenty years mostly in C development, system administration, and security including PCI-DSS. He is currently an architect and a DevOps team leader for Reservit, an online hotel booking engine. He has also contributed to the pfSense project.
Read more about Pierre Pomès

View More author details
Right arrow

Managing files, directories, and templates


A very useful Chef feature is the ability to manage files right from the Chef code. Either plain files can be copied or dynamic files can be generated through templates. We'll leverage this feature to create an example PHP test file and dynamically generate Apache VirtualHosts for our LAMP server, so you'll know how to reuse it anywhere else.

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

  • Optionally, the Chef code from the previous recipes

How to do it…

We'll manage two different kinds of files in two different ways: a static file and a dynamic file generated from a template, so the most common usage is covered.

Managing a simple static file

Let's begin by creating a basic PHP file that will only display the phpinfo() result. This is done using the simple file resource with the file path as argument, giving its content inline...

lock icon
The rest of the page is locked
Previous PageNext Page
You have been reading a chapter from
Infrastructure as Code (IAC) Cookbook
Published in: Feb 2017Publisher: PacktISBN-13: 9781786464910

Authors (2)

author image
Stephane Jourdan

Stephane Jourdan is a passionate infrastructure engineer, enthusiastic entrepreneur, zealous trainer, and continuous learner, working on innovative infrastructures since the early 2000s. He focuses equally on tools and culture, in environments as different as startups, online audio/video media, e-commerce, and semi-conductors. The common point between all these experiences is that success comes with rigor, technical repeatability, communication, and a shared team culture. He co-founded an infrastructure automation consultancy (https://www.linkedin.com/company/green-alto), a web radio (http://phauneradio.com/), a container/serverless platform for developers (https://www.squarescale.com/), and a sound design studio (http://www.tarabust.com/). When Stephane isn't starting or contributing to new open source projects, he's usually found hiking in remote places with his camera.
Read more about Stephane Jourdan

author image
Pierre Pomès

Pierre Pomès is a senior enthusiastic engineer of open source technologies and a Linux adept since 1994. He has been working in the IT industry for the last twenty years mostly in C development, system administration, and security including PCI-DSS. He is currently an architect and a DevOps team leader for Reservit, an online hotel booking engine. He has also contributed to the pfSense project.
Read more about Pierre Pomès