docs: def create_extension(name,
                       if_not_exists=None,
                       schema=None,
                       ext_version=None,
                       from_version=None,
                       user=None,
                       host=None,
                       port=None,
                       maintenance_db=None,
                       password=None,
                       runas=None):
      '''
      Install a postgresql extension
  
      CLI Example:
  
      .. code-block:: bash
  
          salt '*' postgres.create_extension 'adminpack'
  
      '''
      if if_not_exists is None:
          if_not_exists = True
      mtdata = create_metadata(name,
                               ext_version=ext_version,
                               schema=schema,
                               user=user,
                               host=host,
                               port=port,
                               maintenance_db=maintenance_db,
                               password=password,
                               runas=runas)
      installed = _EXTENSION_NOT_INSTALLED not in mtdata
      installable = is_available_extension(name,
                                           user=user,
                                           host=host,
                                           port=port,
                                           maintenance_db=maintenance_db,
                                           password=password,
                                           runas=runas)
      if installable:
          if not installed:
              args = ['CREATE EXTENSION']
              if if_not_exists:
                  args.append('IF NOT EXISTS')
              args.append('"{0}"'.format(name))
              sargs = []
              if schema:
                  sargs.append('SCHEMA "{0}"'.format(schema))
              if ext_version:
                  sargs.append('VERSION {0}'.format(ext_version))
              if from_version:
                  sargs.append('FROM {0}'.format(from_version))
              if sargs:
                  args.append('WITH')
                  args.extend(sargs)
              args.append(';')
              cmd = ' '.join(args).strip()
          else:
              args = []
              if schema and _EXTENSION_TO_MOVE in mtdata:
                  args.append('ALTER EXTENSION "{0}" SET SCHEMA "{1}";'.format(
                      name, schema))
              if ext_version and _EXTENSION_TO_UPGRADE in mtdata:
                  args.append('ALTER EXTENSION "{0}" UPDATE TO {1};'.format(
                      name, ext_version))
              cmd = ' '.join(args).strip()
          if cmd:
              _psql_prepare_and_run(
                  ['-c', cmd],
                  runas=runas, host=host, user=user, port=port,
                  maintenance_db=maintenance_db, password=password)
      mtdata = create_metadata(name,
                               ext_version=ext_version,
                               schema=schema,
                               user=user,
                               host=host,
                               port=port,
                               maintenance_db=maintenance_db,
                               password=password,
                               runas=runas)
      ret = True
      for i in _EXTENSION_FLAGS:
          if (i in mtdata) and (i != _EXTENSION_INSTALLED):
              ret = False
      if not ret:
          log.info('Failed to create ext: %s', name)
      return ret