I have this play.yml
---
- hosts: 127.0.0.1
connection: local
sudo: false
tasks:
- include: apache.yml
My Apache look like this:
vars:
url: czxcxz
- name: Download apache
shell: wget {{url}}
This is giving me error.
If I remove vars
then it works. But I want to include the vars inside tasks so that I can keep different vars for different tasks separate.
Best Answer
NOTE: Using
set_fact
as described below sets a fact/variable onto the remote servers that the task is running against. This fact/variable will then persist across subsequent tasks for the entire duration of your playbook.Also, these facts are immutable (for the duration of the playbook), and cannot be changed once set.
ORIGINAL ANSWER
Use
set_fact
before your task to set facts which seem interchangeable with variables:See http://docs.ansible.com/set_fact_module.html for the official word.