Thanks, my directory structure is as follows:
/
.kitchen.yml
roles/common/
--/tasks/playbook.yml
--/templates/create_motd.j2
test/
//.kitchen.yml
---
driver:
name: vagrant
provisioner:
name: ansible_playbook
hosts: all
require_ansible_repo: true
require_chef_for_busser: false
require_ruby_for_busser: false
ansible_verbose: true
ansible_verbosity: 3
playbook: ../cloud_ansible/roles/common/tasks/playbook.yml
roles_path: ../cloud_ansible/roles/common/
platforms:
- name: ubuntu-16.04
verifier:
name: inspec
suites:
- name: cloud_computing
//roles/common/tasks/playbook.yml
- name: Add configurations for Ubuntu
hosts: all
roles:
- common
vars:
v1: 'test'
group: ['sname1','sname2','sname3']
v2: 'test2'
change_me: 'change me'
tasks:
- name: Create Template for MOTD
template:
src: create_motd.j2
dest: /etc/motd
//roles/common/templates/create_motd.j2
{{v1}}
{% for item in group[ %}
{{item}}
{% endfor %}
{{v2}}
Last tool-run was: {{ansible_date_time.date}}
{{change_me}}
On Monday, November 19, 2018 at 9:50:57 AM UTC+1, J Hawkesworth wrote:
>
> Hard to guess what's going on here without seeing your playbook and
> template file, but my guess would be the template (.j2) file isn't in one
> of the places that ansible expects to find it.
>
> If your template is in a role (best place for it) then there are some
> rules about where ansible will look for templates (and other files)
> described here:
>
> https://docs.ansible.com/ansible/latest/user_guide/playbooks_reuse_roles.html#using-roles
>
> I can't speak for 'kitchen' as I haven't used for it, but the `template`
> module should copy (templated) files to the destination that is specified -
> but if it can't find the template then it wont of course.
>
> Hope this helps,
> Jon
>
>
> On Monday, November 19, 2018 at 8:25:47 AM UTC, Ian Burrows wrote:
>>
>> Hi, I am very new to Ansible and I have a question regarding the template
>> module.
>>
>> I am receiving an error running a playbook where ansible cannot find or
>> access the j2 file.
>>
>> If I transfer the file manually into /tmp/kitchen/ where it says it is
>> looking, then it runs fine. I am using Test Kitchen with kitchen-ansible,
>> Vagrant and Inspec on Windows. Is the template file not supposed to be sent
>> to the host with kitchen? Maybe this is a Test Kitchen issue of not
>> generating the files on the target?
>>
>> Thank you for any guidance.
>>
>
--
You received this message because you are subscribed to the Google Groups
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/fc85ddbf-22b1-4bae-973c-f0e7ce569df8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.