         modified = true if created
         next()
     .on 'both', (err) ->
-      done err
-  done = (err) ->
+      do_end err
+  do_end = (err) ->
     next err, if modified then ctx.OK else ctx.PASS
-  createMachinePrincipal()
-
-
-
-
-
-
-
+  do_wait()
+
+
+
+
+
+
+

module.exports.push name: 'Krb5 Server # Populate', timeout: -1, callback: (ctx, next) ->
  {realm, principals, kadmin_principal, kadmin_password, kadmin_server} = ctx.config.krb5_server
  modified = false
  createMachinePrincipal = ->
    ctx.log "Create principal host/#{ctx.config.host}@#{realm}"
    ctx.krb5_addprinc
      principal: "host/#{ctx.config.host}@#{realm}"

    , (err, created) ->
      return next err if err
      modified = true if created
      do_createConfigPrincipals()
  do_createConfigPrincipals = ->
    each(principals)
    .on 'item', (principal, next) ->
      ctx.log "Create principal {principal}"
