0

Learning Ansible, and mine is windows 10 machine. I enabled the windows feature, Windows Subsystem for Linux(WSL) and then installed Ubuntu app.

enter image description here

Then installed ansible as described here.

Now I created a simple text file with touch command - touch a.txt.

Now I tried the copy this using the copy module of the ansible as follows.

ansible -m copy -a "src=a.txt dest=~/a.txt" localhost 

and I get the following error.

localhost | UNREACHABLE! => {
    "changed": false,
    "msg": "Authentication or permission failure. In some cases, you may have been able to authenticate and did not have permissions on the target directory. Consider changing the remote tmp path in ansible.cfg to a path rooted in \"/tmp\". Failed command was: ( umask 77 && mkdir -p \"` echo /home/vivekubuntu/.ansible/tmp/ansible-tmp-1613225911.9928477-252950072612631 `\" && echo ansible-tmp-1613225911.9928477-252950072612631=\"` echo /home/vivekubuntu/.ansible/tmp/ansible-tmp-1613225911.9928477-252950072612631 `\" ), exited with result 1, stdout output: ansible-tmp-1613225911.9928477-252950072612631=/home/vivekubuntu/.ansible/tmp/ansible-tmp-1613225911.9928477-252950072612631\n",
    "unreachable": true
}

I even tried win_copy

ansible -m win_copy -a "src=a.txt dest=~/a.txt" localhost

I tried various other combinations. In the following, I replaced localhost with ip address.

ansible -m copy -a "src=a.txt dest=~/aa.txt" 192.168.56.1

Now I get the following warning.

[WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does not match
'all'
[WARNING]: Could not match supplied host pattern, ignoring: 192.168.56.1

Not clear how to start ansible on a windows machine. Please help.

1

1 Answer 1

1

looking at the line:

ansible -m copy -a "src=a.txt dest=~/a.txt" localhost 
  1. please note that -i as inventory argument is missing
  2. when providing hosts as a list and not as file ansible expects last host to end with , character
  3. host group selection at the end is also missing

so the correct invocation would be:

ansible -m copy -a "src=/tmp/a dest=~/a" -i localhost, all

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .