# Restart SSH connection during play

**URL:** <https://forum.ansible.com/t/restart-ssh-connection-during-play/14901>\
**Category:** Ansible Project\
**Tags:** ubuntu\
**Created:** [March 31, 2014, 7:35pm UTC](https://forum.ansible.com/t/restart-ssh-connection-during-play/14901 "2014-03-31T19:35:31Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Michael\_Schultz](https://avatars.discourse-cdn.com/v4/letter/m/35a633/32.png) [@Michael\_Schultz](https://forum.ansible.com/u/Michael_Schultz)\
**Post date:** [March 31, 2014, 7:35pm UTC](https://forum.ansible.com/t/restart-ssh-connection-during-play/14901/1 "2014-03-31T19:35:31Z")

</div>

Hello,

I have a task in a play that appends a group to the user running the playbook. For example, ubuntu user is running the play and does a task like:

- name: Append user group  
sudo: yes  
user:  
name=“ubuntu”  
append=“yes”  
groups=“othergroup”

A later task then assumes that the ubuntu user can write to directories with othergroup write access. This is fine if ansible is not running with ControlMaster enabled since it starts a new SSH connection for every task. It is a problem when ControlMaster is enabled though because it re-uses the same connection which doesn’t cause the remote SSH process to re-load the user groups (meaning the process cannot write to the directory as expected).

In the past (using fabric) I could force the SSH connection to close after this task, but I don’t see a way to do that in ansible (which is probably better since that’s a hack). Is there a good way to reload the user’s group?

Thanks!
