Git Product home page Git Product logo

packer's Introduction

Packer

Packer

Testing HashiCorp's Packer - a tool for building Golden Images.


Starting a Packer build:

# First prettify packer files
packer fmt Jenkins-AMI/

# Validate that the syntax is correct 
packer validate Jenkins-AMI/

# Start the build 
packer build Jenkins-AMI/

Building Consul AMI

# Select whether it's a client or server machine 
 packer build -var is_server=true consul/

Provisioners

  • Used for copying files from local machine to the machine being built by Packer
  • Common pattern is to copy files to /tmp directory in the Packer machine as it can be freely modified

  • Some issues were faced as a result of running as ec2-user instead of root
  • To become root execute_command is used with the provisioner
Becoming root with shell provisioner

  // Configure AMI as NAT Instance
  provisioner "shell" {
    /* 
    - execute_command changes the default user from ec2-user to root
    - sysctl commands aren't allowed to be run under the default ec2-user as they modify the kernel 
    */
    execute_command = "echo 'packer' | sudo -S env {{ .Vars }} {{ .Path }}"
    inline = [
      # https://www.kabisa.nl/tech/cost-saving-with-nat-instances/
      "sysctl -w net.ipv4.ip_forward=1 >> /etc/sysctl.conf",
      "/sbin/iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE",
      "iptables-save > /etc/iptables.conf",
      "echo 'iptables-restore < /etc/iptables.conf' >> /etc/rc.local"
    ]
  }

packer's People

Contributors

thejaxon avatar

Stargazers

 avatar  avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.