<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Ansible automation module host deletion in Ansible</title>
    <link>https://community.checkpoint.com/t5/Ansible/Ansible-automation-module-host-deletion/m-p/78301#M275</link>
    <description>&lt;P&gt;The host I am trying to delete was added by the ansible playbook to add host using the cp_mgmt_host library. This was set by setting the value of the variable "State" to "Present". I am now trying to delete the same host as a test to see how to do this via Ansible. So I am using the same&amp;nbsp;cp_mgmt_host library and setting the "State" parameter to "absent" to delete it. The host I have added is part of 2 groups and I am trying to delete it and the message I am getting is that these objects belong to 2 groups. Below is the message I am getting&lt;/P&gt;&lt;P&gt;atal: [x.x.x.x]: FAILED! =&amp;gt; {&lt;BR /&gt;"changed": false,&lt;BR /&gt;"invocation": {&lt;BR /&gt;"module_args": {&lt;BR /&gt;"auto_publish_session": true,&lt;BR /&gt;"color": null,&lt;BR /&gt;"comments": null,&lt;BR /&gt;"details_level": null,&lt;BR /&gt;"groups": null,&lt;BR /&gt;"host_servers": null,&lt;BR /&gt;"ignore_errors": null,&lt;BR /&gt;"ignore_warnings": null,&lt;BR /&gt;"interfaces": null,&lt;BR /&gt;"ip_address": null,&lt;BR /&gt;"ipv4_address": null,&lt;BR /&gt;"ipv6_address": null,&lt;BR /&gt;"name": "TEST123",&lt;BR /&gt;"nat_settings": null,&lt;BR /&gt;"state": "absent",&lt;BR /&gt;"tags": null,&lt;BR /&gt;"version": null,&lt;BR /&gt;"wait_for_task": true&lt;BR /&gt;}&lt;BR /&gt;},&lt;BR /&gt;"msg": {&lt;BR /&gt;"code": "err_validation_failed",&lt;BR /&gt;"message": "Validation failed with 1 warning",&lt;BR /&gt;"warnings": [&lt;BR /&gt;{&lt;BR /&gt;"message": "Object TEST123 is used by the following objects: Domain-xxxxx-Group, OS-xxxxxxx-Server-Group"&lt;BR /&gt;}&lt;BR /&gt;]&lt;BR /&gt;}&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;Do I need to first find out what groups the host belongs to and take it out from the groups and then delete it? If I have to take it out of groups do I use the cp_mgmtgroup library and does have any example if they have used it as I am concerned that I do not want to delete the group by mistake.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
    <pubDate>Sat, 14 Mar 2020 16:51:58 GMT</pubDate>
    <dc:creator>rkcp</dc:creator>
    <dc:date>2020-03-14T16:51:58Z</dc:date>
    <item>
      <title>Ansible automation module host deletion</title>
      <link>https://community.checkpoint.com/t5/Ansible/Ansible-automation-module-host-deletion/m-p/77377#M269</link>
      <description>&lt;P&gt;Hi All&lt;/P&gt;&lt;P&gt;I am trying to do automation using Ansible(cp_mgmt_host) and am running into an issue with a call to delete a host. I am getting an error that the object I am trying to delete is part of some other groups. I have set the&amp;nbsp; ignore_errors and ignore_warnings&amp;nbsp;paramets to true in the cp_mgmt_host function so that the script can run if this condition is met. I am unable to move past because of this. Does the host need to be removed from the group first and if yes, I do not see that as an option in the&amp;nbsp;cp_mgmt_group call?&amp;nbsp; I am getting the below. I am trying to delete the object TESTHOST&lt;/P&gt;&lt;P&gt;"msg": {&lt;BR /&gt;"code": "err_validation_failed",&lt;BR /&gt;"message": "Validation failed with 1 warning",&lt;BR /&gt;"warnings": [&lt;BR /&gt;{&lt;BR /&gt;"message": "Object TESTHOST is used by the following objects: xxxxxxxx, yyyyyyyy"&lt;/P&gt;&lt;P&gt;Any help would be appreciated.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Fri, 06 Mar 2020 01:06:52 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/Ansible/Ansible-automation-module-host-deletion/m-p/77377#M269</guid>
      <dc:creator>rkcp</dc:creator>
      <dc:date>2020-03-06T01:06:52Z</dc:date>
    </item>
    <item>
      <title>Re: Ansible automation module host deletion</title>
      <link>https://community.checkpoint.com/t5/Ansible/Ansible-automation-module-host-deletion/m-p/77530#M270</link>
      <description>The way Ansible works is the entire configuration you wish to work with must be defined in your Ansible playbook.&lt;BR /&gt;The way you delete something from the configuration is to modify the playbook and re-execute it.&lt;BR /&gt;As such, there is no explicit "delete" command in Ansible.&lt;BR /&gt;&lt;BR /&gt;Which means to delete the object from the group in Ansible, you'd have to define the group as it exists in Ansible, run the playbook, remove the host from the group in the playbook.&lt;BR /&gt;&lt;BR /&gt;Of course, this assumes that's the only dependency with that particular object.&lt;BR /&gt;There may be others, and to resolve them in Ansible, you'd have to go through a similar process.</description>
      <pubDate>Sat, 07 Mar 2020 00:43:31 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/Ansible/Ansible-automation-module-host-deletion/m-p/77530#M270</guid>
      <dc:creator>PhoneBoy</dc:creator>
      <dc:date>2020-03-07T00:43:31Z</dc:date>
    </item>
    <item>
      <title>Re: Ansible automation module host deletion</title>
      <link>https://community.checkpoint.com/t5/Ansible/Ansible-automation-module-host-deletion/m-p/77533#M271</link>
      <description>&lt;P&gt;Thanks Phoneboy. Let me explain further. I am using the cp_mgmt_host task of the Checkpoint ansible module to delete the host. One of the parameters it takes is "State" and the possible values are "Present" or "Absent". Present for addition and Absent for deletion. In addition, there are 2 other parameters "ignore_errors" and "ignore_warnings" which can be true or false.&lt;/P&gt;&lt;P&gt;I am doing the below in my playbook&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&amp;nbsp;- name: delete-host&lt;BR /&gt;&amp;nbsp; &amp;nbsp; cp_mgmt_host:&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; name: TESTHOST&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ignore_errors: true&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ignore_warnings:&amp;nbsp;true&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;state: absent&lt;/P&gt;&lt;P&gt;&amp;nbsp;Per the documentation, this is what is needed to delete the host and ignore any warnings or errors but I am unable to delete as the host is a member of a&amp;nbsp; group object. My understanding from the documentation is that having ignore_errors set to true and state to "Absent" the host should be deleted.&lt;/P&gt;&lt;P&gt;What am I missing?&lt;/P&gt;</description>
      <pubDate>Sat, 07 Mar 2020 02:39:25 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/Ansible/Ansible-automation-module-host-deletion/m-p/77533#M271</guid>
      <dc:creator>rkcp</dc:creator>
      <dc:date>2020-03-07T02:39:25Z</dc:date>
    </item>
    <item>
      <title>Re: Ansible automation module host deletion</title>
      <link>https://community.checkpoint.com/t5/Ansible/Ansible-automation-module-host-deletion/m-p/77537#M272</link>
      <description>Ignore Errors or Ignore Warnings will not overcome the requirement to remove all references to the object in groups or other objects before you can remove it.&lt;BR /&gt;ThIs applies whether you're using Ansible or not.&lt;BR /&gt;&lt;BR /&gt;My guess is you are working with an object that was not defined by your Ansible playbook to begin with.&lt;BR /&gt;Ansible can only remove objects where Ansible was used to create the object along with all the objects that might depend on it (e.g. groups).&lt;BR /&gt;That means either defining all those dependencies in your playbook or removing the dependencies outside Ansible.&lt;BR /&gt;</description>
      <pubDate>Sat, 07 Mar 2020 07:11:05 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/Ansible/Ansible-automation-module-host-deletion/m-p/77537#M272</guid>
      <dc:creator>PhoneBoy</dc:creator>
      <dc:date>2020-03-07T07:11:05Z</dc:date>
    </item>
    <item>
      <title>Re: Ansible automation module host deletion</title>
      <link>https://community.checkpoint.com/t5/Ansible/Ansible-automation-module-host-deletion/m-p/78301#M275</link>
      <description>&lt;P&gt;The host I am trying to delete was added by the ansible playbook to add host using the cp_mgmt_host library. This was set by setting the value of the variable "State" to "Present". I am now trying to delete the same host as a test to see how to do this via Ansible. So I am using the same&amp;nbsp;cp_mgmt_host library and setting the "State" parameter to "absent" to delete it. The host I have added is part of 2 groups and I am trying to delete it and the message I am getting is that these objects belong to 2 groups. Below is the message I am getting&lt;/P&gt;&lt;P&gt;atal: [x.x.x.x]: FAILED! =&amp;gt; {&lt;BR /&gt;"changed": false,&lt;BR /&gt;"invocation": {&lt;BR /&gt;"module_args": {&lt;BR /&gt;"auto_publish_session": true,&lt;BR /&gt;"color": null,&lt;BR /&gt;"comments": null,&lt;BR /&gt;"details_level": null,&lt;BR /&gt;"groups": null,&lt;BR /&gt;"host_servers": null,&lt;BR /&gt;"ignore_errors": null,&lt;BR /&gt;"ignore_warnings": null,&lt;BR /&gt;"interfaces": null,&lt;BR /&gt;"ip_address": null,&lt;BR /&gt;"ipv4_address": null,&lt;BR /&gt;"ipv6_address": null,&lt;BR /&gt;"name": "TEST123",&lt;BR /&gt;"nat_settings": null,&lt;BR /&gt;"state": "absent",&lt;BR /&gt;"tags": null,&lt;BR /&gt;"version": null,&lt;BR /&gt;"wait_for_task": true&lt;BR /&gt;}&lt;BR /&gt;},&lt;BR /&gt;"msg": {&lt;BR /&gt;"code": "err_validation_failed",&lt;BR /&gt;"message": "Validation failed with 1 warning",&lt;BR /&gt;"warnings": [&lt;BR /&gt;{&lt;BR /&gt;"message": "Object TEST123 is used by the following objects: Domain-xxxxx-Group, OS-xxxxxxx-Server-Group"&lt;BR /&gt;}&lt;BR /&gt;]&lt;BR /&gt;}&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;Do I need to first find out what groups the host belongs to and take it out from the groups and then delete it? If I have to take it out of groups do I use the cp_mgmtgroup library and does have any example if they have used it as I am concerned that I do not want to delete the group by mistake.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Sat, 14 Mar 2020 16:51:58 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/Ansible/Ansible-automation-module-host-deletion/m-p/78301#M275</guid>
      <dc:creator>rkcp</dc:creator>
      <dc:date>2020-03-14T16:51:58Z</dc:date>
    </item>
    <item>
      <title>Re: Ansible automation module host deletion</title>
      <link>https://community.checkpoint.com/t5/Ansible/Ansible-automation-module-host-deletion/m-p/78316#M276</link>
      <description>You can either remove the object from the groups outside of Ansible OR define the groups in Ansible as they exist currently on your management station with the exception of the object you wish to remove.&lt;BR /&gt;Either approach will work.&lt;BR /&gt;You will not be able to delete the object in Ansible—or via any other mechanism—until you do that.&lt;BR /&gt;</description>
      <pubDate>Sat, 14 Mar 2020 23:03:22 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/Ansible/Ansible-automation-module-host-deletion/m-p/78316#M276</guid>
      <dc:creator>PhoneBoy</dc:creator>
      <dc:date>2020-03-14T23:03:22Z</dc:date>
    </item>
  </channel>
</rss>

