Skip to content

Commit 800de01

Browse files
authored
Merge pull request #18 from JonasVerhofste/provision-changes
Put ansible provision step in a function again
2 parents f95de2c + 227d99a commit 800de01

File tree

1 file changed

+15
-11
lines changed

1 file changed

+15
-11
lines changed

Vagrantfile

+15-11
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,20 @@ end
118118

119119
# }}}
120120

121+
def provision_ansible(node, host, groups)
122+
ansible_mode = run_locally? ? 'ansible_local' : 'ansible'
123+
node.vm.provision ansible_mode do |ansible|
124+
ansible.compatibility_mode = '2.0'
125+
if ! groups.nil?
126+
ansible.groups = groups
127+
end
128+
ansible.playbook = host.key?('playbook') ?
129+
"ansible/#{host['playbook']}" :
130+
"ansible/site.yml"
131+
ansible.become = true
132+
end
133+
end
134+
121135
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
122136
config.ssh.insert_key = false
123137
hosts.each do |host|
@@ -142,17 +156,7 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
142156
end
143157

144158
# Ansible provisioning
145-
ansible_mode = run_locally? ? 'ansible_local' : 'ansible'
146-
node.vm.provision ansible_mode do |ansible|
147-
ansible.compatibility_mode = '2.0'
148-
if ! groups.nil?
149-
ansible.groups = groups
150-
end
151-
ansible.playbook = host.key?('playbook') ?
152-
"ansible/#{host['playbook']}" :
153-
"ansible/site.yml"
154-
ansible.become = true
155-
end
159+
provision_ansible(node, host, groups)
156160
end
157161
end
158162
end

0 commit comments

Comments
 (0)