Sign In Start Free Trial
Account

Add to playlist

Create a Playlist

Modal Close icon
You need to login to use this feature.
  • Book Overview & Buying Infrastructure as Code Cookbook
  • Table Of Contents Toc
  • Feedback & Rating feedback
Infrastructure as Code Cookbook

Infrastructure as Code Cookbook

By : Stephane Jourdan, Pierre Pomès
4 (1)
close
close
Infrastructure as Code Cookbook

Infrastructure as Code Cookbook

4 (1)
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 (12 chapters)
close
close
11
Index

Handling files using cloud-init

An early need we all face is to have a file, a license, or a script in place right from the beginning of the instance life. Cloud-init proposes different ways of sending those files over the new instance. We'll see how to send files using plain text and base64 data encodings.

Getting ready

To step through this recipe, you will need:

  • Access to a cloud-config enabled infrastructure

How to do it…

The first file we'll write is a MOTD (short for Message Of The Day) with root read-write permissions, read-only for everyone else. This file will have its content declared right from the cloud-config file:

#cloud-config
write_files:
  - path: /etc/motd
    content: |
      This server is configured using cloud-init.
      Welcome.
    owner: root:root
    permissions: '0644'

This machine, when booted, will have /etc/motd in place and display the string at login:

$ ssh ubuntu@server_ip
Welcome to Ubuntu 16.04.1 LTS (GNU/Linux 4.4.0-36-generic x86_64...

Unlock full access

Continue reading for free

A Packt free trial gives you instant online access to our library of over 7000 practical eBooks and videos, constantly updated with the latest in tech
bookmark search playlist font-size

Change the font size

margin-width

Change margin width

day-mode

Change background colour

Close icon Search
Country selected

Close icon Your notes and bookmarks

Delete Bookmark

Modal Close icon
Are you sure you want to delete it?
Cancel
Yes, Delete

Confirmation

Modal Close icon
claim successful

Buy this book with your credits?

Modal Close icon
Are you sure you want to buy this book with one of your credits?
Close
YES, BUY