Best to just ask it here, benefits others who might want to search the 
history if they have the same question.
On Monday, March 29, 2021 at 11:05:02 PM UTC+10 needabettername wrote:

> Thank you, incredible helpful. Off to read more about that now.
>
> Also wanted to take the opportunity to thank you, I was reading your 
> excelelnt article on Windows Mapped drives the other day.
> Still some testing to do on that but I may have a question there. If so 
> shall I put it on this list? 
>
> On Mon, 29 Mar 2021 at 00:12, jbor...@gmail.com <jbor...@gmail.com> wrote:
>
>> The way to reset the connection in Ansible is to run
>>
>> - meta: reset_connection
>>
>> This will delete the existing control persist socket so the subsequent 
>> task will use a new connection.
>>
>> On Saturday, March 27, 2021 at 10:36:26 AM UTC+10 needabettername wrote:
>>
>>> My explanation in the first message wasn't great - apologies. 
>>> Just to be clear...
>>>
>>> In a playbook...
>>>
>>>
>>>    1. A Tasks changes remote shell on windows system 
>>>    (ansible_shell_type) from powershell to cmd
>>>    Subsequent tasks then run but have the opposite results as if the 
>>>    shell hasn't been changed
>>>    2. win_ping using powershell - success - when it should fail
>>>    3. win_ping using cmd shell - failure - when it should work, as 
>>>    we've changed the shell in 1
>>>    
>>>
>>> Just been reading about multiplexing, sounded a likely culprit so I set
>>>
>>> ansible.cfg
>>> [ssh_connection]
>>> -o ControlMaster=no
>>>
>>> But no change, it's still hanging onto it's old shell despite having 
>>> been changed.
>>> Or I'm tired and misreading something
>>> On Saturday, 27 March 2021 at 00:06:31 UTC needabettername wrote:
>>>
>>>> Trying to make a dual boot script and came across these results, the 
>>>> shell is changed during the playbook but subsequent tasks are somehow 
>>>> using 
>>>> the old one. 
>>>>
>>>> How can I force a new connection please?
>>>>
>>>> 1) Change shell to cmd -Success
>>>> win_ping using powershell - success
>>>> win_ping using cmd - failure
>>>>
>>>> The reverse is true when changing it back.
>>>> I've confimed the shells are changing by normal ssh from CLI
>>>>
>>>> --Part of Playbook--
>>>> ---
>>>> - hosts: happy
>>>>   gather_facts: no
>>>>   ignore_unreachable: true
>>>>   ignore_errors: true
>>>>   tasks:
>>>>     - include_tasks: win_shell_cmd.yml
>>>>       vars:
>>>>         become: yes
>>>>         ansible_connection: ssh
>>>>         ansible_shell_type: powershell
>>>>         become_method: runas
>>>>     - name: win_ping using ansible_shell_type powershell
>>>>       win_ping:
>>>>       vars:
>>>>         become: yes
>>>>         ansible_connection: ssh
>>>>         ansible_shell_type: powershell
>>>>         become_method: runas
>>>>     - name: win_ping using ansible_shell_type cmd
>>>>       win_ping:
>>>>       vars:
>>>>         become: yes
>>>>         ansible_connection: ssh
>>>>         ansible_shell_type: cmd
>>>>         become_method: runas
>>>>
>>>> --- win_shell_cmd.yml ---
>>>> - name: set the default shell to cmd
>>>>   win_regedit:
>>>>     path: HKLM:\SOFTWARE\OpenSSH
>>>>     name: DefaultShell
>>>>     state: absent
>>>>
>>> -- 
>> You received this message because you are subscribed to a topic in the 
>> Google Groups "Ansible Project" group.
>> To unsubscribe from this topic, visit 
>> https://groups.google.com/d/topic/ansible-project/dHz4pDvbRI8/unsubscribe
>> .
>> To unsubscribe from this group and all its topics, send an email to 
>> ansible-proje...@googlegroups.com.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/ansible-project/efeb849a-3d5d-48e0-888d-574fe5ed5bean%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/ansible-project/efeb849a-3d5d-48e0-888d-574fe5ed5bean%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>

-- 
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/90c548fb-a7b7-4c1c-b3d0-4f90d8217773n%40googlegroups.com.

Reply via email to