Packer template to create nginx-nvm-mongo stack images using Ansible provisioning
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


This template uses Packer to build a DigitalOcean snapshot running Ubuntu. Packer will use Ansible to provision the machine and perform the following steps:

  • add a new user and configure groups
  • enable and configure sudo
  • enable some opinionated ssh security settings
  • adding your ssh key to the droplet
  • enable and configure ufw firewall
  • set up zsh and oh-my-zsh
  • install and configure nginx to serve a static folder and an upstream backend
  • install nvm, node.js and a list of required npm packages
  • install mongodb

Have fun !



This will clone the repository and its git dependencies

git clone
git submodule init
git submodule update


Packer's configuration is in build.json, you must add your api_token there or refer to the Packer Documentation in order to use other builders.

The Ansible provision script ./ansible/provision.yml has some variables defined at ./ansible/vars.yml.

Take a look to the shell variables used in ./, you may need to adapt this script to your system's requirements.



At the end of the deployment process, you should be able to launch the created droplet from your DigitalOcean panel. You can log into the droplet via ssh using the user you specified in ./ansible/vars.yml.

Place your static files in the folder associated with the variable nginx_root and run your application server on the port associated with the variable node_port.


echo "<h1> works </h1>" > ~/project/index.html

And then open your droplet IP in your browser.


  • If errors occur creating the droplet, then you should double-check if the installed packer version is greater than 0.8.

  • You should not upload folders containing symlinks or you will run into the following issue:

    errored: Error uploading playbook_dir directory

    That's why ./ is actually deleting all symlinks from the project folder.