Last active
October 18, 2018 14:36
-
-
Save gliech/d071cea1cb71dc9906f09389670ffa21 to your computer and use it in GitHub Desktop.
Ansible 2.7 breaks include_tasks in handlers
This file contains 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
# -*- mode: ruby -*- | |
# vi: set ft=ruby : | |
guests = [ | |
{ name: 'ansible-old', ansible_ver: '2.6.5', verbose: false }, | |
{ name: 'ansible-new', ansible_ver: '2.7.0', verbose: true }, | |
] | |
script = <<-SCRIPT | |
cat << "EOF" > playbook.yml | |
--- | |
- hosts: all | |
tasks: | |
- name: include a task from the tasks section | |
include_tasks: include.yml | |
- name: notify a handler | |
debug: | |
msg: bar | |
changed_when: yes | |
notify: include a task from the handlers section | |
handlers: | |
- name: include a task from the handlers section | |
include_tasks: include.yml | |
EOF | |
cat << "EOF" > include.yml | |
--- | |
- name: an included task | |
debug: | |
msg: foo | |
EOF | |
SCRIPT | |
VAGRANTFILE_API_VERSION = "2" | |
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| | |
guests.each do |guest| | |
config.vm.define guest[:name] do |machine| | |
machine.vm.hostname = guest[:name] | |
machine.vm.box = "bento/ubuntu-18.04" | |
config.vm.provision "shell", inline: script | |
machine.vm.provision "ansible_local", run: "always" do |ansible| | |
ansible.install_mode = "pip" | |
ansible.version = guest[:ansible_ver] | |
ansible.provisioning_path = "/home/vagrant" | |
ansible.playbook = "playbook.yml" | |
ansible.playbook_command = "PYTHONUNBUFFERED=1 ANSIBLE_FORCE_COLOR=true ansible-playbook" | |
if guest[:verbose] | |
ansible.verbose = "vvvv" | |
end | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment