cancel
Showing results for 
Search instead for 
Did you mean: 
spurs
Flight Engineer
Flight Engineer
  • 1,628 Views

group_vars/all/timezone.yml, file question

Jump to solution

Hello,

I have group_vars/all/timezone.yml including variable host_timezone and below playbook is the answer, but I don't know how this playbook find a group_vars/all/timezone.yml file without vars_files.

 

---
- name: Time Synchronization
  hosts: database_servers

  roles:
    - rhel-system-roles.timesync

  post_tasks:
    - name: Set timezone
      timezone:
        name: "{{ host_timezone }}"
      notify: reboot host

  handlers:
    - name: reboot host
      reboot:

 

Labels (1)
1 Solution

Accepted Solutions
Emanuel_Haine
Flight Engineer
Flight Engineer
  • 1,561 Views

Hi @spurs 

This is a good question and it can be explained by the Ansible variable precedence: https://docs.ansible.com/ansible/latest/playbook_guide/playbooks_variables.html#understanding-variab...

 

View solution in original post

0 Kudos
4 Replies
morbius
Flight Engineer
Flight Engineer
  • 1,584 Views

Ansible already expects that what it finds in group_vars and host_vars files or directories are variables, so you don't need to declare them in vars_files.

spurs
Flight Engineer
Flight Engineer
  • 1,507 Views

thank you! but i need to use vars_files when my variable files are in the vars folder?

0 Kudos
Emanuel_Haine
Flight Engineer
Flight Engineer
  • 1,562 Views

Hi @spurs 

This is a good question and it can be explained by the Ansible variable precedence: https://docs.ansible.com/ansible/latest/playbook_guide/playbooks_variables.html#understanding-variab...

 

0 Kudos
spurs
Flight Engineer
Flight Engineer
  • 1,507 Views

thank you!

0 Kudos
Join the discussion
You must log in to join this conversation.