Having issue finding my hosts

I think you are misusing the directives:

- hosts: /ansible/hosts <= this will NOT use that file as inventory
for the play.

The hosts keyword is supposed to be a 'pattern', not a file nor
inventory source.

to use that as your inventory you can do:
ansible-playbook /ansible/playbook/test.yml -i /ansible/hosts

and set hosts: to 'all'

- hosts: all

YAML does not handle \ very well as it is an escaping character in most situations. When defining tasks I would highly recommend using the YAML for instead of the older key=arg form as it makes your code more readable and you don’t have to escape . Your task would now look like this

  • name: Copies file to Windows
    win_copy:
    src: /ansible/ansible.cfg
    dest: C:\Users\YRunner\Desktop\test1

When using the YAML form, you don’t need to escape \ unless you have double quoted the value. I found you don’t need to quote a value unless you want to convert it to a string or it contains a :.

This has more info on this particular topic http://docs.ansible.com/ansible/devel/windows_usage.html#path-formatting-for-windows.

Thanks

Jordan

I think the \t in your path will be interpreted as a tab character, which is not valid in a Windows path.

It's best to use key: value syntax when working with Windows paths, rather than the key=value style.

Generally, for hard coded windows paths they will work fine if you use key: value and enter the path in single quotes.

Hope this helps,

Jon

What I gave you is just the task to use in place of your win_copy one. You still need to specify the other playbook directives like hosts, tasks, roles and the like.

Thanks

Jordan

Hello Larry,
Any task in ansible comes under task module i think so your script will look like this:

  • hosts: nuc

tasks:

  • name: run simple script

script: C:\Users\YRunner\Desktop\lp1.bat