Created
October 25, 2021 14:55
-
-
Save takahisa/7507aad078d9c06535492494e5f2144e to your computer and use it in GitHub Desktop.
Vagrantfile (動かない)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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