`include_role` does not work
Summary
When I use this role with module include_role
, ansible complains about undefined variable _docker_service_start_command
Steps to reproduce
test.yml
:
---
- name: "olaboga test"
hosts: localhost
tasks:
- name: "register docker service with nginx"
include_role:
name: "docker"
tasks_from: "service_base"
vars:
service_name: "test_service_docker"
docker_service_image: "hello-world"
ansible-playbook -i inventory test.yml
Expected behavior
Everything should be OK.
Actual behavior
Step service : Check if basic parameters are set
fails.
Relevant logs and/or screenshots
TASK [service : Check if basic parameters are set] *****************************
fatal: [localhost]: FAILED! => {"failed": true, "msg": "The conditional check 'service_name is not defined or service_start_command is not defined or service_stop_command is not defined' failed. The error was: error while evaluating conditional (service_name is not defined or service_start_command is not defined or service_stop_command is not defined): {{ _docker_service_start_command }}: '_docker_service_start_command' is undefined\n\nThe error appears to have been in '/root/ansible-roles/roles/service/tasks/register.yml': line 11, column 3, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n- name: \"Check if basic parameters are set\"\n ^ here\n"}
Possible fixes
Use the ansible
version 2.2.1
when it will be ready.