Is it possible / valid to run more than one playbooks for a vagrant ansible provisioner in the following form:
config.vm.define "repo", primary: true do |d|
d.vm.hostname = "some.hostname"
# Create a private network, which allows host-only access to the machine
# using a specific IP.
d.vm.network :private_network, ip: "10.10.2.90"
d.vm.provision 'ansible' do |ansible|
ansible.config_file = 'ansible/ansible.cfg'
ansible.playbook = 'ansible/playbook1.yml'
ansible.playbook = 'ansible/playbook2.yml'
ansible.sudo = true
ansible.inventory_path = 'ansible/inventory/site'
ansible.host_key_checking = false
end
end
no it will not be valid
If you want to run 2 playbook, you would need to run the ansible provisioner twice, this can be done like
config.vm.define "repo", primary: true do |d|
d.vm.hostname = "some.hostname"
# Create a private network, which allows host-only access to the machine
# using a specific IP.
d.vm.network :private_network, ip: "10.10.2.90"
# First playbook
d.vm.provision "playbook1", type:'ansible' do |ansible|
ansible.config_file = 'ansible/ansible.cfg'
ansible.playbook = 'ansible/playbook1.yml'
ansible.sudo = true
ansible.inventory_path = 'ansible/inventory/site'
ansible.host_key_checking = false
end
# Second playbook
d.vm.provision "playbook2", type:'ansible' do |ansible|
ansible.config_file = 'ansible/ansible.cfg'
ansible.playbook = 'ansible/playbook2.yml'
ansible.sudo = true
ansible.inventory_path = 'ansible/inventory/site'
ansible.host_key_checking = false
end
end
You can also use a role instead of the playbook and the role contains pointers to multiple playbooks which are defined in the roles subdirectories. For example playbook.yml contains
---
- name: BaseOS configuration
hosts: all
become: yes
roles:
- baseos
- users
Both BaseOS and users exist in the roles subdirectory and will be executed in sequence when playbook.yml is called.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With