You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I would like to point out in the README.MD That you don't have to live with an SpreadSheet as your Inventory! And that I absolutely don't encourage you to do so XD.
To clarify this, I would like to add a Section that explains how to use the [ansible-inventory tool/command)(https://docs.ansible.com/ansible/latest/cli/ansible-inventory.html) to convert into a regular Inventory file.
The text was updated successfully, but these errors were encountered:
There is no such Option in the Inventory itself.
What you can do is use the ansible-inventory command, that comes with Ansible, to generate either a --yaml, --toml or --json version of your Excel inventory.
Sadly the ansible-inventory comand does not support exporting into the "ini style" hosts file format.
But you can basically generate whatever format you want with some "jinja" magic and a Playbook that looks like this:
---
- hosts: localhostgather_facts: Falsevars:
ini_inventory_output_default: ./ini_inventory_hostsvars_prompt:
- name: "ini_inventory_output"prompt: "output path of ini sytle inventory"default: "{{ ini_inventory_output_default }}"private: Falsetasks:
- name: inventory filelocal_action:
module: copycontent: | {% for group in groups %} {% if group != 'all' %} [{{ group }}] {% for host in groups[group] %} {{ host }} {% endfor %} {% endif %} {% endfor %}dest: "{{ ini_inventory_output }}"run_once: True
You would then run this ansible-playbook -i xlsx_inventory.py ini_inventory.yml
You can expand the Jinja Template to include whatever variable is set via the xlsx_inventory.
If you attach an anonymized sample of your Excel Sheet and an Example of what the Hosts file should look like, I can help you to come up with a Playbook/Template that suits your needs :)
I would like to point out in the README.MD That you don't have to live with an SpreadSheet as your Inventory! And that I absolutely don't encourage you to do so XD.
To clarify this, I would like to add a Section that explains how to use the [
ansible-inventory
tool/command)(https://docs.ansible.com/ansible/latest/cli/ansible-inventory.html) to convert into a regular Inventory file.The text was updated successfully, but these errors were encountered: