user15824359
user15824359

Reputation: 101

Ansible refer to another directory

I have the following structure:

And my playbook.yml is inside playbooks folder:

  - name: "Write variable to file"
  vars:
    db_password: "{{ db_pass }}"
  template:
    src: templates/test.yml.j2
    dest: files/test.yml

But I cannot make it work, the error is : "msg": "Could not find or access 'templates/test.yml.j2' "msg": "Could not find or access 'templates/test.yml.j2'

How can I make my src and dest refer to files that are not in the same folder as playbook?

Upvotes: 0

Views: 555

Answers (1)

Nuno Oliveira
Nuno Oliveira

Reputation: 417

The files and templates folder isn't in the playbook directory, so you need to reference it like this:

  template:
    src: ../templates/test.yml.j2
    dest: ../files/test.yml

If I am mistaken, please send a better description of your folder structure.

Upvotes: 1

Related Questions