I am writing ansible playbook, and set the below variable :
default_tz: 'ZONE="America/Los_Angeles"'
I am trying to add the above variable to a file, by using the below code On the same playbook:
- name: configure time zone
  lineinfile:
   line: "{{ default_tz }}"
   dest: "/etc/sysconfig/clock"
I am getting the below error while running the playbook:
"The task includes an option with an undefined variable. The error was: 'default_tz' is undefined\
You should declare variable in the scope of variables. Like this:
vars:
   default_tz: 'ZONE="America/Los_Angeles"'
https://docs.ansible.com/ansible/latest/user_guide/playbooks_variables.html#defining-variables-in-a-playbook
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With