- CheckMates
- :
- Products
- :
- Developers
- :
- Ansible
- :
- Re: Remove all members from object
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page
Are you a member of CheckMates?
×- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Remove all members from object
Hi!
I want to remove all members of an object and I could really need some help atm.
To create the object I have the following task (example application site groups)
- name: set application groups
check_point.mgmt.cp_mgmt_application_site_group:
name: "{{ item.Name }}"
comments: "{{ item.Comments }}"
members: "{{ item.Members }}"
with_items: "{{ cp_application_groups }}"
loop: "{{ cp_application_groups if cp_application_groups is iterable else []}}"
A creation was made with the following object
- Name: custom-group
Comments: Custom test
Members:
- File Storage and Sharing
When removing the entry of the members or replace it with an "- []", I get the following error message "Requested object [] not found"
- Name: custom-group
Comments: Custom test
Members:
- [] # or remove it entirely
Can someone help me on this?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
In general, with Ansible, you describe the desired state, not the steps required to get to that state.
This creates a few issues when you're trying to manage objects with Ansible that were not created via Ansible.
The only way to use Ansible to remove items from an existing group is:
- Describe the group as it exists now in an Ansible playbook and run it
- Describe the group as you would like it to be in the Ansible playbook and run it
Otherwise, you will need to use a different mechanism to remove items from the group (e.g. SmartConsole, the API).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hey!
The objects have been created via ansible and I want to change them now. Therefore I have an object which had members, and I just wanna clear out all members now.
Desired state yesterday:
- Name: custom-group
Comments: Custom test
Members:
- File Storage and Sharing
Desired state today:
- Name: custom-group
Comments: Custom test
The problem is, not mentioning "Members" does not delete them, but does not touch any members in the group. Is there no way to remove all members from a group via ansible?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Was the group itself created via Ansible? Yes or no.
If the group wasn't created by Ansible, then it may not be possible to remove items from it even if the items were added via Ansible later.
Paging @chkp-royl to clarify.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Yes, the group itself was created via ansible
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Has the group been modified by anything outside of Ansible?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
No. I am only refering to ansible created and modified, and system objects. No "manual" objects via Smart Console.
