Hmm, as I say I don't know what kitchen expects, however it strikes me as
unusual to have your playbook stored in the tasks folder of your role.
Generally playbooks list one or more roles that should be applied to the
hosts in the current play, so it seems odd to have the playbook stored in
with the role.
Can you try just using 'bare' ansible without it being wrapped in kitchen?
Might be worth running ansible-playbook with -vvvvv to get debugging
information including the paths where it is looking for things.
Hope this helps,
Jon
On Monday, November 19, 2018 at 10:58:47 AM UTC, Ian Burrows wrote:
>
> 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/5c968185-dcd8-4336-b294-889ab6146246%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.