Localhost is your ansible server and it doesn’t work with windown module, you need to specify the client group name
Sent from my iPhone > On Apr 16, 2020, at 16:59, Pavan K Kumar <pavankr.b...@gmail.com> wrote: > > > Hello Experts, > > > > I'm new to Ansible and PowerShell. > > > > I have installed cygwin in my windows 10 Operating system and installed > ansible and its related packages as per below mail. > > https://geekflare.com/ansible-installation-windows/ > > > > Here are the environment details > > Ansible version: 2.8.4 > python version : 3.7.7 (default, Apr 10 2020, 07:59:19) [GCC 9.3.0] > > Powershell Version: 5.1.17763.1007 > > > > on above successful setup, i tried to run my below sample ansible script with > hosts as "localhost" > > > > - hosts: localhost > > tasks: > > - name: "run whoami" > > win_command: whoami > > register: whoami_out > > - debug: var=whoami_out.stdout_lines > > > but, i am ending up with the below error > > [WARNING]: provided hosts list is empty, only localhost is available. Note > that the implicit localhost does not match 'all' > > PLAY [localhost] > *********************************************************************************************************************************************************** > > TASK [Gathering Facts] > ***************************************************************************************************************************************************** > ok: [localhost] > > TASK [run whoami] > ********************************************************************************************************************************************************** > fatal: [localhost]: FAILED! => {"changed": false, "module_stderr": > "/home/Pavan.Kammara/.ansible/tmp/ansible-tmp-1586957425.671443-215768864612631/AnsiballZ_win_command.ps1 > : The term > \r\n'/home/Pavan.Kammara/.ansible/tmp/ansible-tmp-1586957425.671443-215768864612631/AnsiballZ_win_command.ps1' > is not \r\nrecognized as the name of a cmdlet, function, script file, or > operable program. Check the spelling of the name, or if \r\na path was > included, verify that the path is correct and try again.\r\nAt line:1 > char:1\r\n+ > /home/Pavan.Kammara/.ansible/tmp/ansible-tmp-1586957425.671443-215768 > ...\r\n+ > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\r\n + > CategoryInfo : ObjectNotFound: (/home/Pavan.Kam...win_command.ps1:String) [], > CommandNotFoundException\r\n + FullyQualifiedErrorId : > CommandNotFoundException\r\n \r\n", "module_stdout": "", "msg": "MODULE > FAILURE\nSee stdout/stderr for the exact error", "rc": 1} > > PLAY RECAP > ***************************************************************************************************************************************************************** > localhost : ok=1 changed=0 unreachable=0 failed=1 skipped=0 rescued=0 > ignored=0 > > > and i tried the 2nd approach by creating my windows 10 machine ip address in > etc/ansible/ansible.cfg and referred the same in asnible playbook as below > > - hosts: all > tasks: > - name: "run whoami" > win_command: whoami > register: whoami_out > - debug: var=whoami_out.stdout_lines > > this time also ended up with the different error, PFB > > PLAY [all] > ***************************************************************************************************************************************************************** > > TASK [Gathering Facts] > ***************************************************************************************************************************************************** > fatal: [192.***.*.***]: UNREACHABLE! => {"changed": false, "msg": "Failed to > connect to the host via ssh: ssh: connect to host 192.***.*.*** port 22: > Connection refused", "unreachable": true} > > PLAY RECAP > ***************************************************************************************************************************************************************** > 192.***.*.*** : ok=0 changed=0 unreachable=1 failed=0 > skipped=0 rescued=0 ignore > > Kindly help me, is it something the environment set up issue. Im completely > clueless why it is not working as im new to this technology. > > Thanks in advance! > > -- > 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 ansible-project+unsubscr...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/ansible-project/0a657327-034b-4131-a9b7-9ee99364889a%40googlegroups.com. -- 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 ansible-project+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/9C687440-C911-4F6A-8C6E-3401B6DD8897%40gmail.com.