Skip to content

Instantly share code, notes, and snippets.

@akaron
Created August 6, 2020 10:17
Show Gist options
  • Save akaron/85c7575aa81bd810255b94f6751098c7 to your computer and use it in GitHub Desktop.
Save akaron/85c7575aa81bd810255b94f6751098c7 to your computer and use it in GitHub Desktop.
an example Vagrant file which uses ansible to provision
---
- hosts: all
gather_facts: no
become: yes
tasks:
- name: Install unzip
apt:
name: unzip
state: present
update_cache: yes
- name: Get terraform
get_url:
url: https://releases.hashicorp.com/terraform/0.12.29/terraform_0.12.29_linux_amd64.zip
dest: /tmp/terraform.zip
checksum: 'sha256:872245d9c6302b24dc0d98a1e010aef1e4ef60865a2d1f60102c8ad03e9d5a1d'
mode: '0755'
- name: unarchive terraform
unarchive:
remote_src: yes
src: /tmp/terraform.zip
dest: /tmp
- name: move terraform binary to PATH
become: yes
copy:
remote_src: yes
src: /tmp/terraform
dest: /usr/local/bin/terraform
mode: "0755"
- name: Get packer
get_url:
url: https://releases.hashicorp.com/packer/1.6.1/packer_1.6.1_linux_amd64.zip
dest: /tmp/packer.zip
checksum: "sha256:8dcf97610e8c3907c23e25201dce20b498e1939e89878dec01de6975733c7729"
- name: unarchive packer
unarchive:
remote_src: yes
src: /tmp/packer.zip
dest: /tmp
- name: move helm binaries to PATH
become: yes
copy:
remote_src: yes
src: /tmp/packer
dest: /usr/local/bin/packer
mode: "0755"
# -*- mode: ruby -*-
# vi: set ft=ruby :
# ENV["LC_ALL"] = "en_US.UTF-8"
Vagrant.configure("2") do |config|
config.vm.box = "ubuntu/xenial64"
config.vm.provider "virtualbox" do |v|
v.name = "tst_terraform_packer"
end
config.vm.provider "virtualbox"
# config.vm.synced_folder '.', '/vagrant', disabled: true
# config.vm.provider "virtualbox" do |vb|
# # Display the VirtualBox GUI when booting the machine
# vb.gui = true
# vb.memory = "1024"
# end
# provision
# copy one of my aws credential into the VM
config.vm.provision "file", source: "~/tmp/.aws", destination: "$HOME/.aws"
config.vm.provision :ansible do |ansible|
ansible.playbook = "playbook.yml" # install terraform and packer
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment