Skip to content

Commit

Permalink
Support multiple playbooks for provisioning (theforeman#256)
Browse files Browse the repository at this point in the history
  • Loading branch information
ehelms authored Jul 24, 2016
1 parent cf49575 commit a022ff1
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 4 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,5 @@ Gemfile.lock
.ruby-gemset
*.retry
*.pyc
user_playbooks/*.yml
user_playbooks/*.yaml
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,19 @@ static:
libvirt__iface_name: vnet2
```

#### Ansible

Boxes can be further customized by declaring Ansible playbooks to be run during provisioning. One or more playbooks can be specified and will be executed sequentially. An ignored directory can be used to put playbooks into 'user_playbooks' without worrying about adding them during a git commit.

```
ansible:
box: centos7-katello-nightly
ansible:
playbook:
- 'user_playbooks/vim.yml'
- 'user_playbooks/zsh.yml'
```

### Plugins

Any file on path `./plugins/*/Vagrantfile` will be loaded on `./Vagrantfile` evaluation. `plugins` directory is ignored by git therefore other git repositories can be cloned into `plugins` to add custom machines.
Expand Down
22 changes: 18 additions & 4 deletions Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,25 @@ module Forklift
@ansible_groups["server-#{box.fetch('name')}"] = box['ansible']['server']
end

if box['ansible'].key?('playbook')
machine.vm.provision :ansible do |ansible|
ansible.playbook = box.fetch('ansible').fetch('playbook')
if (playbooks = box['ansible']['playbook'])

if playbooks.is_a?(String)
machine.vm.provision 'main', type: 'ansible' do |ansible|
ansible.playbook = playbooks

ansible.groups = @ansible_groups
end

elsif playbooks.is_a?(Array)

playbooks.each_with_index do |playbook, index|
machine.vm.provision "main#{index}", type: 'ansible' do |ansible|
ansible.playbook = playbook

ansible.groups = @ansible_groups
end
end

ansible.groups = @ansible_groups
end
end
end
Expand Down
Empty file added user_playbooks/.gitkeep
Empty file.

0 comments on commit a022ff1

Please sign in to comment.