remove previously used remote_user (possibly ControlMaster, ControlPersist problem)

Hi all,

to setup raspberry pis I would like to use the following palybooks (the actual
yaml is at the end).

  1. with remote_user=defaultuser, become and add newuser
  2. with remote_user=newuser, become and delete defaultuser

If I play this with some docker container as target it works but if the target
is a raspberry pi 3 (running archlinux or raspbian) I get:

TASK [remove default user] *********************************************************************************************************************
fatal: [192.168.1.129]: FAILED! => {“changed”: false, “msg”: “userdel: user defaultuser is currently used by process 615\n”, “name”: “defaultuser”, “rc”: 8}

This seems to happen because when the second playbook runs there is still a
defaultuser ssh process running from the first playbook.

Looking into it I found out about -o ControlMaster=auto -o ControlPersist=60s. And if I export ANSIBLE_SSH_ARGS='-o ControlMaster=no'
before ansible-playbook it works also on the raspberry pi.

So my questions are the following.
Why does this affect the rasperry pi but not some docker containers? With the
default ControlPersist=60s it seems that it should also fail on the docker
container.

And is it possible to set ControlMaster=no for a specific playbook?

Thanks
Davide

Playbooks:

`

I found a related post 1 where it is suggested to just kill all processes
before deleting the user 2.