fortinet-ansible-dev / ansible-galaxy-fortios-collection

GNU General Public License v3.0
84 stars 48 forks source link

Adding new secondary ip instead of replacing #341

Open Tiguespa opened 1 month ago

Tiguespa commented 1 month ago

Hello

I've noticed that if i want to implement a new secondary ip via playbook and the module system_interface, it will always change by the new one instead of adding .

Is there anything that i can do to just add ?

tasks:

Thanks

MaxxLiu22 commented 1 month ago

Hi @Tiguespa ,

Thank you for your question. Our Ansible module is designed to manage the entire object and ensure consistency between scripts and actual configurations. However, we do offer a member operation feature that allows for adding or deleting elements from an existing block. Please find an example below. Do let us know if this does not meet your requirements.

  tasks:
  - name: Configure interfaces.
    fortios_system_interface:
      vdom: root
      state: present
      member_state: present  # present for adding and updating, absent for deleting
      member_path: secondaryip:id # main key for locating the element
      system_interface:
        vdom: root
        allowaccess:
        - ping
        - ssh
        - https
        ip: 1.2.56.4/24
        name: test234
        type: vlan
        secondary_IP: "enable"
        vlanid: 766
        interface: port2
        secondaryip:
          -
            ip: "2.3.4.6/24"
            id: "2"

Thanks, Maxx

Tiguespa commented 1 month ago

Thanks you Maxx, it seems it does exactly what i wanted !

I didn't understand member_state/path allowed to do that :)