         results:  _.sortBy $distroSelect, 'distro'
       formatSelection: distroFormat
       formatResult: distroFormat
+    # Once a distro has been chosen, populate the template dropdown with that distro's available templates.
+    .on 'change', (e) ->
+      data = e.added
+      distro = data.id
+      populateTemplateSelect(distro)
+      # Ensure there is no template selected yet
+      $template.val([])
+    
+    $template.val([])
+    $distro.val([])
+  
+  populateDistros()
 
   # Set template to Docker provisioner template
   loadProvisionerRole = (provisioner_templates) ->

    .select2 'enable', enable

  # Populate the "Select a distro" dropdown
  $distro.select2
    placeholder: 'Select a distro'
    data:
      results:  _.sortBy $distroSelect, 'distro'
    formatSelection: distroFormat
    formatResult: distroFormat

  # Once a distro has been chosen, populate the template dropdown with that distro's available
  # templates.
  .on 'change', (e) ->
    data = e.added
    distro = data.id
    populateTemplateSelect(distro)
    # Ensure there is no template selected yet
    $templateId.val(-1)

  populateDistros = ->
    $distro.select2
      placeholder: 'Select a distro'

      $(activeTab).show()

      if !server
        $provisionerRole.val([])
        $distro.val([])
        $template.val([])

    if $('#server_wizard_provisioner_role').val() != ''
      $('#jg-tabs li:nth-child(2) a').click()
