Repository navigation
Conversation
…ories ansible-core 2.19 removed .ini from the default INVENTORY_IGNORE_EXTS list, but the "Using inventory directories and multiple inventory sources" section still lists .ini as ignored. The list also misses the other default entries (.swp, .rpm, .md, .txt, .rst). Show the current default list, link to the configuration reference, and add a note about the .ini change: older versions skip hosts.ini in an inventory directory without a warning, newer versions parse it. The note also says that setting inventory_ignore_extensions replaces the default list. Assisted-by: Claude Opus 5.5 Signed-off-by: YoungjuKim <[email protected]>
|
Thanks for your Ansible docs contribution! We talk about Ansible documentation on Matrix at #docs:ansible.im if you ever want to join us and chat about the docs! We meet on Matrix every Tuesday. See the Ansible calendar for meeting details. We welcome additions to our weekly agenda items too. You can add the |
|
|
||
| ~, .orig, .bak, .ini, .cfg, .retry, .pyc, .pyo | ||
| .pyc, .pyo, .swp, .bak, ~, .rpm, .md, .txt, .rst, .orig, .cfg, .retry | ||
|
|
There was a problem hiding this comment.
| In an inventory directory, executable files are treated as dynamic inventory sources and most other files as static sources. Files which end with any of the extensions in the `reject_exts <https://github.com/ansible/ansible/blob/d33bedc48fdd933b5abd65a77c081876298e2f07/lib/ansible/constants.py#L63>`_ list, along with ``.orig``, ``.cfg``, and ``.retry`` are ignored. |
There was a problem hiding this comment.
Thanks, applied in 47aca39. The suggestion was attached to the blank line 137 only, so committing it from the UI would have kept the old sentence and the code block. I replaced lines 132-137 with your sentence instead. I made two small edits: a comma after .retry to close the "along with" clause, and REJECT_EXTS as the link text to match the constant name in constants.py. Pinning the commit makes sense, since the constant is on L62 on devel now.
| .pyc, .pyo, .swp, .bak, ~, .rpm, .md, .txt, .rst, .orig, .cfg, .retry | ||
|
|
||
| You can replace this list with your own selection by configuring an ``inventory_ignore_extensions`` list in ``ansible.cfg``, or setting the :envvar:`ANSIBLE_INVENTORY_IGNORE` environment variable. The value in either case must be a comma-separated list of patterns, as shown above. | ||
| You can replace this list with your own selection by configuring an ``inventory_ignore_extensions`` list in ``ansible.cfg``, or setting the :envvar:`ANSIBLE_INVENTORY_IGNORE` environment variable. The value in either case must be a comma-separated list of patterns, as shown above. See :ref:`INVENTORY_IGNORE_EXTS` in the configuration reference. |
There was a problem hiding this comment.
| You can replace this list with your own selection by configuring an ``inventory_ignore_extensions`` list in ``ansible.cfg``, or setting the :envvar:`ANSIBLE_INVENTORY_IGNORE` environment variable. The value in either case must be a comma-separated list of patterns, as shown above. See :ref:`INVENTORY_IGNORE_EXTS` in the configuration reference. | |
| You can replace this list with your own selection by configuring an ``inventory_ignore_extensions`` list in ``ansible.cfg``, or setting the :envvar:`ANSIBLE_INVENTORY_IGNORE` environment variable. The value in either case must be a comma-separated list of patterns. See :ref:`INVENTORY_IGNORE_EXTS` in the configuration reference. |
|
|
||
| .. note:: | ||
|
|
||
| Before ``ansible-core`` 2.19, ``.ini`` was also in the default list, so a file such as ``inventory/hosts.ini`` was skipped without a warning when you passed the directory with ``-i``. Starting with ``ansible-core`` 2.19, ``.ini`` files in an inventory directory are parsed as inventory sources. If the directory also holds ``.ini`` files that are not inventory, for example the configuration file of an inventory script, Ansible now tries to parse them as inventory, which can produce ``Unable to parse ... as an inventory source`` warnings. To skip them, set ``inventory_ignore_extensions`` to the list above plus ``.ini``. |
There was a problem hiding this comment.
| Before ``ansible-core`` 2.19, ``.ini`` was also in the default list, so a file such as ``inventory/hosts.ini`` was skipped without a warning when you passed the directory with ``-i``. Starting with ``ansible-core`` 2.19, ``.ini`` files in an inventory directory are parsed as inventory sources. If the directory also holds ``.ini`` files that are not inventory, for example the configuration file of an inventory script, Ansible now tries to parse them as inventory, which can produce ``Unable to parse ... as an inventory source`` warnings. To skip them, set ``inventory_ignore_extensions`` to the list above plus ``.ini``. | |
| Before ``ansible-core`` 2.19, ``.ini`` was also in the default list, so a file such as ``inventory/hosts.ini`` was skipped without a warning when you passed the directory with ``-i``. Starting with ``ansible-core`` 2.19, ``.ini`` files in an inventory directory are parsed as inventory sources. If the directory also holds ``.ini`` files that are not inventory, for example the configuration file of an inventory script, Ansible now tries to parse them as inventory, which can produce ``Unable to parse ... as an inventory source`` warnings. To skip them, set ``inventory_ignore_extensions`` to the default list plus ``.ini``. |
Address review feedback: describe the default ignored extensions as the REJECT_EXTS list plus .orig, .cfg and .retry, with a link to the source, instead of copying the list. Drop "as shown above" now that the list is gone, and say "the default list" in the note about .ini. Assisted-by: Claude Opus 5.5 Signed-off-by: YoungjuKim <[email protected]>
|
@Akasurde I've applied all three suggestions in 47aca39. Could you take another look when you have time? Thanks! I also checked the note against real behavior, with a directory containing
Assisted-by: Claude |
SUMMARY
The "Using inventory directories and multiple inventory sources" section of the dynamic inventory guide lists the file extensions that Ansible ignores in an inventory directory:
This list is out of date:
.inifrom the defaultINVENTORY_IGNORE_EXTS(changelog: "INVENTORY_IGNORE_EXTS config, removedinifrom the default list ..."). The default inlib/ansible/config/base.ymlis nowREJECT_EXTS + ['.orig', '.cfg', '.retry'].REJECT_EXTS(.swp,.rpm,.md,.txt,.rst).This PR:
INVENTORY_IGNORE_EXTSentry in the configuration reference;.inichange. Before 2.19,inventory/hosts.iniwas skipped without any warning when the directory was passed with-i. Since 2.19 it is read, and a non-inventory.inifile in the directory (for example the configuration file of an inventory script) is now parsed and produces warnings. The note also says that settinginventory_ignore_extensionsreplaces the default list instead of adding to it.ISSUE TYPE
COMPONENT NAME
docs/docsite/rst/inventory_guide/intro_dynamic_inventory.rst
ADDITIONAL INFORMATION
I checked the behavior with ansible-core 2.16.3 (Ubuntu 24.04 package) and with ansible-core 2.21.5 (run from the
v2.21.5tag), Python 3.12, using the same directory:With 2.16.3 the
webgroup is missing and nothing is printed abouthosts.ini.An inventory script next to its own
.iniconfiguration file (myinv.py+myinv.inicontaining[myinv]andregions = us-east-1) is silent with 2.16.3. With 2.21.5 it printsFailed to parse inventory with 'ini' plugin ... Expected key=value host variable assignment, got: us-east-1andUnable to parse .../myinv.ini as an inventory source, and adds an emptymyinvgroup.With
ANSIBLE_INVENTORY_IGNORE=.inion 2.21.5,hosts.iniis skipped but anotes.txtfile in the same directory is parsed, so the setting replaces the default list. That is why the note says "the list above plus.ini".I could not build the docs locally. The new
:ref:target,INVENTORY_IGNORE_EXTS, is already used inintro_inventory.rst.If you prefer, I can also add a short entry about this change to the ansible-core 2.19 porting guide, which does not mention it.
This change was drafted with AI assistance and reviewed by me.
🤖 Generated with Claude Code