docs: def gen_csr(
          minion_id,
          dns_name,
          zone='default',
          country=None,
          state=None,
          loc=None,
          org=None,
          org_unit=None,
          password=None,
      ):
      '''
      Generate a csr using the host's private_key.
      Analogous to:
  
      .. code-block:: bash
  
          VCert gencsr -cn [CN Value] -o "Beta Organization" -ou "Beta Group" \
              -l "Palo Alto" -st "California" -c US
  
      CLI Example:
  
      .. code-block:: bash
  
          salt-run venafi.gen_csr <minion_id> <dns_name>
      '''
      tmpdir = tempfile.mkdtemp()
      os.chmod(tmpdir, 0o700)
  
      bank = 'venafi/domains'
      cache = salt.cache.Cache(__opts__, syspaths.CACHE_DIR)
      data = cache.fetch(bank, dns_name)
      if data is None:
          data = {}
      if 'private_key' not in data:
          data['private_key'] = gen_key(minion_id, dns_name, zone, password)
  
      tmppriv = '{0}/priv'.format(tmpdir)
      tmpcsr = '{0}/csr'.format(tmpdir)
      with salt.utils.files.fopen(tmppriv, 'w') as if_:
          if_.write(salt.utils.stringutils.to_str(data['private_key']))
  
      if country is None:
          country = __opts__.get('venafi', {}).get('country')
  
      if state is None:
          state = __opts__.get('venafi', {}).get('state')
  
      if loc is None:
          loc = __opts__.get('venafi', {}).get('loc')
  
      if org is None:
          org = __opts__.get('venafi', {}).get('org')
  
      if org_unit is None:
          org_unit = __opts__.get('venafi', {}).get('org_unit')
  
      subject = '/C={0}/ST={1}/L={2}/O={3}/OU={4}/CN={5}'.format(
          country,
          state,
          loc,
          org,
          org_unit,
          dns_name,
      )
  
      cmd = "openssl req -new -sha256 -key {0} -out {1} -subj '{2}'".format(
          tmppriv,
          tmpcsr,
          subject
      )
      if password is not None:
          cmd += ' -passin pass:{0}'.format(password)
      output = __salt__['salt.cmd']('cmd.run', cmd)
  
      if 'problems making Certificate Request' in output:
          raise CommandExecutionError(
              'There was a problem generating the CSR. Please ensure that you '
              'have the following variables set either on the command line, or '
              'in the venafi section of your master configuration file: '
              'country, state, loc, org, org_unit'
          )
  
      with salt.utils.files.fopen(tmpcsr, 'r') as of_:
          csr = salt.utils.stringutils.to_unicode(of_.read())
  
      data['minion_id'] = minion_id
      data['csr'] = csr
      cache.store(bank, dns_name, data)
      return csr