Reconnect after the user is added

Hi.

Is there a way to make Ansible reconnect to continue? I am adding user and I need to execute the rest of the operations under this user - making checkout of the project with his forwarded SSH key.

Hi Anatoly,

Is there a way to make Ansible reconnect to continue? I am adding user and I need to execute the rest of the operations under this user - making checkout of the project with his forwarded SSH key.

Remember that one playbook in ansible can contain several plays. Create the user in the first play and run the second play as the freshly created user.

Cheers,
Paul

Hi Paul,

Thanks for the hint. Does that mean that Ansible reconnect to remote
machine after each play? (Can’t test it right now)

If you increase the verbosity using -v you’ll see that ansible connects for each task. But it’s probably easier to group tasks to be executed with a certain user as a play.

Cheers,
Paul