Is there a way to use the host_vars/ or group vars/ OR for that matter defaults/ or any sort of variable plugins from some_playbook.yml
that consumes a custom collection. The imported role can't see any variables.
# some_collection
galaxy.yml
playbooks
|_playbook.yml
roles
|_autopatch <-- is templated i.e. do auto patching and take "datetime" as variable
|_role2
Ideal case for host_vars as it can be per-host. Obviously if I have 2 servers in a cluster I can't hardcode the date and have them reboot at the same time.
inventory
collections.yml
group_vars
host_vars
some_playbook.yml
---
# some_playbook.yml
- hosts: all
name:
tasks:
import_role: namespace.some_collection.autopatch
Right now I get
TASK [namespace.some_collection.autopatch : Setup autopatch cron file] *****************************************************************************************************************
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: ansible.errors.AnsibleUndefinedVariable: 'datetime' is undefined
Now, I can do this, but it doesn't really scale with hosts: all
.
tasks:
import_role: namespace.some_collection.autopatch
vars:
datetime: "yolo"