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

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

fortios_user_group deletes the whole group. #161

Closed kar0v closed 2 years ago

kar0v commented 2 years ago

Hello, I'm trying to create a certain user and add that user to a few groups, however what the fortios_user_group does is it deletes the whole group and creates it again, then adds only that one user.

This was done on FortiGate100E Firmware v6.4.7 build 1911(GA)

`---

JieX19 commented 2 years ago

Hi @kar0v

FortiOS modules have a functionality called member_operation, which allows to add or delete a member from a list.

https://ansible-galaxy-fortios-docs.readthedocs.io/en/latest/gen/fortios_user_group.html https://ansible-galaxy-fortios-docs.readthedocs.io/en/latest/gen/fortios_user_group.html

Using member_path and member_state (present/absent) to do the task.

kar0v commented 2 years ago

Thank you for your reply. There is no mention on how to use member_path & member state in the documentation. When I tried to use member_state it was required to use member_path as well. I was unable to locate any examples for member_path & member_state as well. Where can I see more information about the member_path option?

Raimond56 commented 2 years ago

Hey, Use this documentation: https://ansible-galaxy-fortios-docs.readthedocs.io/en/galaxy-2.1.3/gen/fortios_user_group.html It shows member paths where it can be used. So in your case you have to use member:name

JieX19 commented 2 years ago

Hi @kar0v

Here's an example of adding a user 'localuser1' to a group 'foogrp'.

tasks:
  - name: Add a user to a group
    fortios_user_group:
      vdom: "{{ vdom }}"
      state: present
      member_state: present
      member_path: member:name
      user_group:
        member:
          - name: userlocal1
        name: foogrp

Before executing the task, there's only one memeber 'guest' in this group.

This is the result after executing the task:

result

Let me know if you have any questions.

JieX19 commented 2 years ago

Hi, @kar0v I'm closing this issue due to lack of response. Feel free to open an issue if there're any issues.

britel-chaimaa20 commented 5 months ago

Thanks @JieX19 for the member_path clarification. That works perfectly!!