I'm trying to create a cron job using Ansible with this playbook:
---
- name: Crontab dosyasını düzenle
hosts: localhost
gather_facts: false
vars:
ansible_job_id: "1.0.0"
tasks:
- name: Crontab görevini ekle
cron:
name: "Run Python script daily"
minute: "0"
hour: "0"
job: "python3 -c 'print((\"{{ ansible_job_id }}\")'")
state: present
register: output
- name: Sonucu göster 1
debug:
var: output.stdout
- name: Sonucu göster 2
debug:
var: ansible_job_id
But, when I run the playbook, the task named Sonucu göster 1 gives the error
VARIABLE IS NOT DEFINED!
It seems that the output.stdout variable is not properly registered.
How can I resolve this issue?