Skip to content

Instantly share code, notes, and snippets.

@takahisa
Created October 25, 2021 14:55
Show Gist options
  • Save takahisa/7507aad078d9c06535492494e5f2144e to your computer and use it in GitHub Desktop.
Save takahisa/7507aad078d9c06535492494e5f2144e to your computer and use it in GitHub Desktop.
Vagrantfile (動かない)
N = 3
Vagrant.configure(2) do |config|
(1..N).each do |node_id|
config.vm.define "node-#{node_id}"
end
# Triggerを使って最後のVMをセットアップする時だけAnsible Provisionを有効にする。
config.trigger.before :up do |trigger|
node_id = 1
trigger.ruby do |env, machine|
if node_id < N
node_id += 1
else
machine.vm.config.provision :deploy, type: "ansible" do |ansible|
ansible.playbook = "site.yml"
end
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment