<section>
 <h1 class="contains-headerlink leafygreen-ui-41fr9s" weight="medium">
  Externally Sourced Configuration File Values for Self-Managed Deployments
  <a class="headerlink leafygreen-ui-1kepx47" href="#externally-sourced-configuration-file-values-for-self-managed-deployments" title="Permalink to this heading">
   <svg aria-label="Link Icon" class="leafygreen-ui-a30zj9" fill="none" height="12" role="img" viewbox="0 0 16 16" width="12" xmlns="http://www.w3.org/2000/svg">
    <path d="M6.039 9.953a3.596 3.596 0 0 1-.327-.38l1.45-1.445a1.553 1.553 0 0 0 2.496.423l2.885-2.87a1.57 1.57 0 0 0 .01-2.213 1.553 1.553 0 0 0-2.203-.01l-.379.377A.995.995 0 0 1 8.56 3.83a1.005 1.005 0 0 1 .006-1.418l.38-.377a3.542 3.542 0 0 1 5.024.023 3.58 3.58 0 0 1-.022 5.047l-2.884 2.871a3.542 3.542 0 0 1-5.025-.022Z" fill="currentColor">
    </path>
    <path d="M9.961 6.047c.12.12.228.248.327.38l-1.45 1.445a1.553 1.553 0 0 0-2.496-.423l-2.885 2.87a1.57 1.57 0 0 0-.01 2.213 1.553 1.553 0 0 0 2.203.01l.379-.377a.995.995 0 0 1 1.411.006 1.005 1.005 0 0 1-.006 1.418l-.38.377a3.542 3.542 0 0 1-5.024-.023 3.58 3.58 0 0 1 .022-5.047l2.884-2.871a3.542 3.542 0 0 1 5.025.022Z" fill="currentColor">
    </path>
   </svg>
   <div class="css-1btu0w3 evvkmar0" id="externally-sourced-configuration-file-values-for-self-managed-deployments">
   </div>
  </a>
 </h1>
 <div class="leafygreen-ui-a5yxub">
  <p class="css-1cmx2d4 ef7gu8j0">
   On this page
  </p>
  <ul class="css-1qb0mst ef7gu8j1">
   <li class="leafygreen-ui-1e7a0ei">
    <a class="lg-ui-0001 leafygreen-ui-e98ikf" href="#use-the-__rest-expansion-directive" target="_self">
     <span>
      Use the
      <code class="css-1kekw28 e1wawog0">
       __rest
      </code>
      Expansion Directive
     </span>
    </a>
   </li>
   <li class="leafygreen-ui-1jqtqlb">
    <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#use-the-__exec-expansion-directive" target="_self">
     <span>
      Use the
      <code class="css-1kekw28 e1wawog0">
       __exec
      </code>
      Expansion Directive
     </span>
    </a>
   </li>
   <li class="leafygreen-ui-1jqtqlb">
    <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#expansion-directives-reference" target="_self">
     <span>
      Expansion Directives Reference
     </span>
    </a>
   </li>
   <li class="leafygreen-ui-1jqtqlb">
    <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#output-the-configuration-file-with-resolved-expansion-directive-values" target="_self">
     <span>
      Output the Configuration File with Resolved Expansion Directive Values
     </span>
    </a>
   </li>
  </ul>
 </div>
 <p class="leafygreen-ui-1kp3ins">
  MongoDB supports using expansion directives in configuration files
to load externally sourced values. Expansion directives can
load values for specific
  <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/configuration-options/#std-label-configuration-options">
   configuration file options
  </a>
  <em>
   or
  </em>
  load the
entire configuration file. Expansion directives help obscure
confidential information like security certificates and passwords.
 </p>
 <script class="structured_data" type="application/ld+json">
  {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"storage:\n  dbPath: \"/var/lib/mongo\"\nsystemLog:\n  destination: file\n  path: \"/var/log/mongodb/mongod.log\"\nnet:\n  bindIp:\n    __exec: \"python /home/user/getIPAddresses.py\"\n    type: \"string\"\n    trim: \"whitespace\"\n    digest: 85fed8997aac3f558e779625f2e51b4d142dff11184308dc6aca06cff26ee9ad\n    digest_key: 68656c6c30303030307365637265746d796f6c64667269656e64\n  tls:\n    mode: requireTLS\n    certificateKeyFile: \"/etc/tls/mongod.pem\"\n    certificateKeyFilePassword:\n      __rest: \"https://myrestserver.example.net/api/config/myCertKeyFilePassword\"\n      type: \"string\"\n      digest: b08519162ba332985ac18204851949611ef73835ec99067b85723e10113f5c26\n      digest_key: 6d795365637265744b65795374756666","programmingLanguage":"YAML"}
 </script>
 <div class="css-16lmvu9">
  <div class="leafygreen-ui-196mwvg">
   <div class="leafygreen-ui-1b1bvay">
    <pre class="leafygreen-ui-11itue3" tabindex="0"><code class="lg-highlight-hljs-light yaml leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx"><span class="lg-highlight-attr">storage:</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx">  <span class="lg-highlight-attr">dbPath:</span> <span class="lg-highlight-string">"/var/lib/mongo"</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"><span class="lg-highlight-attr">systemLog:</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx">  <span class="lg-highlight-attr">destination:</span> <span class="lg-highlight-string">file</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx">  <span class="lg-highlight-attr">path:</span> <span class="lg-highlight-string">"/var/log/mongodb/mongod.log"</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"><span class="lg-highlight-attr">net:</span></td></tr><tr class="leafygreen-ui-1wr1lm6"><td class="leafygreen-ui-7razhx">  <span class="lg-highlight-attr">bindIp:</span></td></tr><tr class="leafygreen-ui-1wr1lm6"><td class="leafygreen-ui-7razhx">    <span class="lg-highlight-attr">__exec:</span> <span class="lg-highlight-string">"python /home/user/getIPAddresses.py"</span></td></tr><tr class="leafygreen-ui-1wr1lm6"><td class="leafygreen-ui-7razhx">    <span class="lg-highlight-attr">type:</span> <span class="lg-highlight-string">"string"</span></td></tr><tr class="leafygreen-ui-1wr1lm6"><td class="leafygreen-ui-7razhx">    <span class="lg-highlight-attr">trim:</span> <span class="lg-highlight-string">"whitespace"</span></td></tr><tr class="leafygreen-ui-1wr1lm6"><td class="leafygreen-ui-7razhx">    <span class="lg-highlight-attr">digest:</span> <span class="lg-highlight-string">85fed8997aac3f558e779625f2e51b4d142dff11184308dc6aca06cff26ee9ad</span></td></tr><tr class="leafygreen-ui-1wr1lm6"><td class="leafygreen-ui-7razhx">    <span class="lg-highlight-attr">digest_key:</span> <span class="lg-highlight-string">68656c6c30303030307365637265746d796f6c64667269656e64</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx">  <span class="lg-highlight-attr">tls:</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx">    <span class="lg-highlight-attr">mode:</span> <span class="lg-highlight-string">requireTLS</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx">    <span class="lg-highlight-attr">certificateKeyFile:</span> <span class="lg-highlight-string">"/etc/tls/mongod.pem"</span></td></tr><tr class="leafygreen-ui-1wr1lm6"><td class="leafygreen-ui-7razhx">    <span class="lg-highlight-attr">certificateKeyFilePassword:</span></td></tr><tr class="leafygreen-ui-1wr1lm6"><td class="leafygreen-ui-7razhx">      <span class="lg-highlight-attr">__rest:</span> <span class="lg-highlight-string">"https://myrestserver.example.net/api/config/myCertKeyFilePassword"</span></td></tr><tr class="leafygreen-ui-1wr1lm6"><td class="leafygreen-ui-7razhx">      <span class="lg-highlight-attr">type:</span> <span class="lg-highlight-string">"string"</span></td></tr><tr class="leafygreen-ui-1wr1lm6"><td class="leafygreen-ui-7razhx">      <span class="lg-highlight-attr">digest:</span> <span class="lg-highlight-string">b08519162ba332985ac18204851949611ef73835ec99067b85723e10113f5c26</span></td></tr><tr class="leafygreen-ui-1wr1lm6"><td class="leafygreen-ui-7razhx">      <span class="lg-highlight-attr">digest_key:</span> <span class="lg-highlight-string">6d795365637265744b65795374756666</span></td></tr></tbody></table></code></pre>
    <div class="leafygreen-ui-1bqcprk" data-testid="leafygreen-code-panel">
     <button aria-disabled="false" aria-label="Copy" class="leafygreen-ui-1c6zwke" data-testid="code_copy-button" tabindex="0">
      <div class="leafygreen-ui-xhlipt">
       <svg aria-label="Copy Icon" class="leafygreen-ui-1st74h4" height="16" role="img" viewbox="0 0 16 16" width="16">
        <path clip-rule="evenodd" d="M1 5.71428V10.2857C1 11.2325 1.76751 12 2.71429 12H5.75V7.10957C5.75 6.54414 5.97724 6.00244 6.38065 5.60623L8.67403 3.35381C8.77447 3.25516 8.88376 3.16757 9 3.09182V2.71429C9 1.76751 8.23249 1 7.28571 1H5.8V4.42857C5.8 5.13865 5.22437 5.71428 4.51429 5.71428H1ZM9 4.78571L7.25654 6.49804C7.24689 6.50752 7.23749 6.5172 7.22834 6.52708C7.22208 6.53383 7.21594 6.54068 7.20991 6.54762C7.07504 6.70295 7 6.90234 7 7.10957V7.79762H9H10.0095C10.4829 7.79762 10.8667 7.41386 10.8667 6.94047V4H10.1505C9.92587 4 9.7102 4.0882 9.54992 4.24562L9 4.78571ZM4.86667 1H4.15053C3.92587 1 3.7102 1.0882 3.54992 1.24562L1.25654 3.49804C1.09244 3.65921 1 3.87957 1 4.10957V4.79762H4.00952C4.48291 4.79762 4.86667 4.41386 4.86667 3.94047V1ZM7 12V8.71428H9H10.5143C11.2244 8.71428 11.8 8.13865 11.8 7.42857V4H13.2857C14.2325 4 15 4.76751 15 5.71429V13.2857C15 14.2325 14.2325 15 13.2857 15H8.71429C7.76751 15 7 14.2325 7 13.2857V12Z" fill="currentColor" fill-rule="evenodd">
        </path>
       </svg>
      </div>
     </button>
    </div>
   </div>
  </div>
 </div>
 <ul class="leafygreen-ui-rioki0">
  <li class="leafygreen-ui-d7p7b6">
   <p class="leafygreen-ui-1kp3ins">
    If the configuration file includes the
    <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-configexpansion-configexpansion.__rest" target="_self">
     <span>
      <code class="leafygreen-ui-1l06pbn">
       __rest
      </code>
     </span>
    </a>
    expansion, on Linux/macOS, the read access to the configuration file must be limited
to the user running the
    <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod">
     <code class="leafygreen-ui-1l06pbn">
      mongod
     </code>
    </a>
    /
    <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongos/#mongodb-binary-bin.mongos">
     <code class="leafygreen-ui-1l06pbn">
      mongos
     </code>
    </a>
    process only.
   </p>
  </li>
  <li class="leafygreen-ui-d7p7b6">
   <p class="leafygreen-ui-1kp3ins">
    If the configuration file includes the
    <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-configexpansion-configexpansion.__exec" target="_self">
     <span>
      <code class="leafygreen-ui-1l06pbn">
       __exec
      </code>
     </span>
    </a>
    expansion, on Linux/macOS, the write access to the configuration file must be
limited to the user running the
    <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod">
     <code class="leafygreen-ui-1l06pbn">
      mongod
     </code>
    </a>
    /
    <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongos/#mongodb-binary-bin.mongos">
     <code class="leafygreen-ui-1l06pbn">
      mongos
     </code>
    </a>
    process only.
   </p>
  </li>
 </ul>
 <p class="leafygreen-ui-1kp3ins">
  To use expansion directives, you must specify the
  <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#std-option-mongod.--configExpand">
   <code class="leafygreen-ui-1l06pbn">
    --configExpand
   </code>
  </a>
  command-line option
with the complete list of expansion directives used:
 </p>
 <script class="structured_data" type="application/ld+json">
  {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"mongod --config \"/path/to/config/mongod.conf\" --configExpand \"rest,exec\"","programmingLanguage":"Bash"}
 </script>
 <div class="css-16lmvu9">
  <div class="leafygreen-ui-196mwvg">
   <div class="leafygreen-ui-1b1bvay">
    <pre class="leafygreen-ui-1q4bxgx" tabindex="0"><code class="lg-highlight-hljs-light bash leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">mongod --config <span class="lg-highlight-string">"/path/to/config/mongod.conf"</span> --configExpand <span class="lg-highlight-string">"rest,exec"</span></td></tr></tbody></table></code></pre>
    <div class="leafygreen-ui-1bqcprk" data-testid="leafygreen-code-panel">
     <button aria-disabled="false" aria-label="Copy" class="leafygreen-ui-1c6zwke" data-testid="code_copy-button" tabindex="0">
      <div class="leafygreen-ui-xhlipt">
       <svg aria-label="Copy Icon" class="leafygreen-ui-1st74h4" height="16" role="img" viewbox="0 0 16 16" width="16">
        <path clip-rule="evenodd" d="M1 5.71428V10.2857C1 11.2325 1.76751 12 2.71429 12H5.75V7.10957C5.75 6.54414 5.97724 6.00244 6.38065 5.60623L8.67403 3.35381C8.77447 3.25516 8.88376 3.16757 9 3.09182V2.71429C9 1.76751 8.23249 1 7.28571 1H5.8V4.42857C5.8 5.13865 5.22437 5.71428 4.51429 5.71428H1ZM9 4.78571L7.25654 6.49804C7.24689 6.50752 7.23749 6.5172 7.22834 6.52708C7.22208 6.53383 7.21594 6.54068 7.20991 6.54762C7.07504 6.70295 7 6.90234 7 7.10957V7.79762H9H10.0095C10.4829 7.79762 10.8667 7.41386 10.8667 6.94047V4H10.1505C9.92587 4 9.7102 4.0882 9.54992 4.24562L9 4.78571ZM4.86667 1H4.15053C3.92587 1 3.7102 1.0882 3.54992 1.24562L1.25654 3.49804C1.09244 3.65921 1 3.87957 1 4.10957V4.79762H4.00952C4.48291 4.79762 4.86667 4.41386 4.86667 3.94047V1ZM7 12V8.71428H9H10.5143C11.2244 8.71428 11.8 8.13865 11.8 7.42857V4H13.2857C14.2325 4 15 4.76751 15 5.71429V13.2857C15 14.2325 14.2325 15 13.2857 15H8.71429C7.76751 15 7 14.2325 7 13.2857V12Z" fill="currentColor" fill-rule="evenodd">
        </path>
       </svg>
      </div>
     </button>
    </div>
   </div>
  </div>
 </div>
 <p class="leafygreen-ui-1kp3ins">
  If you omit the
  <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#std-option-mongod.--configExpand">
   <code class="leafygreen-ui-1l06pbn">
    --configExpand
   </code>
  </a>
  option
  <em>
   or
  </em>
  if
you do not specify the complete list of expansion directives used in
the configuration file, the
  <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod">
   <code class="leafygreen-ui-1l06pbn">
    mongod
   </code>
  </a>
  /
  <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongos/#mongodb-binary-bin.mongos">
   <code class="leafygreen-ui-1l06pbn">
    mongos
   </code>
  </a>
  returns
an error and terminates. You can only specify the
  <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#std-option-mongod.--configExpand">
   <code class="leafygreen-ui-1l06pbn">
    --configExpand
   </code>
  </a>
  option on the
command line.
 </p>
 <span class="leafygreen-ui-1qnjd6d" id="std-label-expansion-directive-rest">
 </span>
 <section>
  <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium">
   Use the
   <code class="leafygreen-ui-1l06pbn">
    __rest
   </code>
   Expansion Directive
   <a class="headerlink leafygreen-ui-1kepx47" href="#use-the-__rest-expansion-directive" title="Permalink to this heading">
    <svg aria-label="Link Icon" class="leafygreen-ui-a30zj9" fill="none" height="12" role="img" viewbox="0 0 16 16" width="12" xmlns="http://www.w3.org/2000/svg">
     <path d="M6.039 9.953a3.596 3.596 0 0 1-.327-.38l1.45-1.445a1.553 1.553 0 0 0 2.496.423l2.885-2.87a1.57 1.57 0 0 0 .01-2.213 1.553 1.553 0 0 0-2.203-.01l-.379.377A.995.995 0 0 1 8.56 3.83a1.005 1.005 0 0 1 .006-1.418l.38-.377a3.542 3.542 0 0 1 5.024.023 3.58 3.58 0 0 1-.022 5.047l-2.884 2.871a3.542 3.542 0 0 1-5.025-.022Z" fill="currentColor">
     </path>
     <path d="M9.961 6.047c.12.12.228.248.327.38l-1.45 1.445a1.553 1.553 0 0 0-2.496-.423l-2.885 2.87a1.57 1.57 0 0 0-.01 2.213 1.553 1.553 0 0 0 2.203.01l.379-.377a.995.995 0 0 1 1.411.006 1.005 1.005 0 0 1-.006 1.418l-.38.377a3.542 3.542 0 0 1-5.024-.023 3.58 3.58 0 0 1 .022-5.047l2.884-2.871a3.542 3.542 0 0 1 5.025.022Z" fill="currentColor">
     </path>
    </svg>
    <div class="css-1btu0w3 evvkmar0" id="use-the-__rest-expansion-directive">
    </div>
   </a>
  </h2>
  <p class="leafygreen-ui-1kp3ins">
   The
   <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-configexpansion-configexpansion.__rest" target="_self">
    <span>
     <code class="leafygreen-ui-1l06pbn">
      __rest
     </code>
    </span>
   </a>
   expansion directive loads configuration
file values from a
   <code class="leafygreen-ui-1l06pbn">
    REST
   </code>
   endpoint.
   <code class="leafygreen-ui-1l06pbn">
    __rest
   </code>
   supports loading
specific values  in the configuration file
   <em>
    or
   </em>
   loading the entire
configuration file.
  </p>
  <div aria-hidden="true">
  </div>
  <div class="leafygreen-ui-1b75luy" data-lgid="lg-tabs">
   <div class="leafygreen-ui-jp7pox" id="tabs-5">
    <div aria-label="Tabs to describe usage of full-file-rest/single-val-rest" aria-orientation="horizontal" class="leafygreen-ui-m8p1vb lg-ui-tab-list-0000" data-lgid="lg-tabs-tab_list" role="tablist">
     <button aria-controls="_2p9gdxyvi" aria-selected="true" class="leafygreen-ui-1l773z1" data-text="" id="_6q8y86xrr" name="" role="tab" tabindex="0">
      <div class="leafygreen-ui-1nxuzmg">
       Specific Value
      </div>
     </button>
     <button aria-controls="_jw7l1tp7i" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_c8oy494lf" name="" role="tab" tabindex="-1">
      <div class="leafygreen-ui-1nxuzmg">
       Full Configuration File
      </div>
     </button>
    </div>
    <div class="leafygreen-ui-ov1ktg">
     <div class="leafygreen-ui-1sg2lsz">
     </div>
    </div>
   </div>
   <div class="lg-ui-tab-panels-0000" data-lgid="lg-tabs-tab_panels">
    <div>
     <div aria-labelledby="_4kpkbet32" class="" id="_x0p1v4m2p" role="tabpanel">
      <div class="leafygreen-ui-1kdmo88">
       <p class="leafygreen-ui-1kp3ins">
        The following configuration file uses the
        <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-configexpansion-configexpansion.__rest" target="_self">
         <span>
          <code class="leafygreen-ui-1l06pbn">
           __rest
          </code>
         </span>
        </a>
        expansion directive to load the
setting
        <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/configuration-options/#mongodb-setting-net.tls.certificateKeyFilePassword">
         <code class="leafygreen-ui-1l06pbn">
          net.tls.certificateKeyFilePassword
         </code>
        </a>
        value from an
external
        <code class="leafygreen-ui-1l06pbn">
         REST
        </code>
        endpoint:
       </p>
       <script class="structured_data" type="application/ld+json">
        {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"storage:\n  dbPath: \"/var/lib/mongo\"\nsystemLog:\n  destination: file\n  path: \"/var/log/mongodb/mongod.log\"\nnet:\n  bindIp: 192.51.100.24,127.0.0.1\n  tls:\n    mode: requireTLS\n    certificateKeyFile: \"/etc/tls/mongod.pem\"\n    certificateKeyFilePassword:\n      __rest: \"https://myrestserver.example.net/api/config/myCertKeyFilePassword\"\n      type: \"string\"","programmingLanguage":"YAML"}
       </script>
       <div class="css-16lmvu9">
        <div class="leafygreen-ui-196mwvg">
         <div class="leafygreen-ui-yzcs8i">
          <pre class="leafygreen-ui-11itue3" tabindex="-1"><code class="lg-highlight-hljs-light yaml leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx"><span class="lg-highlight-attr">storage:</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx">  <span class="lg-highlight-attr">dbPath:</span> <span class="lg-highlight-string">"/var/lib/mongo"</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"><span class="lg-highlight-attr">systemLog:</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx">  <span class="lg-highlight-attr">destination:</span> <span class="lg-highlight-string">file</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx">  <span class="lg-highlight-attr">path:</span> <span class="lg-highlight-string">"/var/log/mongodb/mongod.log"</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"><span class="lg-highlight-attr">net:</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx">  <span class="lg-highlight-attr">bindIp:</span> <span class="lg-highlight-number">192.51</span><span class="lg-highlight-number">.100</span><span class="lg-highlight-number">.24</span><span class="lg-highlight-string">,127.0.0.1</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx">  <span class="lg-highlight-attr">tls:</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx">    <span class="lg-highlight-attr">mode:</span> <span class="lg-highlight-string">requireTLS</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx">    <span class="lg-highlight-attr">certificateKeyFile:</span> <span class="lg-highlight-string">"/etc/tls/mongod.pem"</span></td></tr><tr class="leafygreen-ui-1wr1lm6"><td class="leafygreen-ui-7razhx">    <span class="lg-highlight-attr">certificateKeyFilePassword:</span></td></tr><tr class="leafygreen-ui-1wr1lm6"><td class="leafygreen-ui-7razhx">      <span class="lg-highlight-attr">__rest:</span> <span class="lg-highlight-string">"https://myrestserver.example.net/api/config/myCertKeyFilePassword"</span></td></tr><tr class="leafygreen-ui-1wr1lm6"><td class="leafygreen-ui-7razhx">      <span class="lg-highlight-attr">type:</span> <span class="lg-highlight-string">"string"</span></td></tr></tbody></table></code></pre>
          <div class="leafygreen-ui-1bqcprk" data-testid="leafygreen-code-panel">
           <button aria-disabled="false" aria-label="Copy" class="leafygreen-ui-1c6zwke" data-testid="code_copy-button" tabindex="0">
            <div class="leafygreen-ui-xhlipt">
             <svg aria-label="Copy Icon" class="leafygreen-ui-1st74h4" height="16" role="img" viewbox="0 0 16 16" width="16">
              <path clip-rule="evenodd" d="M1 5.71428V10.2857C1 11.2325 1.76751 12 2.71429 12H5.75V7.10957C5.75 6.54414 5.97724 6.00244 6.38065 5.60623L8.67403 3.35381C8.77447 3.25516 8.88376 3.16757 9 3.09182V2.71429C9 1.76751 8.23249 1 7.28571 1H5.8V4.42857C5.8 5.13865 5.22437 5.71428 4.51429 5.71428H1ZM9 4.78571L7.25654 6.49804C7.24689 6.50752 7.23749 6.5172 7.22834 6.52708C7.22208 6.53383 7.21594 6.54068 7.20991 6.54762C7.07504 6.70295 7 6.90234 7 7.10957V7.79762H9H10.0095C10.4829 7.79762 10.8667 7.41386 10.8667 6.94047V4H10.1505C9.92587 4 9.7102 4.0882 9.54992 4.24562L9 4.78571ZM4.86667 1H4.15053C3.92587 1 3.7102 1.0882 3.54992 1.24562L1.25654 3.49804C1.09244 3.65921 1 3.87957 1 4.10957V4.79762H4.00952C4.48291 4.79762 4.86667 4.41386 4.86667 3.94047V1ZM7 12V8.71428H9H10.5143C11.2244 8.71428 11.8 8.13865 11.8 7.42857V4H13.2857C14.2325 4 15 4.76751 15 5.71429V13.2857C15 14.2325 14.2325 15 13.2857 15H8.71429C7.76751 15 7 14.2325 7 13.2857V12Z" fill="currentColor" fill-rule="evenodd">
              </path>
             </svg>
            </div>
           </button>
          </div>
         </div>
        </div>
       </div>
       <dl>
        <dt>
         File Permission
        </dt>
        <dd class="css-1ufxuu7">
         If the configuration file includes the
         <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-configexpansion-configexpansion.__rest" target="_self">
          <span>
           <code class="leafygreen-ui-1l06pbn">
            __rest
           </code>
          </span>
         </a>
         expansion, on Linux/macOS, the read access to the configuration file must be limited
to the user running the
         <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod">
          <code class="leafygreen-ui-1l06pbn">
           mongod
          </code>
         </a>
         /
         <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongos/#mongodb-binary-bin.mongos">
          <code class="leafygreen-ui-1l06pbn">
           mongos
          </code>
         </a>
         process only.
        </dd>
        <dt>
         Expansion Parsing
        </dt>
        <dd class="css-1ufxuu7">
         <p class="leafygreen-ui-1kp3ins">
          To parse the
          <code class="leafygreen-ui-1l06pbn">
           __rest
          </code>
          blocks, start the
          <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod">
           <code class="leafygreen-ui-1l06pbn">
            mongod
           </code>
          </a>
          /
          <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongos/#mongodb-binary-bin.mongos">
           <code class="leafygreen-ui-1l06pbn">
            mongos
           </code>
          </a>
          with
the
          <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#std-option-mongod.--configExpand">
           <code class="leafygreen-ui-1l06pbn">
            --configExpand "rest"
           </code>
          </a>
          option.
         </p>
         <p class="leafygreen-ui-1kp3ins">
          The
          <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod">
           <code class="leafygreen-ui-1l06pbn">
            mongod
           </code>
          </a>
          /
          <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongos/#mongodb-binary-bin.mongos">
           <code class="leafygreen-ui-1l06pbn">
            mongos
           </code>
          </a>
          issues a
          <code class="leafygreen-ui-1l06pbn">
           GET
          </code>
          request against specified
URL. If successful, the
          <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod">
           <code class="leafygreen-ui-1l06pbn">
            mongod
           </code>
          </a>
          /
          <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongos/#mongodb-binary-bin.mongos">
           <code class="leafygreen-ui-1l06pbn">
            mongos
           </code>
          </a>
          replaces the value of
          <code class="leafygreen-ui-1l06pbn">
           certificateKeyFilePassword
          </code>
          with the returned value. If
the URL fails to resolve or if the
          <code class="leafygreen-ui-1l06pbn">
           REST
          </code>
          endpoint
returns an invalid value, the
          <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod">
           <code class="leafygreen-ui-1l06pbn">
            mongod
           </code>
          </a>
          /
          <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongos/#mongodb-binary-bin.mongos">
           <code class="leafygreen-ui-1l06pbn">
            mongos
           </code>
          </a>
          throws an error and
terminates.
         </p>
        </dd>
       </dl>
      </div>
     </div>
    </div>
    <div>
     <div aria-labelledby="_5kf6ca95a" class="leafygreen-ui-38lglc" id="_jkugjbb5w" role="tabpanel">
      <div class="leafygreen-ui-1kdmo88">
       <p class="leafygreen-ui-1kp3ins">
        The following configuration file uses the
        <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-configexpansion-configexpansion.__rest" target="_self">
         <span>
          <code class="leafygreen-ui-1l06pbn">
           __rest
          </code>
         </span>
        </a>
        expansion directive to load the
configuration file from an external
        <code class="leafygreen-ui-1l06pbn">
         REST
        </code>
        endpoint. The
expansion directive and its options
        <strong>
         must
        </strong>
        be the only values
specified in the configuration file.
       </p>
       <script class="structured_data" type="application/ld+json">
        {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"__rest: \"https://myrestserver.example.net/api/config/fullConfig\"\ntype: \"yaml\"","programmingLanguage":"YAML"}
       </script>
       <div class="css-16lmvu9">
        <div class="leafygreen-ui-196mwvg">
         <div class="leafygreen-ui-yzcs8i">
          <pre class="leafygreen-ui-11itue3" tabindex="-1"><code class="lg-highlight-hljs-light yaml leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx"><span class="lg-highlight-attr">__rest:</span> <span class="lg-highlight-string">"https://myrestserver.example.net/api/config/fullConfig"</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"><span class="lg-highlight-attr">type:</span> <span class="lg-highlight-string">"yaml"</span></td></tr></tbody></table></code></pre>
          <div class="leafygreen-ui-1bqcprk" data-testid="leafygreen-code-panel">
           <button aria-disabled="false" aria-label="Copy" class="leafygreen-ui-1c6zwke" data-testid="code_copy-button" tabindex="0">
            <div class="leafygreen-ui-xhlipt">
             <svg aria-label="Copy Icon" class="leafygreen-ui-1st74h4" height="16" role="img" viewbox="0 0 16 16" width="16">
              <path clip-rule="evenodd" d="M1 5.71428V10.2857C1 11.2325 1.76751 12 2.71429 12H5.75V7.10957C5.75 6.54414 5.97724 6.00244 6.38065 5.60623L8.67403 3.35381C8.77447 3.25516 8.88376 3.16757 9 3.09182V2.71429C9 1.76751 8.23249 1 7.28571 1H5.8V4.42857C5.8 5.13865 5.22437 5.71428 4.51429 5.71428H1ZM9 4.78571L7.25654 6.49804C7.24689 6.50752 7.23749 6.5172 7.22834 6.52708C7.22208 6.53383 7.21594 6.54068 7.20991 6.54762C7.07504 6.70295 7 6.90234 7 7.10957V7.79762H9H10.0095C10.4829 7.79762 10.8667 7.41386 10.8667 6.94047V4H10.1505C9.92587 4 9.7102 4.0882 9.54992 4.24562L9 4.78571ZM4.86667 1H4.15053C3.92587 1 3.7102 1.0882 3.54992 1.24562L1.25654 3.49804C1.09244 3.65921 1 3.87957 1 4.10957V4.79762H4.00952C4.48291 4.79762 4.86667 4.41386 4.86667 3.94047V1ZM7 12V8.71428H9H10.5143C11.2244 8.71428 11.8 8.13865 11.8 7.42857V4H13.2857C14.2325 4 15 4.76751 15 5.71429V13.2857C15 14.2325 14.2325 15 13.2857 15H8.71429C7.76751 15 7 14.2325 7 13.2857V12Z" fill="currentColor" fill-rule="evenodd">
              </path>
             </svg>
            </div>
           </button>
          </div>
         </div>
        </div>
       </div>
       <dl>
        <dt>
         File Permission
        </dt>
        <dd class="css-1ufxuu7">
         If the configuration file includes the
         <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-configexpansion-configexpansion.__rest" target="_self">
          <span>
           <code class="leafygreen-ui-1l06pbn">
            __rest
           </code>
          </span>
         </a>
         expansion, on Linux/macOS, the read access to the configuration file must be limited
to the user running the
         <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod">
          <code class="leafygreen-ui-1l06pbn">
           mongod
          </code>
         </a>
         /
         <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongos/#mongodb-binary-bin.mongos">
          <code class="leafygreen-ui-1l06pbn">
           mongos
          </code>
         </a>
         process only.
        </dd>
        <dt>
         Expansion Parsing
        </dt>
        <dd class="css-1ufxuu7">
         <p class="leafygreen-ui-1kp3ins">
          To parse the
          <code class="leafygreen-ui-1l06pbn">
           __rest
          </code>
          blocks, start the
          <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod">
           <code class="leafygreen-ui-1l06pbn">
            mongod
           </code>
          </a>
          /
          <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongos/#mongodb-binary-bin.mongos">
           <code class="leafygreen-ui-1l06pbn">
            mongos
           </code>
          </a>
          with
the
          <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#std-option-mongod.--configExpand">
           <code class="leafygreen-ui-1l06pbn">
            --configExpand "rest"
           </code>
          </a>
          option.
         </p>
         <p class="leafygreen-ui-1kp3ins">
          The
          <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod">
           <code class="leafygreen-ui-1l06pbn">
            mongod
           </code>
          </a>
          /
          <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongos/#mongodb-binary-bin.mongos">
           <code class="leafygreen-ui-1l06pbn">
            mongos
           </code>
          </a>
          issues a
          <code class="leafygreen-ui-1l06pbn">
           GET
          </code>
          request against the
specified URL. If successful, the
          <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod">
           <code class="leafygreen-ui-1l06pbn">
            mongod
           </code>
          </a>
          /
          <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongos/#mongodb-binary-bin.mongos">
           <code class="leafygreen-ui-1l06pbn">
            mongos
           </code>
          </a>
          parses the
returned configuration
          <code class="leafygreen-ui-1l06pbn">
           yaml
          </code>
          file and uses it during
startup. If the URL fails to resolve or return a properly
formatted
          <code class="leafygreen-ui-1l06pbn">
           yaml
          </code>
          file, the
          <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod">
           <code class="leafygreen-ui-1l06pbn">
            mongod
           </code>
          </a>
          /
          <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongos/#mongodb-binary-bin.mongos">
           <code class="leafygreen-ui-1l06pbn">
            mongos
           </code>
          </a>
          throws an error and
terminates.
         </p>
        </dd>
       </dl>
      </div>
     </div>
    </div>
   </div>
  </div>
  <div class="leafygreen-ui-85da11" role="note">
   <h2 class="leafygreen-ui-1ac4g5h">
    Important
   </h2>
   <div class="leafygreen-ui-9mycqc">
    <p class="leafygreen-ui-1kp3ins">
     The value returned by the specified
     <code class="leafygreen-ui-1l06pbn">
      REST
     </code>
     endpoint
     <strong>
      cannot
     </strong>
     include any additional expansion directives. The
     <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod">
      <code class="leafygreen-ui-1l06pbn">
       mongod
      </code>
     </a>
     /
     <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongos/#mongodb-binary-bin.mongos">
      <code class="leafygreen-ui-1l06pbn">
       mongos
      </code>
     </a>
     does
     <strong>
      not
     </strong>
     perform additional
processing on the returned data and will terminate with an
error code if the returned data includes additional
expansion directives.
    </p>
   </div>
  </div>
  <span class="leafygreen-ui-1qnjd6d" id="std-label-expansion-directive-exec">
  </span>
 </section>
 <section>
  <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium">
   Use the
   <code class="leafygreen-ui-1l06pbn">
    __exec
   </code>
   Expansion Directive
   <a class="headerlink leafygreen-ui-1kepx47" href="#use-the-__exec-expansion-directive" title="Permalink to this heading">
    <svg aria-label="Link Icon" class="leafygreen-ui-a30zj9" fill="none" height="12" role="img" viewbox="0 0 16 16" width="12" xmlns="http://www.w3.org/2000/svg">
     <path d="M6.039 9.953a3.596 3.596 0 0 1-.327-.38l1.45-1.445a1.553 1.553 0 0 0 2.496.423l2.885-2.87a1.57 1.57 0 0 0 .01-2.213 1.553 1.553 0 0 0-2.203-.01l-.379.377A.995.995 0 0 1 8.56 3.83a1.005 1.005 0 0 1 .006-1.418l.38-.377a3.542 3.542 0 0 1 5.024.023 3.58 3.58 0 0 1-.022 5.047l-2.884 2.871a3.542 3.542 0 0 1-5.025-.022Z" fill="currentColor">
     </path>
     <path d="M9.961 6.047c.12.12.228.248.327.38l-1.45 1.445a1.553 1.553 0 0 0-2.496-.423l-2.885 2.87a1.57 1.57 0 0 0-.01 2.213 1.553 1.553 0 0 0 2.203.01l.379-.377a.995.995 0 0 1 1.411.006 1.005 1.005 0 0 1-.006 1.418l-.38.377a3.542 3.542 0 0 1-5.024-.023 3.58 3.58 0 0 1 .022-5.047l2.884-2.871a3.542 3.542 0 0 1 5.025.022Z" fill="currentColor">
     </path>
    </svg>
    <div class="css-1btu0w3 evvkmar0" id="use-the-__exec-expansion-directive">
    </div>
   </a>
  </h2>
  <p class="leafygreen-ui-1kp3ins">
   The
   <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-configexpansion-configexpansion.__exec" target="_self">
    <span>
     <code class="leafygreen-ui-1l06pbn">
      __exec
     </code>
    </span>
   </a>
   expansion directive loads configuration
file values from a shell or terminal command.
   <code class="leafygreen-ui-1l06pbn">
    __exec
   </code>
   supports
loading specific values in the configuration file
   <em>
    or
   </em>
   loading the
entire configuration file.
  </p>
  <div aria-hidden="true">
  </div>
  <div class="leafygreen-ui-1b75luy" data-lgid="lg-tabs">
   <div class="leafygreen-ui-jp7pox" id="tabs-7">
    <div aria-label="Tabs to describe usage of full-file-yaml/single-val-yaml" aria-orientation="horizontal" class="leafygreen-ui-m8p1vb lg-ui-tab-list-0000" data-lgid="lg-tabs-tab_list" role="tablist">
     <button aria-controls="_bk5d2wdpj" aria-selected="true" class="leafygreen-ui-1l773z1" data-text="" id="_42ie21jga" name="" role="tab" tabindex="0">
      <div class="leafygreen-ui-1nxuzmg">
       Specific Value
      </div>
     </button>
     <button aria-controls="_yyfg6joq3" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_q3tl781op" name="" role="tab" tabindex="-1">
      <div class="leafygreen-ui-1nxuzmg">
       Full Configuration File
      </div>
     </button>
    </div>
    <div class="leafygreen-ui-ov1ktg">
     <div class="leafygreen-ui-1sg2lsz">
     </div>
    </div>
   </div>
   <div class="lg-ui-tab-panels-0000" data-lgid="lg-tabs-tab_panels">
    <div>
     <div aria-labelledby="_ksti6j8jw" class="" id="_w59tvbvv0" role="tabpanel">
      <div class="leafygreen-ui-1kdmo88">
       <p class="leafygreen-ui-1kp3ins">
        The following example configuration file uses the
        <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-configexpansion-configexpansion.__exec" target="_self">
         <span>
          <code class="leafygreen-ui-1l06pbn">
           __exec
          </code>
         </span>
        </a>
        expansion directive to to load the
setting
        <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/configuration-options/#mongodb-setting-net.tls.certificateKeyFilePassword">
         <code class="leafygreen-ui-1l06pbn">
          net.tls.certificateKeyFilePassword
         </code>
        </a>
        value from the output
of a shell or terminal command:
       </p>
       <script class="structured_data" type="application/ld+json">
        {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"storage:\n  dbPath: \"/var/lib/mongo\"\nsystemLog:\n  destination: file\n  path: \"/var/log/mongodb/mongod.log\"\nnet:\n  bindIp: 192.51.100.24,127.0.0.1\n  tls:\n    mode: requireTLS\n    certificateKeyFile: \"/etc/tls/mongod.pem\"\n    certificateKeyFilePassword:\n      __exec: \"python /home/myUserName/getPEMPassword.py\"\n      type: \"string\"","programmingLanguage":"YAML"}
       </script>
       <div class="css-16lmvu9">
        <div class="leafygreen-ui-196mwvg">
         <div class="leafygreen-ui-yzcs8i">
          <pre class="leafygreen-ui-11itue3" tabindex="-1"><code class="lg-highlight-hljs-light yaml leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx"><span class="lg-highlight-attr">storage:</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx">  <span class="lg-highlight-attr">dbPath:</span> <span class="lg-highlight-string">"/var/lib/mongo"</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"><span class="lg-highlight-attr">systemLog:</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx">  <span class="lg-highlight-attr">destination:</span> <span class="lg-highlight-string">file</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx">  <span class="lg-highlight-attr">path:</span> <span class="lg-highlight-string">"/var/log/mongodb/mongod.log"</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"><span class="lg-highlight-attr">net:</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx">  <span class="lg-highlight-attr">bindIp:</span> <span class="lg-highlight-number">192.51</span><span class="lg-highlight-number">.100</span><span class="lg-highlight-number">.24</span><span class="lg-highlight-string">,127.0.0.1</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx">  <span class="lg-highlight-attr">tls:</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx">    <span class="lg-highlight-attr">mode:</span> <span class="lg-highlight-string">requireTLS</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx">    <span class="lg-highlight-attr">certificateKeyFile:</span> <span class="lg-highlight-string">"/etc/tls/mongod.pem"</span></td></tr><tr class="leafygreen-ui-1wr1lm6"><td class="leafygreen-ui-7razhx">    <span class="lg-highlight-attr">certificateKeyFilePassword:</span></td></tr><tr class="leafygreen-ui-1wr1lm6"><td class="leafygreen-ui-7razhx">      <span class="lg-highlight-attr">__exec:</span> <span class="lg-highlight-string">"python /home/myUserName/getPEMPassword.py"</span></td></tr><tr class="leafygreen-ui-1wr1lm6"><td class="leafygreen-ui-7razhx">      <span class="lg-highlight-attr">type:</span> <span class="lg-highlight-string">"string"</span></td></tr></tbody></table></code></pre>
          <div class="leafygreen-ui-1bqcprk" data-testid="leafygreen-code-panel">
           <button aria-disabled="false" aria-label="Copy" class="leafygreen-ui-1c6zwke" data-testid="code_copy-button" tabindex="0">
            <div class="leafygreen-ui-xhlipt">
             <svg aria-label="Copy Icon" class="leafygreen-ui-1st74h4" height="16" role="img" viewbox="0 0 16 16" width="16">
              <path clip-rule="evenodd" d="M1 5.71428V10.2857C1 11.2325 1.76751 12 2.71429 12H5.75V7.10957C5.75 6.54414 5.97724 6.00244 6.38065 5.60623L8.67403 3.35381C8.77447 3.25516 8.88376 3.16757 9 3.09182V2.71429C9 1.76751 8.23249 1 7.28571 1H5.8V4.42857C5.8 5.13865 5.22437 5.71428 4.51429 5.71428H1ZM9 4.78571L7.25654 6.49804C7.24689 6.50752 7.23749 6.5172 7.22834 6.52708C7.22208 6.53383 7.21594 6.54068 7.20991 6.54762C7.07504 6.70295 7 6.90234 7 7.10957V7.79762H9H10.0095C10.4829 7.79762 10.8667 7.41386 10.8667 6.94047V4H10.1505C9.92587 4 9.7102 4.0882 9.54992 4.24562L9 4.78571ZM4.86667 1H4.15053C3.92587 1 3.7102 1.0882 3.54992 1.24562L1.25654 3.49804C1.09244 3.65921 1 3.87957 1 4.10957V4.79762H4.00952C4.48291 4.79762 4.86667 4.41386 4.86667 3.94047V1ZM7 12V8.71428H9H10.5143C11.2244 8.71428 11.8 8.13865 11.8 7.42857V4H13.2857C14.2325 4 15 4.76751 15 5.71429V13.2857C15 14.2325 14.2325 15 13.2857 15H8.71429C7.76751 15 7 14.2325 7 13.2857V12Z" fill="currentColor" fill-rule="evenodd">
              </path>
             </svg>
            </div>
           </button>
          </div>
         </div>
        </div>
       </div>
       <dl>
        <dt>
         File Permission
        </dt>
        <dd class="css-1ufxuu7">
         If the configuration file includes the
         <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-configexpansion-configexpansion.__exec" target="_self">
          <span>
           <code class="leafygreen-ui-1l06pbn">
            __exec
           </code>
          </span>
         </a>
         expansion, on Linux/macOS, the write access to the configuration file must be
limited to the user running the
         <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod">
          <code class="leafygreen-ui-1l06pbn">
           mongod
          </code>
         </a>
         /
         <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongos/#mongodb-binary-bin.mongos">
          <code class="leafygreen-ui-1l06pbn">
           mongos
          </code>
         </a>
         process only.
        </dd>
        <dt>
         Expansion Parsing
        </dt>
        <dd class="css-1ufxuu7">
         <p class="leafygreen-ui-1kp3ins">
          To parse the
          <code class="leafygreen-ui-1l06pbn">
           __exec
          </code>
          blocks, start the
          <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod">
           <code class="leafygreen-ui-1l06pbn">
            mongod
           </code>
          </a>
          /
          <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongos/#mongodb-binary-bin.mongos">
           <code class="leafygreen-ui-1l06pbn">
            mongos
           </code>
          </a>
          with
the
          <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#std-option-mongod.--configExpand">
           <code class="leafygreen-ui-1l06pbn">
            --configExpand "exec"
           </code>
          </a>
          option.
         </p>
         <p class="leafygreen-ui-1kp3ins">
          The
          <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod">
           <code class="leafygreen-ui-1l06pbn">
            mongod
           </code>
          </a>
          /
          <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongos/#mongodb-binary-bin.mongos">
           <code class="leafygreen-ui-1l06pbn">
            mongos
           </code>
          </a>
          attempts to execute the specified operation.
If the command executes successfully, the
          <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod">
           <code class="leafygreen-ui-1l06pbn">
            mongod
           </code>
          </a>
          /
          <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongos/#mongodb-binary-bin.mongos">
           <code class="leafygreen-ui-1l06pbn">
            mongos
           </code>
          </a>
          replaces the value of
          <code class="leafygreen-ui-1l06pbn">
           certificateKeyFilePassword
          </code>
          with
the returned value. If the command fails or returns an
invalid value for the configuration file setting, the
          <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod">
           <code class="leafygreen-ui-1l06pbn">
            mongod
           </code>
          </a>
          /
          <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongos/#mongodb-binary-bin.mongos">
           <code class="leafygreen-ui-1l06pbn">
            mongos
           </code>
          </a>
          throws an error and terminates.
         </p>
        </dd>
       </dl>
      </div>
     </div>
    </div>
    <div>
     <div aria-labelledby="_61aogwqrv" class="leafygreen-ui-38lglc" id="_9giydpxoc" role="tabpanel">
      <div class="leafygreen-ui-1kdmo88">
       <p class="leafygreen-ui-1kp3ins">
        The following example configuration file uses the
        <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-configexpansion-configexpansion.__exec" target="_self">
         <span>
          <code class="leafygreen-ui-1l06pbn">
           __exec
          </code>
         </span>
        </a>
        expansion directive to load the
configuration file from the output of a shell or terminal
command. The
        <code class="leafygreen-ui-1l06pbn">
         __exec
        </code>
        expansion directive
and its options
        <strong>
         must
        </strong>
        be the only values specified in the
configuration file.
       </p>
       <script class="structured_data" type="application/ld+json">
        {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"__exec: \"python /home/myUserName/getFullConfig.py\"\ntype: \"yaml\"","programmingLanguage":"YAML"}
       </script>
       <div class="css-16lmvu9">
        <div class="leafygreen-ui-196mwvg">
         <div class="leafygreen-ui-yzcs8i">
          <pre class="leafygreen-ui-11itue3" tabindex="-1"><code class="lg-highlight-hljs-light yaml leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx"><span class="lg-highlight-attr">__exec:</span> <span class="lg-highlight-string">"python /home/myUserName/getFullConfig.py"</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"><span class="lg-highlight-attr">type:</span> <span class="lg-highlight-string">"yaml"</span></td></tr></tbody></table></code></pre>
          <div class="leafygreen-ui-1bqcprk" data-testid="leafygreen-code-panel">
           <button aria-disabled="false" aria-label="Copy" class="leafygreen-ui-1c6zwke" data-testid="code_copy-button" tabindex="0">
            <div class="leafygreen-ui-xhlipt">
             <svg aria-label="Copy Icon" class="leafygreen-ui-1st74h4" height="16" role="img" viewbox="0 0 16 16" width="16">
              <path clip-rule="evenodd" d="M1 5.71428V10.2857C1 11.2325 1.76751 12 2.71429 12H5.75V7.10957C5.75 6.54414 5.97724 6.00244 6.38065 5.60623L8.67403 3.35381C8.77447 3.25516 8.88376 3.16757 9 3.09182V2.71429C9 1.76751 8.23249 1 7.28571 1H5.8V4.42857C5.8 5.13865 5.22437 5.71428 4.51429 5.71428H1ZM9 4.78571L7.25654 6.49804C7.24689 6.50752 7.23749 6.5172 7.22834 6.52708C7.22208 6.53383 7.21594 6.54068 7.20991 6.54762C7.07504 6.70295 7 6.90234 7 7.10957V7.79762H9H10.0095C10.4829 7.79762 10.8667 7.41386 10.8667 6.94047V4H10.1505C9.92587 4 9.7102 4.0882 9.54992 4.24562L9 4.78571ZM4.86667 1H4.15053C3.92587 1 3.7102 1.0882 3.54992 1.24562L1.25654 3.49804C1.09244 3.65921 1 3.87957 1 4.10957V4.79762H4.00952C4.48291 4.79762 4.86667 4.41386 4.86667 3.94047V1ZM7 12V8.71428H9H10.5143C11.2244 8.71428 11.8 8.13865 11.8 7.42857V4H13.2857C14.2325 4 15 4.76751 15 5.71429V13.2857C15 14.2325 14.2325 15 13.2857 15H8.71429C7.76751 15 7 14.2325 7 13.2857V12Z" fill="currentColor" fill-rule="evenodd">
              </path>
             </svg>
            </div>
           </button>
          </div>
         </div>
        </div>
       </div>
       <dl>
        <dt>
         File Permission
        </dt>
        <dd class="css-1ufxuu7">
         If the configuration file includes the
         <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-configexpansion-configexpansion.__exec" target="_self">
          <span>
           <code class="leafygreen-ui-1l06pbn">
            __exec
           </code>
          </span>
         </a>
         expansion, on Linux/macOS, the write access to the configuration file must be
limited to the user running the
         <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod">
          <code class="leafygreen-ui-1l06pbn">
           mongod
          </code>
         </a>
         /
         <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongos/#mongodb-binary-bin.mongos">
          <code class="leafygreen-ui-1l06pbn">
           mongos
          </code>
         </a>
         process only.
        </dd>
        <dt>
         Expansion Parsing
        </dt>
        <dd class="css-1ufxuu7">
         <p class="leafygreen-ui-1kp3ins">
          To parse the
          <code class="leafygreen-ui-1l06pbn">
           __exec
          </code>
          blocks, start the
          <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod">
           <code class="leafygreen-ui-1l06pbn">
            mongod
           </code>
          </a>
          /
          <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongos/#mongodb-binary-bin.mongos">
           <code class="leafygreen-ui-1l06pbn">
            mongos
           </code>
          </a>
          with
the
          <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#std-option-mongod.--configExpand">
           <code class="leafygreen-ui-1l06pbn">
            --configExpand "rest"
           </code>
          </a>
          option.
         </p>
         <p class="leafygreen-ui-1kp3ins">
          If the command executes successfully, the
          <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod">
           <code class="leafygreen-ui-1l06pbn">
            mongod
           </code>
          </a>
          /
          <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongos/#mongodb-binary-bin.mongos">
           <code class="leafygreen-ui-1l06pbn">
            mongos
           </code>
          </a>
          parses
the returned configuration
          <code class="leafygreen-ui-1l06pbn">
           yaml
          </code>
          file and uses it during
startup. If the command fails or returns an invalid
          <code class="leafygreen-ui-1l06pbn">
           yaml
          </code>
          file, the
          <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod">
           <code class="leafygreen-ui-1l06pbn">
            mongod
           </code>
          </a>
          /
          <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongos/#mongodb-binary-bin.mongos">
           <code class="leafygreen-ui-1l06pbn">
            mongos
           </code>
          </a>
          throws an error and terminates.
         </p>
        </dd>
       </dl>
      </div>
     </div>
    </div>
   </div>
  </div>
  <div class="leafygreen-ui-85da11" role="note">
   <h2 class="leafygreen-ui-1ac4g5h">
    Important
   </h2>
   <div class="leafygreen-ui-9mycqc">
    <p class="leafygreen-ui-1kp3ins">
     The data returned by executing the specified
     <code class="leafygreen-ui-1l06pbn">
      __exec
     </code>
     string
     <strong>
      cannot
     </strong>
     include any additional expansion
directives. The
     <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod">
      <code class="leafygreen-ui-1l06pbn">
       mongod
      </code>
     </a>
     /
     <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongos/#mongodb-binary-bin.mongos">
      <code class="leafygreen-ui-1l06pbn">
       mongos
      </code>
     </a>
     does
     <strong>
      not
     </strong>
     perform additional processing on the returned data and
will terminate with an error code if the returned data
includes additional expansion directives.
    </p>
   </div>
  </div>
  <span class="leafygreen-ui-1qnjd6d" id="std-label-expansion-directives">
  </span>
 </section>
 <section>
  <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium">
   Expansion Directives Reference
   <a class="headerlink leafygreen-ui-1kepx47" href="#expansion-directives-reference" title="Permalink to this heading">
    <svg aria-label="Link Icon" class="leafygreen-ui-a30zj9" fill="none" height="12" role="img" viewbox="0 0 16 16" width="12" xmlns="http://www.w3.org/2000/svg">
     <path d="M6.039 9.953a3.596 3.596 0 0 1-.327-.38l1.45-1.445a1.553 1.553 0 0 0 2.496.423l2.885-2.87a1.57 1.57 0 0 0 .01-2.213 1.553 1.553 0 0 0-2.203-.01l-.379.377A.995.995 0 0 1 8.56 3.83a1.005 1.005 0 0 1 .006-1.418l.38-.377a3.542 3.542 0 0 1 5.024.023 3.58 3.58 0 0 1-.022 5.047l-2.884 2.871a3.542 3.542 0 0 1-5.025-.022Z" fill="currentColor">
     </path>
     <path d="M9.961 6.047c.12.12.228.248.327.38l-1.45 1.445a1.553 1.553 0 0 0-2.496-.423l-2.885 2.87a1.57 1.57 0 0 0-.01 2.213 1.553 1.553 0 0 0 2.203.01l.379-.377a.995.995 0 0 1 1.411.006 1.005 1.005 0 0 1-.006 1.418l-.38.377a3.542 3.542 0 0 1-5.024-.023 3.58 3.58 0 0 1 .022-5.047l2.884-2.871a3.542 3.542 0 0 1 5.025.022Z" fill="currentColor">
     </path>
    </svg>
    <div class="css-1btu0w3 evvkmar0" id="expansion-directives-reference">
    </div>
   </a>
  </h2>
  <dl class="configexpansion">
   <dt>
    <code class="leafygreen-ui-1l06pbn">
     __rest
    </code>
    <a class="headerlink leafygreen-ui-1kepx47" href="#mongodb-configexpansion-configexpansion.__rest" title="Permalink to this definition">
     <svg aria-label="Link Icon" class="leafygreen-ui-a30zj9" fill="none" height="12" role="img" viewbox="0 0 16 16" width="12" xmlns="http://www.w3.org/2000/svg">
      <path d="M6.039 9.953a3.596 3.596 0 0 1-.327-.38l1.45-1.445a1.553 1.553 0 0 0 2.496.423l2.885-2.87a1.57 1.57 0 0 0 .01-2.213 1.553 1.553 0 0 0-2.203-.01l-.379.377A.995.995 0 0 1 8.56 3.83a1.005 1.005 0 0 1 .006-1.418l.38-.377a3.542 3.542 0 0 1 5.024.023 3.58 3.58 0 0 1-.022 5.047l-2.884 2.871a3.542 3.542 0 0 1-5.025-.022Z" fill="currentColor">
      </path>
      <path d="M9.961 6.047c.12.12.228.248.327.38l-1.45 1.445a1.553 1.553 0 0 0-2.496-.423l-2.885 2.87a1.57 1.57 0 0 0-.01 2.213 1.553 1.553 0 0 0 2.203.01l.379-.377a.995.995 0 0 1 1.411.006 1.005 1.005 0 0 1-.006 1.418l-.38.377a3.542 3.542 0 0 1-5.024-.023 3.58 3.58 0 0 1 .022-5.047l2.884-2.871a3.542 3.542 0 0 1 5.025.022Z" fill="currentColor">
      </path>
     </svg>
     <div class="css-1btu0w3 evvkmar0" id="mongodb-configexpansion-configexpansion.__rest">
     </div>
    </a>
   </dt>
   <dd>
    <p class="leafygreen-ui-1kp3ins">
     The
     <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-configexpansion-configexpansion.__rest" target="_self">
      <span>
       <code class="leafygreen-ui-1l06pbn">
        __rest
       </code>
      </span>
     </a>
     expansion directive loads configuration
file values from a
     <code class="leafygreen-ui-1l06pbn">
      REST
     </code>
     endpoint.
     <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-configexpansion-configexpansion.__rest" target="_self">
      <span>
       <code class="leafygreen-ui-1l06pbn">
        __rest
       </code>
      </span>
     </a>
     supports loading specific values in the configuration file
     <em>
      or
     </em>
     loading the entire configuration file. The
     <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod">
      <code class="leafygreen-ui-1l06pbn">
       mongod
      </code>
     </a>
     /
     <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongos/#mongodb-binary-bin.mongos">
      <code class="leafygreen-ui-1l06pbn">
       mongos
      </code>
     </a>
     then starts
using the externally sourced values as part of its configuration.
    </p>
    <p class="leafygreen-ui-1kp3ins">
     The
     <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-configexpansion-configexpansion.__rest" target="_self">
      <span>
       <code class="leafygreen-ui-1l06pbn">
        __rest
       </code>
      </span>
     </a>
     expansion directive has the following
syntax:
    </p>
    <ul class="leafygreen-ui-rioki0">
     <li class="leafygreen-ui-d7p7b6">
      <p class="leafygreen-ui-1kp3ins">
       To specify a
       <code class="leafygreen-ui-1l06pbn">
        REST
       </code>
       endpoint for a specific configuration file
setting or settings:
      </p>
      <script class="structured_data" type="application/ld+json">
       {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"&lt;some&gt;:\n  __rest: \"&lt;string&gt;\"\n  type: \"string\"\n  trim: \"none|whitespace\"\n  digest: \"&lt;string&gt;\"\n  digest_key: \"&lt;string&gt;\"","programmingLanguage":"YAML"}
      </script>
      <div class="css-16lmvu9">
       <div class="leafygreen-ui-196mwvg">
        <div class="leafygreen-ui-yzcs8i">
         <pre class="leafygreen-ui-11itue3" tabindex="-1"><code class="lg-highlight-hljs-light yaml leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx"><span class="lg-highlight-string">&lt;some</span> <span class="lg-highlight-string">configuration</span> <span class="lg-highlight-string">file</span> <span class="lg-highlight-string">setting&gt;:</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx">  <span class="lg-highlight-attr">__rest:</span> <span class="lg-highlight-string">"&lt;string&gt;"</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx">  <span class="lg-highlight-attr">type:</span> <span class="lg-highlight-string">"string"</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx">  <span class="lg-highlight-attr">trim:</span> <span class="lg-highlight-string">"none|whitespace"</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx">  <span class="lg-highlight-attr">digest:</span> <span class="lg-highlight-string">"&lt;string&gt;"</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx">  <span class="lg-highlight-attr">digest_key:</span> <span class="lg-highlight-string">"&lt;string&gt;"</span></td></tr></tbody></table></code></pre>
         <div class="leafygreen-ui-1bqcprk" data-testid="leafygreen-code-panel">
          <button aria-disabled="false" aria-label="Copy" class="leafygreen-ui-1c6zwke" data-testid="code_copy-button" tabindex="0">
           <div class="leafygreen-ui-xhlipt">
            <svg aria-label="Copy Icon" class="leafygreen-ui-1st74h4" height="16" role="img" viewbox="0 0 16 16" width="16">
             <path clip-rule="evenodd" d="M1 5.71428V10.2857C1 11.2325 1.76751 12 2.71429 12H5.75V7.10957C5.75 6.54414 5.97724 6.00244 6.38065 5.60623L8.67403 3.35381C8.77447 3.25516 8.88376 3.16757 9 3.09182V2.71429C9 1.76751 8.23249 1 7.28571 1H5.8V4.42857C5.8 5.13865 5.22437 5.71428 4.51429 5.71428H1ZM9 4.78571L7.25654 6.49804C7.24689 6.50752 7.23749 6.5172 7.22834 6.52708C7.22208 6.53383 7.21594 6.54068 7.20991 6.54762C7.07504 6.70295 7 6.90234 7 7.10957V7.79762H9H10.0095C10.4829 7.79762 10.8667 7.41386 10.8667 6.94047V4H10.1505C9.92587 4 9.7102 4.0882 9.54992 4.24562L9 4.78571ZM4.86667 1H4.15053C3.92587 1 3.7102 1.0882 3.54992 1.24562L1.25654 3.49804C1.09244 3.65921 1 3.87957 1 4.10957V4.79762H4.00952C4.48291 4.79762 4.86667 4.41386 4.86667 3.94047V1ZM7 12V8.71428H9H10.5143C11.2244 8.71428 11.8 8.13865 11.8 7.42857V4H13.2857C14.2325 4 15 4.76751 15 5.71429V13.2857C15 14.2325 14.2325 15 13.2857 15H8.71429C7.76751 15 7 14.2325 7 13.2857V12Z" fill="currentColor" fill-rule="evenodd">
             </path>
            </svg>
           </div>
          </button>
         </div>
        </div>
       </div>
      </div>
     </li>
     <li class="leafygreen-ui-d7p7b6">
      <p class="leafygreen-ui-1kp3ins">
       To specify a
       <code class="leafygreen-ui-1l06pbn">
        REST
       </code>
       endpoint for the entire configuration file:
      </p>
      <script class="structured_data" type="application/ld+json">
       {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"__rest: \"&lt;string&gt;\"\ntype: \"yaml\"\ntrim: \"none|whitespace\"","programmingLanguage":"YAML"}
      </script>
      <div class="css-16lmvu9">
       <div class="leafygreen-ui-196mwvg">
        <div class="leafygreen-ui-yzcs8i">
         <pre class="leafygreen-ui-11itue3" tabindex="-1"><code class="lg-highlight-hljs-light yaml leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx"><span class="lg-highlight-attr">__rest:</span> <span class="lg-highlight-string">"&lt;string&gt;"</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"><span class="lg-highlight-attr">type:</span> <span class="lg-highlight-string">"yaml"</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"><span class="lg-highlight-attr">trim:</span> <span class="lg-highlight-string">"none|whitespace"</span></td></tr></tbody></table></code></pre>
         <div class="leafygreen-ui-1bqcprk" data-testid="leafygreen-code-panel">
          <button aria-disabled="false" aria-label="Copy" class="leafygreen-ui-1c6zwke" data-testid="code_copy-button" tabindex="0">
           <div class="leafygreen-ui-xhlipt">
            <svg aria-label="Copy Icon" class="leafygreen-ui-1st74h4" height="16" role="img" viewbox="0 0 16 16" width="16">
             <path clip-rule="evenodd" d="M1 5.71428V10.2857C1 11.2325 1.76751 12 2.71429 12H5.75V7.10957C5.75 6.54414 5.97724 6.00244 6.38065 5.60623L8.67403 3.35381C8.77447 3.25516 8.88376 3.16757 9 3.09182V2.71429C9 1.76751 8.23249 1 7.28571 1H5.8V4.42857C5.8 5.13865 5.22437 5.71428 4.51429 5.71428H1ZM9 4.78571L7.25654 6.49804C7.24689 6.50752 7.23749 6.5172 7.22834 6.52708C7.22208 6.53383 7.21594 6.54068 7.20991 6.54762C7.07504 6.70295 7 6.90234 7 7.10957V7.79762H9H10.0095C10.4829 7.79762 10.8667 7.41386 10.8667 6.94047V4H10.1505C9.92587 4 9.7102 4.0882 9.54992 4.24562L9 4.78571ZM4.86667 1H4.15053C3.92587 1 3.7102 1.0882 3.54992 1.24562L1.25654 3.49804C1.09244 3.65921 1 3.87957 1 4.10957V4.79762H4.00952C4.48291 4.79762 4.86667 4.41386 4.86667 3.94047V1ZM7 12V8.71428H9H10.5143C11.2244 8.71428 11.8 8.13865 11.8 7.42857V4H13.2857C14.2325 4 15 4.76751 15 5.71429V13.2857C15 14.2325 14.2325 15 13.2857 15H8.71429C7.76751 15 7 14.2325 7 13.2857V12Z" fill="currentColor" fill-rule="evenodd">
             </path>
            </svg>
           </div>
          </button>
         </div>
        </div>
       </div>
      </div>
      <p class="leafygreen-ui-1kp3ins">
       If specifying the entire configuration file via
       <code class="leafygreen-ui-1l06pbn">
        REST
       </code>
       endpoint,
the expansion directive and its options
       <strong>
        must
       </strong>
       be the only values
specified in the configuration file.
      </p>
     </li>
    </ul>
    <p class="leafygreen-ui-1kp3ins">
     <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-configexpansion-configexpansion.__rest" target="_self">
      <span>
       <code class="leafygreen-ui-1l06pbn">
        __rest
       </code>
      </span>
     </a>
     takes the following fields:
    </p>
    <div class="leafygreen-ui-skkc39" tabindex="0">
     <table class="leafygreen-ui-hr8lsv">
      <colgroup>
       <col style="width:15%"/>
       <col style="width:15%"/>
       <col style="width:70%"/>
      </colgroup>
      <thead class="leafygreen-ui-a9ho40">
       <tr data-testid="leafygreen-ui-header-row">
        <th class="leafygreen-ui-1trtg6r" role="columnheader" scope="col">
         <div class="leafygreen-ui-ui0te9">
          <div>
           Field
          </div>
         </div>
        </th>
        <th class="leafygreen-ui-13uteka" role="columnheader" scope="col">
         <div class="leafygreen-ui-ui0te9">
          <div>
           Type
          </div>
         </div>
        </th>
        <th class="leafygreen-ui-13uteka" role="columnheader" scope="col">
         <div class="leafygreen-ui-ui0te9">
          <div>
           Description
          </div>
         </div>
        </th>
       </tr>
      </thead>
      <tbody>
       <tr class="leafygreen-ui-15dvrnp">
        <td class="leafygreen-ui-1drjk7h">
         <div class="leafygreen-ui-1n4j8xf">
          <div>
           <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-expansion-rest" target="_self">
            <span>
             __rest
            </span>
           </a>
          </div>
         </div>
        </td>
        <td class="leafygreen-ui-1drjk7h">
         <div class="leafygreen-ui-1n4j8xf">
          <div>
           string
          </div>
         </div>
        </td>
        <td class="leafygreen-ui-1drjk7h">
         <div class="leafygreen-ui-1n4j8xf">
          <div>
           <span class="leafygreen-ui-1qnjd6d" id="std-label-expansion-rest">
           </span>
           <p class="leafygreen-ui-1kp3ins">
            <em>
             Required
            </em>
            The URL against which the
            <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod">
             <code class="leafygreen-ui-1l06pbn">
              mongod
             </code>
            </a>
            /
            <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongos/#mongodb-binary-bin.mongos">
             <code class="leafygreen-ui-1l06pbn">
              mongos
             </code>
            </a>
            issues a
            <code class="leafygreen-ui-1l06pbn">
             GET
            </code>
            request
to retrieve the externally sourced value.
           </p>
           <p class="leafygreen-ui-1kp3ins">
            For non-localhost
            <code class="leafygreen-ui-1l06pbn">
             REST
            </code>
            endpoints (e.g. a
            <code class="leafygreen-ui-1l06pbn">
             REST
            </code>
            endpoint
hosted on a remote server),
            <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-configexpansion-configexpansion.__rest" target="_self">
             <span>
              <code class="leafygreen-ui-1l06pbn">
               __rest
              </code>
             </span>
            </a>
            requires encrypted (
            <code class="leafygreen-ui-1l06pbn">
             https://
            </code>
            ) URLs where both the host
machine and the remote server support TLS 1.1 or later.
           </p>
           <p class="leafygreen-ui-1kp3ins">
            If the
            <code class="leafygreen-ui-1l06pbn">
             REST
            </code>
            endpoint specified in the URL requires
authentication, encode credentials into the URL with the
standard
            <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://tools.ietf.org/html/rfc3986#section-3.2.1" rel="noopener noreferrer">
             <span>
              RFC 3986 User Information
             </span>
             <svg alt="" aria-hidden="true" class="leafygreen-ui-1ie5kuq" height="16" role="presentation" viewbox="0 0 16 16" width="16">
              <path d="M13.823 2.4491C13.8201 2.30008 13.6999 2.17994 13.5509 2.17704L9.5062 2.09836C9.25654 2.09351 9.12821 2.39519 9.30482 2.5718L10.3856 3.65257L7.93433 6.10383C7.87964 6.15852 7.83047 6.21665 7.78683 6.27752L5.99909 8.06525C5.46457 8.59977 5.46457 9.4664 5.99909 10.0009C6.53361 10.5354 7.40023 10.5354 7.93475 10.0009L9.72249 8.21317C9.78336 8.16953 9.84148 8.12037 9.89618 8.06567L12.3474 5.61441L13.4282 6.69518C13.6048 6.87179 13.9065 6.74347 13.9016 6.4938L13.823 2.4491Z" fill="currentColor">
              </path>
              <path d="M7.25 3.12893C7.66421 3.12893 8 3.46472 8 3.87893C8 4.29315 7.66421 4.62893 7.25 4.62893H4C3.72386 4.62893 3.5 4.85279 3.5 5.12893V11.9929C3.5 12.2691 3.72386 12.4929 4 12.4929H10.864C11.1401 12.4929 11.364 12.2691 11.364 11.9929V8.75C11.364 8.33579 11.6998 8 12.114 8C12.5282 8 12.864 8.33579 12.864 8.75V11.9929C12.864 13.0975 11.9686 13.9929 10.864 13.9929H4C2.89543 13.9929 2 13.0975 2 11.9929V5.12893C2 4.02436 2.89543 3.12893 4 3.12893H7.25Z" fill="currentColor">
              </path>
             </svg>
            </a>
            format.
           </p>
           <p class="leafygreen-ui-1kp3ins">
            For localhost
            <code class="leafygreen-ui-1l06pbn">
             REST
            </code>
            endpoints (e.g. a
            <code class="leafygreen-ui-1l06pbn">
             REST
            </code>
            endpoint
listening on the host machine),
            <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-configexpansion-configexpansion.__rest" target="_self">
             <span>
              <code class="leafygreen-ui-1l06pbn">
               __rest
              </code>
             </span>
            </a>
            allows unencrypted (
            <code class="leafygreen-ui-1l06pbn">
             http://
            </code>
            ) URLs.
           </p>
           <p class="leafygreen-ui-1kp3ins">
            <strong class="css-rws738">
             IMPORTANT:
            </strong>
            The value returned by the specified
            <code class="leafygreen-ui-1l06pbn">
             REST
            </code>
            endpoint
            <strong>
             cannot
            </strong>
            include any additional expansion directives. The
            <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod">
             <code class="leafygreen-ui-1l06pbn">
              mongod
             </code>
            </a>
            /
            <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongos/#mongodb-binary-bin.mongos">
             <code class="leafygreen-ui-1l06pbn">
              mongos
             </code>
            </a>
            does
            <strong>
             not
            </strong>
            perform additional
processing on the returned data and will terminate with an
error code if the returned data includes additional
expansion directives.
           </p>
          </div>
         </div>
        </td>
       </tr>
       <tr class="leafygreen-ui-15dvrnp">
        <td class="leafygreen-ui-1drjk7h">
         <div class="leafygreen-ui-1n4j8xf">
          <div>
           <code class="leafygreen-ui-1l06pbn">
            type
           </code>
          </div>
         </div>
        </td>
        <td class="leafygreen-ui-1drjk7h">
         <div class="leafygreen-ui-1n4j8xf">
          <div>
           string
          </div>
         </div>
        </td>
        <td class="leafygreen-ui-1drjk7h">
         <div class="leafygreen-ui-1n4j8xf">
          <div>
           <p class="leafygreen-ui-1kp3ins">
            <em>
             Optional
            </em>
            Controls how
            <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-configexpansion-configexpansion.__rest" target="_self">
             <span>
              <code class="leafygreen-ui-1l06pbn">
               __rest
              </code>
             </span>
            </a>
            parses the returned value from the specified URL.
           </p>
           <p class="leafygreen-ui-1kp3ins">
            Possible values are:
           </p>
           <ul class="leafygreen-ui-rioki0">
            <li class="leafygreen-ui-d7p7b6">
             <p class="leafygreen-ui-1kp3ins">
              <code class="leafygreen-ui-1l06pbn">
               string
              </code>
              (
              <em>
               Default
              </em>
              )
             </p>
             <p class="leafygreen-ui-1kp3ins">
              Directs
              <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-configexpansion-configexpansion.__rest" target="_self">
               <span>
                <code class="leafygreen-ui-1l06pbn">
                 __rest
                </code>
               </span>
              </a>
              to parse the returned data
as a literal string. If specifying
              <code class="leafygreen-ui-1l06pbn">
               string
              </code>
              , the entire
              <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-configexpansion-configexpansion.__rest" target="_self">
               <span>
                <code class="leafygreen-ui-1l06pbn">
                 __rest
                </code>
               </span>
              </a>
              block and supporting options must
be nested under the field for which you are loading
externally sourced values.
             </p>
            </li>
            <li class="leafygreen-ui-d7p7b6">
             <p class="leafygreen-ui-1kp3ins">
              <code class="leafygreen-ui-1l06pbn">
               yaml
              </code>
             </p>
             <p class="leafygreen-ui-1kp3ins">
              Directs
              <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-configexpansion-configexpansion.__rest" target="_self">
               <span>
                <code class="leafygreen-ui-1l06pbn">
                 __rest
                </code>
               </span>
              </a>
              to parse the returned data
as a
              <code class="leafygreen-ui-1l06pbn">
               yaml
              </code>
              formatted file. If specifying
              <code class="leafygreen-ui-1l06pbn">
               yaml
              </code>
              , the
              <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-configexpansion-configexpansion.__rest" target="_self">
               <span>
                <code class="leafygreen-ui-1l06pbn">
                 __rest
                </code>
               </span>
              </a>
              block must be the only content in
the configuration file. The
              <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod">
               <code class="leafygreen-ui-1l06pbn">
                mongod
               </code>
              </a>
              /
              <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongos/#mongodb-binary-bin.mongos">
               <code class="leafygreen-ui-1l06pbn">
                mongos
               </code>
              </a>
              replaces the
configuration file contents with the
              <code class="leafygreen-ui-1l06pbn">
               yaml
              </code>
              retrieved from
the REST resource.
             </p>
            </li>
           </ul>
          </div>
         </div>
        </td>
       </tr>
       <tr class="leafygreen-ui-15dvrnp">
        <td class="leafygreen-ui-1drjk7h">
         <div class="leafygreen-ui-1n4j8xf">
          <div>
           <code class="leafygreen-ui-1l06pbn">
            trim
           </code>
          </div>
         </div>
        </td>
        <td class="leafygreen-ui-1drjk7h">
         <div class="leafygreen-ui-1n4j8xf">
          <div>
           string
          </div>
         </div>
        </td>
        <td class="leafygreen-ui-1drjk7h">
         <div class="leafygreen-ui-1n4j8xf">
          <div>
           <em>
            Optional
           </em>
           Specify
           <code class="leafygreen-ui-1l06pbn">
            whitespace
           </code>
           to direct
           <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-configexpansion-configexpansion.__rest" target="_self">
            <span>
             <code class="leafygreen-ui-1l06pbn">
              __rest
             </code>
            </span>
           </a>
           to trim any leading or trailing whitespace, specifically
occurrences of
           <code class="leafygreen-ui-1l06pbn">
            " "
           </code>
           ,
           <code class="leafygreen-ui-1l06pbn">
            "\r"
           </code>
           ,
           <code class="leafygreen-ui-1l06pbn">
            "\n"
           </code>
           ,
           <code class="leafygreen-ui-1l06pbn">
            "\t"
           </code>
           ,
           <code class="leafygreen-ui-1l06pbn">
            "\v"
           </code>
           , and
           <code class="leafygreen-ui-1l06pbn">
            "\f"
           </code>
           . Defaults to
           <code class="leafygreen-ui-1l06pbn">
            none
           </code>
           , or no trimming.
          </div>
         </div>
        </td>
       </tr>
       <tr class="leafygreen-ui-15dvrnp">
        <td class="leafygreen-ui-1drjk7h">
         <div class="leafygreen-ui-1n4j8xf">
          <div>
           <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-expansion-rest-digest" target="_self">
            <span>
             digest
            </span>
           </a>
          </div>
         </div>
        </td>
        <td class="leafygreen-ui-1drjk7h">
         <div class="leafygreen-ui-1n4j8xf">
          <div>
           string
          </div>
         </div>
        </td>
        <td class="leafygreen-ui-1drjk7h">
         <div class="leafygreen-ui-1n4j8xf">
          <div>
           <span class="leafygreen-ui-1qnjd6d" id="std-label-expansion-rest-digest">
           </span>
           <p class="leafygreen-ui-1kp3ins">
            <em>
             Optional
            </em>
            . The SHA-256 digest of the expansion result.
           </p>
           <p class="leafygreen-ui-1kp3ins">
            If specified, you must also specify the
            <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-expansion-rest-digest-key" target="_self">
             <span>
              digest_key
              <!-- -->
              .
             </span>
            </a>
           </p>
          </div>
         </div>
        </td>
       </tr>
       <tr class="leafygreen-ui-15dvrnp">
        <td class="leafygreen-ui-1drjk7h">
         <div class="leafygreen-ui-1n4j8xf">
          <div>
           <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-expansion-rest-digest-key" target="_self">
            <span>
             digest_key
            </span>
           </a>
          </div>
         </div>
        </td>
        <td class="leafygreen-ui-1drjk7h">
         <div class="leafygreen-ui-1n4j8xf">
          <div>
           string
          </div>
         </div>
        </td>
        <td class="leafygreen-ui-1drjk7h">
         <div class="leafygreen-ui-1n4j8xf">
          <div>
           <span class="leafygreen-ui-1qnjd6d" id="std-label-expansion-rest-digest-key">
           </span>
           <p class="leafygreen-ui-1kp3ins">
            <em>
             Optional
            </em>
            . The hexadecimal string representation of the
secret used to calculate the SHA-256
            <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-expansion-rest-digest" target="_self">
             <span>
              digest
              <!-- -->
              .
             </span>
            </a>
           </p>
           <p class="leafygreen-ui-1kp3ins">
            If specified, you must also specify the
            <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-expansion-rest-digest" target="_self">
             <span>
              digest
              <!-- -->
              .
             </span>
            </a>
           </p>
          </div>
         </div>
        </td>
       </tr>
      </tbody>
     </table>
    </div>
    <div class="leafygreen-ui-15mdk4" role="note">
     <h2 class="leafygreen-ui-6n7b7d">
      Note
     </h2>
     <div class="leafygreen-ui-9mycqc">
      <ul class="leafygreen-ui-rioki0">
       <li class="leafygreen-ui-d7p7b6">
        <p class="leafygreen-ui-1kp3ins">
         If the configuration file includes the
         <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-configexpansion-configexpansion.__rest" target="_self">
          <span>
           <code class="leafygreen-ui-1l06pbn">
            __rest
           </code>
          </span>
         </a>
         expansion, on Linux/macOS, the read access to the configuration file must be limited
to the user running the
         <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod">
          <code class="leafygreen-ui-1l06pbn">
           mongod
          </code>
         </a>
         /
         <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongos/#mongodb-binary-bin.mongos">
          <code class="leafygreen-ui-1l06pbn">
           mongos
          </code>
         </a>
         process only.
        </p>
       </li>
       <li class="leafygreen-ui-d7p7b6">
        <p class="leafygreen-ui-1kp3ins">
         To enable parsing of the
         <code class="leafygreen-ui-1l06pbn">
          __rest
         </code>
         expansion directive, start
the
         <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod">
          <code class="leafygreen-ui-1l06pbn">
           mongod
          </code>
         </a>
         /
         <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongos/#mongodb-binary-bin.mongos">
          <code class="leafygreen-ui-1l06pbn">
           mongos
          </code>
         </a>
         with the
         <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#std-option-mongod.--configExpand">
          <code class="leafygreen-ui-1l06pbn">
           --configExpand "rest"
          </code>
         </a>
         option.
        </p>
       </li>
      </ul>
     </div>
    </div>
    <p class="leafygreen-ui-1kp3ins">
     For examples, see
     <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-expansion-directive-rest" target="_self">
      <span>
       Use the
       <code class="leafygreen-ui-1l06pbn">
        __rest
       </code>
       Expansion Directive
       <!-- -->
       .
      </span>
     </a>
    </p>
   </dd>
  </dl>
  <dl class="configexpansion">
   <dt>
    <code class="leafygreen-ui-1l06pbn">
     __exec
    </code>
    <a class="headerlink leafygreen-ui-1kepx47" href="#mongodb-configexpansion-configexpansion.__exec" title="Permalink to this definition">
     <svg aria-label="Link Icon" class="leafygreen-ui-a30zj9" fill="none" height="12" role="img" viewbox="0 0 16 16" width="12" xmlns="http://www.w3.org/2000/svg">
      <path d="M6.039 9.953a3.596 3.596 0 0 1-.327-.38l1.45-1.445a1.553 1.553 0 0 0 2.496.423l2.885-2.87a1.57 1.57 0 0 0 .01-2.213 1.553 1.553 0 0 0-2.203-.01l-.379.377A.995.995 0 0 1 8.56 3.83a1.005 1.005 0 0 1 .006-1.418l.38-.377a3.542 3.542 0 0 1 5.024.023 3.58 3.58 0 0 1-.022 5.047l-2.884 2.871a3.542 3.542 0 0 1-5.025-.022Z" fill="currentColor">
      </path>
      <path d="M9.961 6.047c.12.12.228.248.327.38l-1.45 1.445a1.553 1.553 0 0 0-2.496-.423l-2.885 2.87a1.57 1.57 0 0 0-.01 2.213 1.553 1.553 0 0 0 2.203.01l.379-.377a.995.995 0 0 1 1.411.006 1.005 1.005 0 0 1-.006 1.418l-.38.377a3.542 3.542 0 0 1-5.024-.023 3.58 3.58 0 0 1 .022-5.047l2.884-2.871a3.542 3.542 0 0 1 5.025.022Z" fill="currentColor">
      </path>
     </svg>
     <div class="css-1btu0w3 evvkmar0" id="mongodb-configexpansion-configexpansion.__exec">
     </div>
    </a>
   </dt>
   <dd>
    <p class="leafygreen-ui-1kp3ins">
     The
     <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-configexpansion-configexpansion.__exec" target="_self">
      <span>
       <code class="leafygreen-ui-1l06pbn">
        __exec
       </code>
      </span>
     </a>
     expansion directive loads configuration
file values from the output of a shell or terminal command.
     <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-configexpansion-configexpansion.__exec" target="_self">
      <span>
       <code class="leafygreen-ui-1l06pbn">
        __exec
       </code>
      </span>
     </a>
     supports loading specific values in the
configuration file
     <em>
      or
     </em>
     loading the entire configuration file. The
     <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod">
      <code class="leafygreen-ui-1l06pbn">
       mongod
      </code>
     </a>
     /
     <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongos/#mongodb-binary-bin.mongos">
      <code class="leafygreen-ui-1l06pbn">
       mongos
      </code>
     </a>
     then starts using the externally sourced values as part of
its configuration.
    </p>
    <p class="leafygreen-ui-1kp3ins">
     The
     <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-configexpansion-configexpansion.__exec" target="_self">
      <span>
       <code class="leafygreen-ui-1l06pbn">
        __exec
       </code>
      </span>
     </a>
     expansion directive has the following
syntax:
    </p>
    <ul class="leafygreen-ui-rioki0">
     <li class="leafygreen-ui-d7p7b6">
      <p class="leafygreen-ui-1kp3ins">
       To specify a shell or terminal command for a specific configuration
file
setting or settings:
      </p>
      <script class="structured_data" type="application/ld+json">
       {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"&lt;some&gt;:\n  __exec: \"&lt;string&gt;\"\n  type: \"string\"\n  trim: \"none|whitespace\"","programmingLanguage":"YAML"}
      </script>
      <div class="css-16lmvu9">
       <div class="leafygreen-ui-196mwvg">
        <div class="leafygreen-ui-yzcs8i">
         <pre class="leafygreen-ui-11itue3" tabindex="-1"><code class="lg-highlight-hljs-light yaml leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx"><span class="lg-highlight-string">&lt;some</span> <span class="lg-highlight-string">configuration</span> <span class="lg-highlight-string">file</span> <span class="lg-highlight-string">setting&gt;:</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx">  <span class="lg-highlight-attr">__exec:</span> <span class="lg-highlight-string">"&lt;string&gt;"</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx">  <span class="lg-highlight-attr">type:</span> <span class="lg-highlight-string">"string"</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx">  <span class="lg-highlight-attr">trim:</span> <span class="lg-highlight-string">"none|whitespace"</span></td></tr></tbody></table></code></pre>
         <div class="leafygreen-ui-1bqcprk" data-testid="leafygreen-code-panel">
          <button aria-disabled="false" aria-label="Copy" class="leafygreen-ui-1c6zwke" data-testid="code_copy-button" tabindex="0">
           <div class="leafygreen-ui-xhlipt">
            <svg aria-label="Copy Icon" class="leafygreen-ui-1st74h4" height="16" role="img" viewbox="0 0 16 16" width="16">
             <path clip-rule="evenodd" d="M1 5.71428V10.2857C1 11.2325 1.76751 12 2.71429 12H5.75V7.10957C5.75 6.54414 5.97724 6.00244 6.38065 5.60623L8.67403 3.35381C8.77447 3.25516 8.88376 3.16757 9 3.09182V2.71429C9 1.76751 8.23249 1 7.28571 1H5.8V4.42857C5.8 5.13865 5.22437 5.71428 4.51429 5.71428H1ZM9 4.78571L7.25654 6.49804C7.24689 6.50752 7.23749 6.5172 7.22834 6.52708C7.22208 6.53383 7.21594 6.54068 7.20991 6.54762C7.07504 6.70295 7 6.90234 7 7.10957V7.79762H9H10.0095C10.4829 7.79762 10.8667 7.41386 10.8667 6.94047V4H10.1505C9.92587 4 9.7102 4.0882 9.54992 4.24562L9 4.78571ZM4.86667 1H4.15053C3.92587 1 3.7102 1.0882 3.54992 1.24562L1.25654 3.49804C1.09244 3.65921 1 3.87957 1 4.10957V4.79762H4.00952C4.48291 4.79762 4.86667 4.41386 4.86667 3.94047V1ZM7 12V8.71428H9H10.5143C11.2244 8.71428 11.8 8.13865 11.8 7.42857V4H13.2857C14.2325 4 15 4.76751 15 5.71429V13.2857C15 14.2325 14.2325 15 13.2857 15H8.71429C7.76751 15 7 14.2325 7 13.2857V12Z" fill="currentColor" fill-rule="evenodd">
             </path>
            </svg>
           </div>
          </button>
         </div>
        </div>
       </div>
      </div>
     </li>
     <li class="leafygreen-ui-d7p7b6">
      <p class="leafygreen-ui-1kp3ins">
       To specify a  a shell or terminal command for the entire
configuration file:
      </p>
      <script class="structured_data" type="application/ld+json">
       {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"__exec: \"&lt;string&gt;\"\ntype: \"yaml\"\ntrim: \"none|whitespace\"","programmingLanguage":"YAML"}
      </script>
      <div class="css-16lmvu9">
       <div class="leafygreen-ui-196mwvg">
        <div class="leafygreen-ui-yzcs8i">
         <pre class="leafygreen-ui-11itue3" tabindex="-1"><code class="lg-highlight-hljs-light yaml leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx"><span class="lg-highlight-attr">__exec:</span> <span class="lg-highlight-string">"&lt;string&gt;"</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"><span class="lg-highlight-attr">type:</span> <span class="lg-highlight-string">"yaml"</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"><span class="lg-highlight-attr">trim:</span> <span class="lg-highlight-string">"none|whitespace"</span></td></tr></tbody></table></code></pre>
         <div class="leafygreen-ui-1bqcprk" data-testid="leafygreen-code-panel">
          <button aria-disabled="false" aria-label="Copy" class="leafygreen-ui-1c6zwke" data-testid="code_copy-button" tabindex="0">
           <div class="leafygreen-ui-xhlipt">
            <svg aria-label="Copy Icon" class="leafygreen-ui-1st74h4" height="16" role="img" viewbox="0 0 16 16" width="16">
             <path clip-rule="evenodd" d="M1 5.71428V10.2857C1 11.2325 1.76751 12 2.71429 12H5.75V7.10957C5.75 6.54414 5.97724 6.00244 6.38065 5.60623L8.67403 3.35381C8.77447 3.25516 8.88376 3.16757 9 3.09182V2.71429C9 1.76751 8.23249 1 7.28571 1H5.8V4.42857C5.8 5.13865 5.22437 5.71428 4.51429 5.71428H1ZM9 4.78571L7.25654 6.49804C7.24689 6.50752 7.23749 6.5172 7.22834 6.52708C7.22208 6.53383 7.21594 6.54068 7.20991 6.54762C7.07504 6.70295 7 6.90234 7 7.10957V7.79762H9H10.0095C10.4829 7.79762 10.8667 7.41386 10.8667 6.94047V4H10.1505C9.92587 4 9.7102 4.0882 9.54992 4.24562L9 4.78571ZM4.86667 1H4.15053C3.92587 1 3.7102 1.0882 3.54992 1.24562L1.25654 3.49804C1.09244 3.65921 1 3.87957 1 4.10957V4.79762H4.00952C4.48291 4.79762 4.86667 4.41386 4.86667 3.94047V1ZM7 12V8.71428H9H10.5143C11.2244 8.71428 11.8 8.13865 11.8 7.42857V4H13.2857C14.2325 4 15 4.76751 15 5.71429V13.2857C15 14.2325 14.2325 15 13.2857 15H8.71429C7.76751 15 7 14.2325 7 13.2857V12Z" fill="currentColor" fill-rule="evenodd">
             </path>
            </svg>
           </div>
          </button>
         </div>
        </div>
       </div>
      </div>
      <p class="leafygreen-ui-1kp3ins">
       If specifying the entire configuration file via a terminal or shell
command, the expansion directive and its options
       <strong>
        must
       </strong>
       be the
only values specified in the configuration file.
      </p>
     </li>
    </ul>
    <p class="leafygreen-ui-1kp3ins">
     <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-configexpansion-configexpansion.__exec" target="_self">
      <span>
       <code class="leafygreen-ui-1l06pbn">
        __exec
       </code>
      </span>
     </a>
     takes the following fields:
    </p>
    <div class="leafygreen-ui-skkc39" tabindex="0">
     <table class="leafygreen-ui-hr8lsv">
      <colgroup>
       <col style="width:15%"/>
       <col style="width:15%"/>
       <col style="width:70%"/>
      </colgroup>
      <thead class="leafygreen-ui-a9ho40">
       <tr data-testid="leafygreen-ui-header-row">
        <th class="leafygreen-ui-1trtg6r" role="columnheader" scope="col">
         <div class="leafygreen-ui-ui0te9">
          <div>
           Field
          </div>
         </div>
        </th>
        <th class="leafygreen-ui-13uteka" role="columnheader" scope="col">
         <div class="leafygreen-ui-ui0te9">
          <div>
           Type
          </div>
         </div>
        </th>
        <th class="leafygreen-ui-13uteka" role="columnheader" scope="col">
         <div class="leafygreen-ui-ui0te9">
          <div>
           Description
          </div>
         </div>
        </th>
       </tr>
      </thead>
      <tbody>
       <tr class="leafygreen-ui-15dvrnp">
        <td class="leafygreen-ui-1drjk7h">
         <div class="leafygreen-ui-1n4j8xf">
          <div>
           <code class="leafygreen-ui-1l06pbn">
            __exec
           </code>
          </div>
         </div>
        </td>
        <td class="leafygreen-ui-1drjk7h">
         <div class="leafygreen-ui-1n4j8xf">
          <div>
           string
          </div>
         </div>
        </td>
        <td class="leafygreen-ui-1drjk7h">
         <div class="leafygreen-ui-1n4j8xf">
          <div>
           <p class="leafygreen-ui-1kp3ins">
            <em>
             Required
            </em>
            The string which the
            <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod">
             <code class="leafygreen-ui-1l06pbn">
              mongod
             </code>
            </a>
            /
            <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongos/#mongodb-binary-bin.mongos">
             <code class="leafygreen-ui-1l06pbn">
              mongos
             </code>
            </a>
            executes on the
terminal or shell to retrieve the externally sourced value.
           </p>
           <p class="leafygreen-ui-1kp3ins">
            On Linux and OSX hosts, execution is handled via
POSIX
            <code class="leafygreen-ui-1l06pbn">
             popen()
            </code>
            . On Windows hosts, execution is handled via
the process control API.
            <code class="leafygreen-ui-1l06pbn">
             __exec
            </code>
            opens a read-only
pipe as the same user that started the
            <code class="leafygreen-ui-1l06pbn">
             mongod
            </code>
            or
            <code class="leafygreen-ui-1l06pbn">
             mongos
            </code>
            .
           </p>
           <p class="leafygreen-ui-1kp3ins">
            <strong class="css-rws738">
             IMPORTANT:
            </strong>
            The data returned by executing the specified
command
            <strong>
             cannot
            </strong>
            include any additional expansion
directives. The
            <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod">
             <code class="leafygreen-ui-1l06pbn">
              mongod
             </code>
            </a>
            /
            <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongos/#mongodb-binary-bin.mongos">
             <code class="leafygreen-ui-1l06pbn">
              mongos
             </code>
            </a>
            does
            <strong>
             not
            </strong>
            perform additional processing on the returned data and
will terminate with an error code if the returned data
includes additional expansion directives.
           </p>
          </div>
         </div>
        </td>
       </tr>
       <tr class="leafygreen-ui-15dvrnp">
        <td class="leafygreen-ui-1drjk7h">
         <div class="leafygreen-ui-1n4j8xf">
          <div>
           <code class="leafygreen-ui-1l06pbn">
            type
           </code>
          </div>
         </div>
        </td>
        <td class="leafygreen-ui-1drjk7h">
         <div class="leafygreen-ui-1n4j8xf">
          <div>
           string
          </div>
         </div>
        </td>
        <td class="leafygreen-ui-1drjk7h">
         <div class="leafygreen-ui-1n4j8xf">
          <div>
           <p class="leafygreen-ui-1kp3ins">
            <em>
             Optional
            </em>
            Controls how
            <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-configexpansion-configexpansion.__exec" target="_self">
             <span>
              <code class="leafygreen-ui-1l06pbn">
               __exec
              </code>
             </span>
            </a>
            parses the value returned by the executed command.
           </p>
           <p class="leafygreen-ui-1kp3ins">
            Possible values are:
           </p>
           <ul class="leafygreen-ui-rioki0">
            <li class="leafygreen-ui-d7p7b6">
             <p class="leafygreen-ui-1kp3ins">
              <code class="leafygreen-ui-1l06pbn">
               string
              </code>
              (
              <em>
               Default
              </em>
              )
             </p>
             <p class="leafygreen-ui-1kp3ins">
              Directs
              <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-configexpansion-configexpansion.__exec" target="_self">
               <span>
                <code class="leafygreen-ui-1l06pbn">
                 __exec
                </code>
               </span>
              </a>
              to parse the returned data
as a literal string. If specifying
              <code class="leafygreen-ui-1l06pbn">
               string
              </code>
              , the entire
              <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-configexpansion-configexpansion.__exec" target="_self">
               <span>
                <code class="leafygreen-ui-1l06pbn">
                 __exec
                </code>
               </span>
              </a>
              block and supporting options must
be nested under the field for which you are loading
externally sourced values.
             </p>
            </li>
            <li class="leafygreen-ui-d7p7b6">
             <p class="leafygreen-ui-1kp3ins">
              <code class="leafygreen-ui-1l06pbn">
               yaml
              </code>
             </p>
             <p class="leafygreen-ui-1kp3ins">
              Directs
              <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-configexpansion-configexpansion.__exec" target="_self">
               <span>
                <code class="leafygreen-ui-1l06pbn">
                 __exec
                </code>
               </span>
              </a>
              to parse the returned data
as a
              <code class="leafygreen-ui-1l06pbn">
               yaml
              </code>
              formatted file. If specifying
              <code class="leafygreen-ui-1l06pbn">
               yaml
              </code>
              , the
              <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-configexpansion-configexpansion.__exec" target="_self">
               <span>
                <code class="leafygreen-ui-1l06pbn">
                 __exec
                </code>
               </span>
              </a>
              block must be the only content in
the configuration file. The
              <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod">
               <code class="leafygreen-ui-1l06pbn">
                mongod
               </code>
              </a>
              /
              <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongos/#mongodb-binary-bin.mongos">
               <code class="leafygreen-ui-1l06pbn">
                mongos
               </code>
              </a>
              replaces the
configuration file contents with the
              <code class="leafygreen-ui-1l06pbn">
               yaml
              </code>
              retrieved from
the executed command.
             </p>
            </li>
           </ul>
          </div>
         </div>
        </td>
       </tr>
       <tr class="leafygreen-ui-15dvrnp">
        <td class="leafygreen-ui-1drjk7h">
         <div class="leafygreen-ui-1n4j8xf">
          <div>
           <code class="leafygreen-ui-1l06pbn">
            trim
           </code>
          </div>
         </div>
        </td>
        <td class="leafygreen-ui-1drjk7h">
         <div class="leafygreen-ui-1n4j8xf">
          <div>
           string
          </div>
         </div>
        </td>
        <td class="leafygreen-ui-1drjk7h">
         <div class="leafygreen-ui-1n4j8xf">
          <div>
           <em>
            Optional
           </em>
           Specify
           <code class="leafygreen-ui-1l06pbn">
            whitespace
           </code>
           to direct
           <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-configexpansion-configexpansion.__exec" target="_self">
            <span>
             <code class="leafygreen-ui-1l06pbn">
              __exec
             </code>
            </span>
           </a>
           to trim any leading or trailing whitespace, specifically
occurrences of
           <code class="leafygreen-ui-1l06pbn">
            " "
           </code>
           ,
           <code class="leafygreen-ui-1l06pbn">
            "\r"
           </code>
           ,
           <code class="leafygreen-ui-1l06pbn">
            "\n"
           </code>
           ,
           <code class="leafygreen-ui-1l06pbn">
            "\t"
           </code>
           ,
           <code class="leafygreen-ui-1l06pbn">
            "\v"
           </code>
           , and
           <code class="leafygreen-ui-1l06pbn">
            "\f"
           </code>
           . Defaults to
           <code class="leafygreen-ui-1l06pbn">
            none
           </code>
           , or no trimming.
          </div>
         </div>
        </td>
       </tr>
       <tr class="leafygreen-ui-15dvrnp">
        <td class="leafygreen-ui-1drjk7h">
         <div class="leafygreen-ui-1n4j8xf">
          <div>
           <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-expansion-exec-digest" target="_self">
            <span>
             digest
            </span>
           </a>
          </div>
         </div>
        </td>
        <td class="leafygreen-ui-1drjk7h">
         <div class="leafygreen-ui-1n4j8xf">
          <div>
           string
          </div>
         </div>
        </td>
        <td class="leafygreen-ui-1drjk7h">
         <div class="leafygreen-ui-1n4j8xf">
          <div>
           <span class="leafygreen-ui-1qnjd6d" id="std-label-expansion-exec-digest">
           </span>
           <p class="leafygreen-ui-1kp3ins">
            <em>
             Optional
            </em>
            . The SHA-256 digest of the expansion result.
           </p>
           <p class="leafygreen-ui-1kp3ins">
            If specified, you must also specify the
            <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-expansion-exec-digest-key" target="_self">
             <span>
              digest_key
             </span>
            </a>
           </p>
          </div>
         </div>
        </td>
       </tr>
       <tr class="leafygreen-ui-15dvrnp">
        <td class="leafygreen-ui-1drjk7h">
         <div class="leafygreen-ui-1n4j8xf">
          <div>
           <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-expansion-exec-digest-key" target="_self">
            <span>
             digest_key
            </span>
           </a>
          </div>
         </div>
        </td>
        <td class="leafygreen-ui-1drjk7h">
         <div class="leafygreen-ui-1n4j8xf">
          <div>
           string
          </div>
         </div>
        </td>
        <td class="leafygreen-ui-1drjk7h">
         <div class="leafygreen-ui-1n4j8xf">
          <div>
           <span class="leafygreen-ui-1qnjd6d" id="std-label-expansion-exec-digest-key">
           </span>
           <p class="leafygreen-ui-1kp3ins">
            <em>
             Optional
            </em>
            . The hexadecimal string representation of the
secret used to calculate the SHA-256
            <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-expansion-exec-digest" target="_self">
             <span>
              digest
              <!-- -->
              .
             </span>
            </a>
           </p>
           <p class="leafygreen-ui-1kp3ins">
            If specified, you must also specify the
            <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-expansion-exec-digest" target="_self">
             <span>
              digest
             </span>
            </a>
           </p>
          </div>
         </div>
        </td>
       </tr>
      </tbody>
     </table>
    </div>
    <div class="leafygreen-ui-15mdk4" role="note">
     <h2 class="leafygreen-ui-6n7b7d">
      Note
     </h2>
     <div class="leafygreen-ui-9mycqc">
      <ul class="leafygreen-ui-rioki0">
       <li class="leafygreen-ui-d7p7b6">
        <p class="leafygreen-ui-1kp3ins">
         If the configuration file includes the
         <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-configexpansion-configexpansion.__exec" target="_self">
          <span>
           <code class="leafygreen-ui-1l06pbn">
            __exec
           </code>
          </span>
         </a>
         expansion, on Linux/macOS, the write access to the configuration file must be
limited to the user running the
         <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod">
          <code class="leafygreen-ui-1l06pbn">
           mongod
          </code>
         </a>
         /
         <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongos/#mongodb-binary-bin.mongos">
          <code class="leafygreen-ui-1l06pbn">
           mongos
          </code>
         </a>
         process only.
        </p>
       </li>
       <li class="leafygreen-ui-d7p7b6">
        <p class="leafygreen-ui-1kp3ins">
         To enable parsing of the
         <code class="leafygreen-ui-1l06pbn">
          __exec
         </code>
         expansion directives, start
the
         <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod">
          <code class="leafygreen-ui-1l06pbn">
           mongod
          </code>
         </a>
         /
         <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongos/#mongodb-binary-bin.mongos">
          <code class="leafygreen-ui-1l06pbn">
           mongos
          </code>
         </a>
         with the
         <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#std-option-mongod.--configExpand">
          <code class="leafygreen-ui-1l06pbn">
           --configExpand "exec"
          </code>
         </a>
         option.
        </p>
       </li>
      </ul>
     </div>
    </div>
    <p class="leafygreen-ui-1kp3ins">
     For examples, see
     <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-expansion-directive-exec" target="_self">
      <span>
       Use the
       <code class="leafygreen-ui-1l06pbn">
        __exec
       </code>
       Expansion Directive
       <!-- -->
       .
      </span>
     </a>
    </p>
   </dd>
  </dl>
  <span class="leafygreen-ui-1qnjd6d" id="std-label-expansion-directive-output">
  </span>
 </section>
 <section>
  <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium">
   Output the Configuration File with Resolved Expansion Directive Values
   <a class="headerlink leafygreen-ui-1kepx47" href="#output-the-configuration-file-with-resolved-expansion-directive-values" title="Permalink to this heading">
    <svg aria-label="Link Icon" class="leafygreen-ui-a30zj9" fill="none" height="12" role="img" viewbox="0 0 16 16" width="12" xmlns="http://www.w3.org/2000/svg">
     <path d="M6.039 9.953a3.596 3.596 0 0 1-.327-.38l1.45-1.445a1.553 1.553 0 0 0 2.496.423l2.885-2.87a1.57 1.57 0 0 0 .01-2.213 1.553 1.553 0 0 0-2.203-.01l-.379.377A.995.995 0 0 1 8.56 3.83a1.005 1.005 0 0 1 .006-1.418l.38-.377a3.542 3.542 0 0 1 5.024.023 3.58 3.58 0 0 1-.022 5.047l-2.884 2.871a3.542 3.542 0 0 1-5.025-.022Z" fill="currentColor">
     </path>
     <path d="M9.961 6.047c.12.12.228.248.327.38l-1.45 1.445a1.553 1.553 0 0 0-2.496-.423l-2.885 2.87a1.57 1.57 0 0 0-.01 2.213 1.553 1.553 0 0 0 2.203.01l.379-.377a.995.995 0 0 1 1.411.006 1.005 1.005 0 0 1-.006 1.418l-.38.377a3.542 3.542 0 0 1-5.024-.023 3.58 3.58 0 0 1 .022-5.047l2.884-2.871a3.542 3.542 0 0 1 5.025.022Z" fill="currentColor">
     </path>
    </svg>
    <div class="css-1btu0w3 evvkmar0" id="output-the-configuration-file-with-resolved-expansion-directive-values">
    </div>
   </a>
  </h2>
  <p class="leafygreen-ui-1kp3ins">
   You can test the final output of a configuration file that specifies one
or more expansion directives by starting the
   <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod">
    <code class="leafygreen-ui-1l06pbn">
     mongod
    </code>
   </a>
   /
   <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongos/#mongodb-binary-bin.mongos">
    <code class="leafygreen-ui-1l06pbn">
     mongos
    </code>
   </a>
   with the
   <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#std-option-mongod.--outputConfig">
    <code class="leafygreen-ui-1l06pbn">
     --outputConfig
    </code>
   </a>
   option. A
   <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod">
    <code class="leafygreen-ui-1l06pbn">
     mongod
    </code>
   </a>
   /
   <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongos/#mongodb-binary-bin.mongos">
    <code class="leafygreen-ui-1l06pbn">
     mongos
    </code>
   </a>
   started with
   <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#std-option-mongod.--outputConfig">
    <code class="leafygreen-ui-1l06pbn">
     --outputConfig
    </code>
   </a>
   outputs
the resolved YAML configuration document to
   <code class="leafygreen-ui-1l06pbn">
    stdout
   </code>
   and halts. If any
expansion directive specified in the configuration file returns
additional expansion directives, the
   <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod">
    <code class="leafygreen-ui-1l06pbn">
     mongod
    </code>
   </a>
   /
   <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongos/#mongodb-binary-bin.mongos">
    <code class="leafygreen-ui-1l06pbn">
     mongos
    </code>
   </a>
   throws an error and
terminates.
  </p>
  <div class="leafygreen-ui-1sjx7ru" role="note">
   <h2 class="leafygreen-ui-29m78u">
    Warning
   </h2>
   <div class="leafygreen-ui-9mycqc">
    <p class="leafygreen-ui-1kp3ins">
     The
     <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#std-option-mongod.--outputConfig">
      <code class="leafygreen-ui-1l06pbn">
       --outputConfig
      </code>
     </a>
     option returns
the resolved values for any field using an expansion directive. This
includes any private or sensitive information previously obscured by
using an external source for the configuration option.
    </p>
   </div>
  </div>
  <p class="leafygreen-ui-1kp3ins">
   For example, the following configuration file
   <code class="leafygreen-ui-1l06pbn">
    mongod.conf
   </code>
   contains a
   <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-configexpansion-configexpansion.__rest" target="_self">
    <span>
     <code class="leafygreen-ui-1l06pbn">
      __rest
     </code>
    </span>
   </a>
   expansion
directive:
  </p>
  <script class="structured_data" type="application/ld+json">
   {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"storage:\n  dbPath: \"/var/lib/mongo\"\nsystemLog:\n  destination: file\n  path: \"/var/log/mongodb/mongod.log\"\nnet:\n  port:\n    __rest: \"https://mongoconf.example.net:8080/record/1\"\n    type: string","programmingLanguage":"YAML"}
  </script>
  <div class="css-16lmvu9">
   <div class="leafygreen-ui-196mwvg">
    <div class="leafygreen-ui-yzcs8i">
     <pre class="leafygreen-ui-11itue3" tabindex="-1"><code class="lg-highlight-hljs-light yaml leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx"><span class="lg-highlight-attr">storage:</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx">  <span class="lg-highlight-attr">dbPath:</span> <span class="lg-highlight-string">"/var/lib/mongo"</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"><span class="lg-highlight-attr">systemLog:</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx">  <span class="lg-highlight-attr">destination:</span> <span class="lg-highlight-string">file</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx">  <span class="lg-highlight-attr">path:</span> <span class="lg-highlight-string">"/var/log/mongodb/mongod.log"</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"><span class="lg-highlight-attr">net:</span></td></tr><tr class="leafygreen-ui-1wr1lm6"><td class="leafygreen-ui-7razhx">  <span class="lg-highlight-attr">port:</span></td></tr><tr class="leafygreen-ui-1wr1lm6"><td class="leafygreen-ui-7razhx">    <span class="lg-highlight-attr">__rest:</span> <span class="lg-highlight-string">"https://mongoconf.example.net:8080/record/1"</span></td></tr><tr class="leafygreen-ui-1wr1lm6"><td class="leafygreen-ui-7razhx">    <span class="lg-highlight-attr">type:</span> <span class="lg-highlight-string">string</span></td></tr></tbody></table></code></pre>
     <div class="leafygreen-ui-1bqcprk" data-testid="leafygreen-code-panel">
      <button aria-disabled="false" aria-label="Copy" class="leafygreen-ui-1c6zwke" data-testid="code_copy-button" tabindex="0">
       <div class="leafygreen-ui-xhlipt">
        <svg aria-label="Copy Icon" class="leafygreen-ui-1st74h4" height="16" role="img" viewbox="0 0 16 16" width="16">
         <path clip-rule="evenodd" d="M1 5.71428V10.2857C1 11.2325 1.76751 12 2.71429 12H5.75V7.10957C5.75 6.54414 5.97724 6.00244 6.38065 5.60623L8.67403 3.35381C8.77447 3.25516 8.88376 3.16757 9 3.09182V2.71429C9 1.76751 8.23249 1 7.28571 1H5.8V4.42857C5.8 5.13865 5.22437 5.71428 4.51429 5.71428H1ZM9 4.78571L7.25654 6.49804C7.24689 6.50752 7.23749 6.5172 7.22834 6.52708C7.22208 6.53383 7.21594 6.54068 7.20991 6.54762C7.07504 6.70295 7 6.90234 7 7.10957V7.79762H9H10.0095C10.4829 7.79762 10.8667 7.41386 10.8667 6.94047V4H10.1505C9.92587 4 9.7102 4.0882 9.54992 4.24562L9 4.78571ZM4.86667 1H4.15053C3.92587 1 3.7102 1.0882 3.54992 1.24562L1.25654 3.49804C1.09244 3.65921 1 3.87957 1 4.10957V4.79762H4.00952C4.48291 4.79762 4.86667 4.41386 4.86667 3.94047V1ZM7 12V8.71428H9H10.5143C11.2244 8.71428 11.8 8.13865 11.8 7.42857V4H13.2857C14.2325 4 15 4.76751 15 5.71429V13.2857C15 14.2325 14.2325 15 13.2857 15H8.71429C7.76751 15 7 14.2325 7 13.2857V12Z" fill="currentColor" fill-rule="evenodd">
         </path>
        </svg>
       </div>
      </button>
     </div>
    </div>
   </div>
  </div>
  <p class="leafygreen-ui-1kp3ins">
   The string recorded at the specified URL is
   <code class="leafygreen-ui-1l06pbn">
    20128
   </code>
  </p>
  <p class="leafygreen-ui-1kp3ins">
   If the configuration file includes the
   <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-configexpansion-configexpansion.__rest" target="_self">
    <span>
     <code class="leafygreen-ui-1l06pbn">
      __rest
     </code>
    </span>
   </a>
   expansion, on Linux/macOS, the read access to the configuration file must be limited
to the user running the
   <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod">
    <code class="leafygreen-ui-1l06pbn">
     mongod
    </code>
   </a>
   /
   <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongos/#mongodb-binary-bin.mongos">
    <code class="leafygreen-ui-1l06pbn">
     mongos
    </code>
   </a>
   process only.
  </p>
  <p class="leafygreen-ui-1kp3ins">
   Start the
   <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod">
    <code class="leafygreen-ui-1l06pbn">
     mongod
    </code>
   </a>
   with the
   <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#std-option-mongod.--configExpand">
    <code class="leafygreen-ui-1l06pbn">
     --configExpand "rest"
    </code>
   </a>
   and
   <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#std-option-mongod.--outputConfig">
    <code class="leafygreen-ui-1l06pbn">
     --outputConfig
    </code>
   </a>
   options:
  </p>
  <script class="structured_data" type="application/ld+json">
   {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"mongod -f mongod.conf --configExpand rest --outputConfig","programmingLanguage":"YAML"}
  </script>
  <div class="css-16lmvu9">
   <div class="leafygreen-ui-196mwvg">
    <div class="leafygreen-ui-yzcs8i">
     <pre class="leafygreen-ui-1q4bxgx" tabindex="-1"><code class="lg-highlight-hljs-light yaml leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx"><span class="lg-highlight-string">mongod</span> <span class="lg-highlight-string">-f</span> <span class="lg-highlight-string">mongod.conf</span> <span class="lg-highlight-string">--configExpand</span> <span class="lg-highlight-string">rest</span> <span class="lg-highlight-string">--outputConfig</span></td></tr></tbody></table></code></pre>
     <div class="leafygreen-ui-1bqcprk" data-testid="leafygreen-code-panel">
      <button aria-disabled="false" aria-label="Copy" class="leafygreen-ui-1c6zwke" data-testid="code_copy-button" tabindex="0">
       <div class="leafygreen-ui-xhlipt">
        <svg aria-label="Copy Icon" class="leafygreen-ui-1st74h4" height="16" role="img" viewbox="0 0 16 16" width="16">
         <path clip-rule="evenodd" d="M1 5.71428V10.2857C1 11.2325 1.76751 12 2.71429 12H5.75V7.10957C5.75 6.54414 5.97724 6.00244 6.38065 5.60623L8.67403 3.35381C8.77447 3.25516 8.88376 3.16757 9 3.09182V2.71429C9 1.76751 8.23249 1 7.28571 1H5.8V4.42857C5.8 5.13865 5.22437 5.71428 4.51429 5.71428H1ZM9 4.78571L7.25654 6.49804C7.24689 6.50752 7.23749 6.5172 7.22834 6.52708C7.22208 6.53383 7.21594 6.54068 7.20991 6.54762C7.07504 6.70295 7 6.90234 7 7.10957V7.79762H9H10.0095C10.4829 7.79762 10.8667 7.41386 10.8667 6.94047V4H10.1505C9.92587 4 9.7102 4.0882 9.54992 4.24562L9 4.78571ZM4.86667 1H4.15053C3.92587 1 3.7102 1.0882 3.54992 1.24562L1.25654 3.49804C1.09244 3.65921 1 3.87957 1 4.10957V4.79762H4.00952C4.48291 4.79762 4.86667 4.41386 4.86667 3.94047V1ZM7 12V8.71428H9H10.5143C11.2244 8.71428 11.8 8.13865 11.8 7.42857V4H13.2857C14.2325 4 15 4.76751 15 5.71429V13.2857C15 14.2325 14.2325 15 13.2857 15H8.71429C7.76751 15 7 14.2325 7 13.2857V12Z" fill="currentColor" fill-rule="evenodd">
         </path>
        </svg>
       </div>
      </button>
     </div>
    </div>
   </div>
  </div>
  <p class="leafygreen-ui-1kp3ins">
   The
   <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod">
    <code class="leafygreen-ui-1l06pbn">
     mongod
    </code>
   </a>
   outputs the following to
   <code class="leafygreen-ui-1l06pbn">
    stdout
   </code>
   before terminating:
  </p>
  <script class="structured_data" type="application/ld+json">
   {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"config: mongod.conf\nstorage:\n  dbPath: \"/var/lib/mongo\"\nsystemLog:\n  destination: file\n  path: \"/var/log/mongodb/mongod.log\"\nnet:\n  port: 20128\noutputConfig: true","programmingLanguage":"YAML"}
  </script>
  <div class="css-16lmvu9">
   <div class="leafygreen-ui-196mwvg">
    <div class="leafygreen-ui-yzcs8i">
     <pre class="leafygreen-ui-11itue3" tabindex="-1"><code class="lg-highlight-hljs-light yaml leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx"><span class="lg-highlight-attr">config:</span> <span class="lg-highlight-string">mongod.conf</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"><span class="lg-highlight-attr">storage:</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx">  <span class="lg-highlight-attr">dbPath:</span> <span class="lg-highlight-string">"/var/lib/mongo"</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"><span class="lg-highlight-attr">systemLog:</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx">  <span class="lg-highlight-attr">destination:</span> <span class="lg-highlight-string">file</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx">  <span class="lg-highlight-attr">path:</span> <span class="lg-highlight-string">"/var/log/mongodb/mongod.log"</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"><span class="lg-highlight-attr">net:</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx">  <span class="lg-highlight-attr">port:</span> <span class="lg-highlight-number">20128</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"><span class="lg-highlight-attr">outputConfig:</span> <span class="lg-highlight-literal">true</span></td></tr></tbody></table></code></pre>
     <div class="leafygreen-ui-1bqcprk" data-testid="leafygreen-code-panel">
      <button aria-disabled="false" aria-label="Copy" class="leafygreen-ui-1c6zwke" data-testid="code_copy-button" tabindex="0">
       <div class="leafygreen-ui-xhlipt">
        <svg aria-label="Copy Icon" class="leafygreen-ui-1st74h4" height="16" role="img" viewbox="0 0 16 16" width="16">
         <path clip-rule="evenodd" d="M1 5.71428V10.2857C1 11.2325 1.76751 12 2.71429 12H5.75V7.10957C5.75 6.54414 5.97724 6.00244 6.38065 5.60623L8.67403 3.35381C8.77447 3.25516 8.88376 3.16757 9 3.09182V2.71429C9 1.76751 8.23249 1 7.28571 1H5.8V4.42857C5.8 5.13865 5.22437 5.71428 4.51429 5.71428H1ZM9 4.78571L7.25654 6.49804C7.24689 6.50752 7.23749 6.5172 7.22834 6.52708C7.22208 6.53383 7.21594 6.54068 7.20991 6.54762C7.07504 6.70295 7 6.90234 7 7.10957V7.79762H9H10.0095C10.4829 7.79762 10.8667 7.41386 10.8667 6.94047V4H10.1505C9.92587 4 9.7102 4.0882 9.54992 4.24562L9 4.78571ZM4.86667 1H4.15053C3.92587 1 3.7102 1.0882 3.54992 1.24562L1.25654 3.49804C1.09244 3.65921 1 3.87957 1 4.10957V4.79762H4.00952C4.48291 4.79762 4.86667 4.41386 4.86667 3.94047V1ZM7 12V8.71428H9H10.5143C11.2244 8.71428 11.8 8.13865 11.8 7.42857V4H13.2857C14.2325 4 15 4.76751 15 5.71429V13.2857C15 14.2325 14.2325 15 13.2857 15H8.71429C7.76751 15 7 14.2325 7 13.2857V12Z" fill="currentColor" fill-rule="evenodd">
         </path>
        </svg>
       </div>
      </button>
     </div>
    </div>
   </div>
  </div>
 </section>
</section>
