惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

V
V2EX
酷 壳 – CoolShell
酷 壳 – CoolShell
美团技术团队
有赞技术团队
有赞技术团队
Hugging Face - Blog
Hugging Face - Blog
罗磊的独立博客
S
SegmentFault 最新的问题
D
Docker
博客园 - 司徒正美
雷峰网
雷峰网
V
Visual Studio Blog
云风的 BLOG
云风的 BLOG
G
Google Developers Blog
The GitHub Blog
The GitHub Blog
A
About on SuperTechFans
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
博客园 - Franky
月光博客
月光博客
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
H
Hackread – Cybersecurity News, Data Breaches, AI and More
T
The Blog of Author Tim Ferriss
Google DeepMind News
Google DeepMind News
MyScale Blog
MyScale Blog
MongoDB | Blog
MongoDB | Blog

Stonecharioteer on Tech

I Traced My Traffic Through a Home Tailscale Exit Node What Was I Reading Last? In Three Not-So-Easy Pieces Dogfooding Is Hard Code blocks in your books, finally GoForGo v0.9.0 Merrilin - We built an app to read books I use a Macbook now Data Structures & Algorithms - Preparing for Interviews Using a local DNS namespace for local service discovery Direction KOllector - Publishing KOReader Highlights gbt: branches touched in the last 24 hours A Soiree into Symbols in Ruby Some Smalltalk about Ruby Loops Ruby Blocks Returning from Ruby Blocks, Procs and Lambdas My Linux Laptop Finally Works: How Claude Helped Me Fix Years of Annoyances TIL: Watchexec - Modern File Watching for Development Workflows A Less Busy Mind GoForGo - Learn Go through live examples Migrating My Old Blog to Hugo with Claude The Qtile Window Manager: A Python-Powered Tiling Experience Read the RFCs that Built the Internet Py-x-Protobuf - Or How I Learned to Stop Worrying and Love Protocol Buffers Python Reverse a List New Beginnings Leaving ChainSafe Systems Screen Lock for Cinnamon Desktop using Zenity and Terminal Commands Crews Not Teams A System for Getting Better at LeetCode
Vagrant
2022-01-10 · via Stonecharioteer on Tech

I’m late to the Vagrant train. I must have heard about it in 2014, but I’ve never bothered to look it up. I’m using it lately to test out my dotfiles, which I’m creating Ansible playbooks for. It’s convenient.

For those of you who’re either too young to have encountered it, or have never heard of it before, Vagrant is a tool that allows you to create a text-based configuration to spin up virtual machines. These machines can be spun up and destroyed at whim, and you will always get an identical machine as long as your configuration is defined and you do not install adhoc stuff directly without recording it in the config.

I’m not delving too deep into it, but all I need to know is how to provision a few machines with IPs I can communicate with using Ansible.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
Vagrant.configure("2") do |config|
  config.vm.define "ubuntu1" do |ubuntu1|
    ubuntu1.vm.box = "hashicorp/bionic64"
    ubuntu1.vm.host_name = "ubuntu1804"
    ubuntu1.vm.network "private_network", ip: "192.168.60.2"
  end

  config.vm.define "ubuntu2" do |ubuntu2|
    ubuntu2.vm.box = "bento/ubuntu-21.04"
    ubuntu2.vm.host_name = "ubuntu2104"
    ubuntu2.vm.network "private_network", ip: "192.168.60.3"
  end

  config.vm.define "arch1" do |arch1|
    arch1.vm.box = "archlinux/archlinux"
    arch1.vm.host_name = "archbtw"
    arch1.vm.network "private_network", ip: "192.168.60.4"
  end

end

In this file, I’m defining 3 virtual machines: 2 Ubuntu boxes and 1 archlinux box. Each of the machines gets a unique IP address from a subnet I don’t use in my local network. I’ve not yet figured out how to enable host-name broadcasting locally, so I refer to them in my Ansible hosts file with the IP address hard-coded in. This works fine for testing.

I bring up the machines with: vagrant up, and whenever I want fresh machines, I use vagrant destroy -f && vagrant up. If I were to change the config, the Vagrantfile, I’d just run vagrant reload --provision.

There’s something to be said about learning only what you need in today’s world, so this is all I’m learning about Vagrant. It helps me test out my Ansible playbooks so I’m happy there. I’ve looked at the provisioning commands as well, but I don’t need those right now. I’m happier running the commands externally through Ansible instead of telling the Vagrantfile to run my playbooks. Call it separation of concerns or standardized usage, if you will.