title: Set ansible connection differently according to given condition
body: <p>I have a playbook that, for one of the hosts, how I need to connect differs according to whether certain tasks have previously succeeded.</p>
  
  <p>In this specific case there's a tunnel between two of them, and one routes all its traffic over that tunnel, so once configured I need to use the other as a jump box in order to connect - but I can imagine many other circumstances where you might want to change connection method mid-playbook, from as simple as modifying users/passwords.</p>
  
  <p>How can I have a conditional connection method?</p>
  
  <p>I can't simply update with <code>set_fact</code>, since by the time I reach that task ansible will already have tried and possibly failed to 'gather facts' at the start, and won't proceed.</p>