Giter Club home page Giter Club logo

ansible_xls_to_facts's Introduction

Ansible module which imports an Excel spreadsheet to Ansible facts.

Each sheet is represented by "spreadsheet_{sheet_name}" in Ansible. The column headers of each row in the sheet are converted to variable names, and values are populated for each row.

Copy to the library path as specified in your ansible.cfg file.

Requires the openpyxl Python module on the Ansible host.

  • Default behavior is set for data_only to allow extracting values only from formulae

Install with PIP:

sudo pip install openpyxl

ansible_xls_to_facts's People

Contributors

kristopher-vensel-tm avatar mamullen13316 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ansible_xls_to_facts's Issues

Module failure

Hi Matt,

Thank you for your module.

I followed the steps provided in the READ.me and Python files but unfortunately, I am getting the following error:

localhost | FAILED! => {
"changed": false,
"failed": true,
"module_stderr": "OpenSSH_6.6.1, OpenSSL 1.0.1e-fips 11 Feb 2013\r\ndebug1: Reading configuration data /etc/ssh/ssh_config\r\ndebug1: /etc/ssh/ssh_config line 56: Applying options for *\r\ndebug1: auto-mux: Trying existing master\r\ndebug2: fd 3 setting O_NONBLOCK\r\ndebug2: mux_client_hello_exchange: master version 4\r\ndebug3: mux_client_forwards: request forwardings: 0 local, 0 remote\r\ndebug3: mux_client_request_session: entering\r\ndebug3: mux_client_request_alive: entering\r\ndebug3: mux_client_request_alive: done pid = 12826\r\ndebug3: mux_client_request_session: session request sent\r\ndebug1: mux_client_request_session: master session id: 2\r\ndebug3: mux_client_read_packet: read header failed: Broken pipe\r\ndebug2: Received exit status from master 0\r\nShared connection to localhost closed.\r\n",
"module_stdout": "Traceback (most recent call last):\r\n File "/tmp/ansible_Z013Jt/ansible_module_xls_to_facts.py", line 144, in \r\n main()\r\n File "/tmp/ansible_Z013Jt/ansible_module_xls_to_facts.py", line 134, in main\r\n code, response = read_xls_dict(module.params["src"])\r\n File "/tmp/ansible_Z013Jt/ansible_module_xls_to_facts.py", line 103, in read_xls_dict\r\n wb = openpyxl.load_workbook(input_file)\r\n File "/usr/lib/python2.7/site-packages/openpyxl/reader/excel.py", line 171, in load_workbook\r\n archive = _validate_archive(filename)\r\n File "/usr/lib/python2.7/site-packages/openpyxl/reader/excel.py", line 121, in _validate_archive\r\n archive = ZipFile(f, 'r', ZIP_DEFLATED)\r\n File "/usr/lib64/python2.7/zipfile.py", line 766, in init\r\n self._RealGetContents()\r\n File "/usr/lib64/python2.7/zipfile.py", line 807, in _RealGetContents\r\n raise BadZipfile, "File is not a zip file"\r\nzipfile.BadZipfile: File is not a zip file\r\n",
"msg": "MODULE FAILURE",
"rc": 0
}

The verbose output can be found here https://pastebin.com/mpFp17K1
I created another spreadsheet and renamed to 'example.xlsx' but the result was the same. The file is not a zip file in both cases:

[ansible@devops ansible_xls_to_facts]$ file example.xlsx
example.xlsx: Microsoft Excel 2007+

I would be grateful if you could guide me on this issue.

Many thanks

Best regards

Iban

xls_to_facts yaml

Hi,

i am following your video how to build evpn by getting information from XLS.

Appreciate if you are able to share yaml to call xls_to_facts module created on your github

i am trying the yaml as below but it still doesn;t work

  • name: Import host-specific facts from a XLS file
    xls_to_facts:
    src: "evpn_config_template.xlsx"

  • name: Render switch global configuration commands
    template:
    src: spine_global.j2
    dest: "{{configuration_file.type}}"

Thanks,
Best Regards,
Yansen

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.