Coder Social home page Coder Social logo

Comments (7)

JieX19 avatar JieX19 commented on August 23, 2024

@ricewu2020,

Thanks for your question! At this moment, the backend API is defined this way and it would be backwards incompatible change to switch from taking a list of objects to a list of strings. I will bring up this improvement internally.

from ansible-galaxy-fortios-collection.

ricewu2020 avatar ricewu2020 commented on August 23, 2024

@JieX19 Thanks for the reply! What you mean is that the API structure (fortiosapi) on Fortigate is written like that? For the well-working "fortios_ipv4_policy" module to accept a list of strings, are you aware what kind of API is being used by Fortigate? I'm still new to these automation stuff. The source code seems to be using the fortios python module. To accept a list of strings will be truly helpful when we have a large number of entries in a csv spreadsheet to be pushed to Fortigate :)

from ansible-galaxy-fortios-collection.

JieX19 avatar JieX19 commented on August 23, 2024

@ricewu2020

It's true the python module is triggered while processing the YAMLs, but it's actually the backend APIs to do the CRUD operations. Fortiosapi communicates with fortigate devices through the http-based APIs, which are shared by both the both fortigate UI and ansible modules.

from ansible-galaxy-fortios-collection.

ricewu2020 avatar ricewu2020 commented on August 23, 2024

@JieX19 Is it possible that what I requested can be modified shortly by accepting a list of strings? Otherwise to achieve real automation with csv input file, these httpapi based ansible modules can't be used actually. From client's side, it's quite common and user-friendly to prepare all inputs in a csv file first and then loaded to a playbook. A list of strings can't be avoided.
If it is possible, normally how long does it take to modify the API? Thanks.

from ansible-galaxy-fortios-collection.

chillancezen avatar chillancezen commented on August 23, 2024

hello @ricewu2020 ,

we realized it's very hard for API team to modify current logic basing on our requirement.
we decide to work this issue around by processing input content ourselves.
could you try Ansible native data processing methods:

here is an example of mine:

$cat fortios_firewall_addrgrp.yml
- hosts: fortigate03
  connection: httpapi
  collections:
  - fortinet.fortios
  vars:
   vdom: "root"
   ansible_httpapi_use_ssl: no
   ansible_httpapi_validate_certs: no
   ansible_httpapi_port: 80
   #demo_input_path: './my_datasource'
   #demo_input: "{{ lookup( 'file', demo_input_path) }}"
   demo_input: 'login.microsoftonline.com, login.microsoft.com, login.windows.net'
   demo_members: []
  tasks:
   - name: 'process input content'
     set_fact:
        demo_members: "{{ demo_members + [{'name': item.strip(' ')}] }}"
     with_items:
        - "{{demo_input.split(',')}}"

   - debug:
      var: demo_members

   - name: Configure Firewall Schedule Recurring
     fortios_firewall_addrgrp:
        vdom:  "{{ vdom }}"
        state: "present"
        firewall_addrgrp:
            name: "firwalladdressgroup0"
            comment: 'created via Ansible'
            visibility: 'enable'
            member: "{{ demo_members }}"

from ansible-galaxy-fortios-collection.

chillancezen avatar chillancezen commented on August 23, 2024

Ansible playbook is flexible enough to process data in all ways.
the syntax here is much like python/jinja2, so using python's native library is supposed to be ok.

from ansible-galaxy-fortios-collection.

chillancezen avatar chillancezen commented on August 23, 2024

@ricewu2020 hope you are doing fine and getting this issue resolved.

I mark this issue closed. you can feel free to reopen if you need further support from us.

thanks,
Link.

from ansible-galaxy-fortios-collection.

Related Issues (20)

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.