Building Cloud images for Linode with Packer

From LearnLinux.tv Wiki
Jump to navigationJump to search

Overview

In this video, Jay shows how to build cloud images for use with Linode, by using Hashicorp Packer. Packer is an awesome tool for automating the building of cloud resources.

Relevant Links
Original Video

First example

 {
   "variables": {
     "linode_api_token": ""
   },
 
 
   "builders": [{
     "type": "linode",
     "linode_token": "Template:User `linode api token`",
     "image": "linode/debian10",
     "region": "us-east",
     "instance_type": "g6-nanode-1",
     "ssh_username": "root",
     "instance_label": "myserver-Template:Timestamp",
     "image_label": "my-image-Template:Timestamp",
     "image_description": "My first Packer image"
   }]
 }

Second example

 {
   "variables": {
     "linode_api_token": ""
   },
 
   "builders": [{
     "type": "linode",
     "linode_token": "Template:User `linode api token`",
     "image": "linode/debian10",
     "region": "us-east",
     "instance_type": "g6-nanode-1",
     "ssh_username": "root",
     "instance_label": "myserver-Template:Timestamp",
     "image_label": "my-image-Template:Timestamp",
     "image_description": "My first Packer image"
   }],
 
   "provisioners": [{
     "type": "shell",
     "script": "script.sh"
   }]
 
 }

Apache install script

 #!/bin/bash
 
 sudo apt update
 
 sudo apt install -y apache2