Why Ansible doesn't read the templates in relative path?

Ansible will only look in the roles/users/templates directory when you explicitly use the role "users", which you are not using in your example. To do what you want you need to change your site.yml to look something like this:

- hosts: users
  remote_user: root
  sudo: True
  roles:
    - { role: users }

Then in roles/users/tasks/main.yml you would have:

- name: templates
  template: src="fig.conf.j2" dest="/home/vagrant/fig.conf"

The role in site.yml tells Ansible to invoke the yaml file roles/users/tasks/main.yml. Tasks that refer to files or templates within that role will by default look in roles/users/files and roles/users/templates for those files/templates. You might want to read more about roles in the Ansible documentation to make sure you better understand how they fit together.

Tags:

Ansible