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

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

Unable to add new parameters to an existing firewall Policy #265

Closed RachnaDodia closed 5 days ago

RachnaDodia commented 1 year ago

Hi Team Need an urgent help on fortigate collection.

I am able to create a new policy and overwrite a existing policy by passing the relevant parameters.

But if there is an existing polcy as below-

"Policyid- 10 Source- host1 destination- host 2,host 3, host 4 service-ftp action- accept"

I want to add "host 5" to the destination address list, but for that I need to overwrite the existing policy by passing all the parameters again to the module i.e i have to pass "host 2,host 3, host 4,host5"

I want to avoid passing the parameters again which already exists.

Any solution or workaround for this ?

JieX19 commented 1 year ago

Hi @RachnaDodia,

You can add one or more items to an existing list by using the member_path feature, this is the doc for the feature https://ansible-galaxy-fortios-docs.readthedocs.io/en/latest/faq.html#how-to-use-the-member-operation-to-add-an-element-in-an-object

Below is an example of adding two more elements to the dstintf.

  - name: Update Policy 2
    fortios_firewall_policy:
      enable_log: True
      vdom:  "{{ vdom }}"
      member_state: "present"
      member_path: "dstintf:name"
      firewall_policy:
       policyid: "2"
       dstintf:
        - name: "port7"
        - name: "port8"