<?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: Connection' object has no attribute '_session_uid' in Ansible</title>
    <link>https://community.checkpoint.com/t5/Ansible/Connection-object-has-no-attribute-session-uid/m-p/214873#M792</link>
    <description>&lt;P&gt;We have opened an official service request for this. Thank you. This thread can be closed.&lt;/P&gt;</description>
    <pubDate>Tue, 21 May 2024 07:50:50 GMT</pubDate>
    <dc:creator>memet</dc:creator>
    <dc:date>2024-05-21T07:50:50Z</dc:date>
    <item>
      <title>Connection' object has no attribute '_session_uid'</title>
      <link>https://community.checkpoint.com/t5/Ansible/Connection-object-has-no-attribute-session-uid/m-p/213744#M790</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I implement a custom solution, which utilizes Ansible Checkpoint module to execute changes on objects in Checkpoint. Because we have two Checkpoint instances, one in Active and one in Standby (read-only) mode, I would like to ensure that solution connects to Active one automatically.&lt;/P&gt;&lt;P&gt;My idea for implementation is that, if solution connects to instance in Standby mode and executes a command which fails (e.g. host object update), the operation should be retried 3 times before switching over to 2nd Checkpoint instance (which should be in Active mode).&lt;/P&gt;&lt;P&gt;For implementing retry operation, I want to use generic Retries/Delay/Until task attributes of Ansible. However, I noticed that these attributes are completely ignored by Checkpoint module commands, in case when update operation is executed on instance in Standby mode.&amp;nbsp;&lt;/P&gt;&lt;P&gt;My code:&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;- &lt;/SPAN&gt;&lt;SPAN&gt;name&lt;/SPAN&gt;&lt;SPAN&gt;: &lt;/SPAN&gt;&lt;SPAN&gt;add host {{ _host_name }}&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;check_point.mgmt.cp_mgmt_hosts&lt;/SPAN&gt;&lt;SPAN&gt;:&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;config&lt;/SPAN&gt;&lt;SPAN&gt;:&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;name&lt;/SPAN&gt;&lt;SPAN&gt;: &lt;/SPAN&gt;&lt;SPAN&gt;"{{ _host_name }}"&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;ip_address&lt;/SPAN&gt;&lt;SPAN&gt;: &lt;/SPAN&gt;&lt;SPAN&gt;"{{ _host_ip }}"&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;comments&lt;/SPAN&gt;&lt;SPAN&gt;: &lt;/SPAN&gt;&lt;SPAN&gt;"{{ _host_comments }}"&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;groups&lt;/SPAN&gt;&lt;SPAN&gt;: &lt;/SPAN&gt;&lt;SPAN&gt;"{{ _host_hostlist }}"&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;color&lt;/SPAN&gt;&lt;SPAN&gt;: &lt;/SPAN&gt;&lt;SPAN&gt;"{{ _host_zone_color }}"&lt;/SPAN&gt;&lt;SPAN&gt; &amp;nbsp;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;auto_publish_session&lt;/SPAN&gt;&lt;SPAN&gt;: &lt;/SPAN&gt;&lt;SPAN&gt;true&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;state&lt;/SPAN&gt;&lt;SPAN&gt;: &lt;/SPAN&gt;&lt;SPAN&gt;merged&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;register&lt;/SPAN&gt;&lt;SPAN&gt;: &lt;/SPAN&gt;&lt;SPAN&gt;_add_host_result&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;ignore_errors&lt;/SPAN&gt;&lt;SPAN&gt;: &lt;/SPAN&gt;&lt;SPAN&gt;true&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;retries&lt;/SPAN&gt;&lt;SPAN&gt;: &lt;/SPAN&gt;&lt;SPAN&gt;3&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;delay&lt;/SPAN&gt;&lt;SPAN&gt;: &lt;/SPAN&gt;&lt;SPAN&gt;5&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;until&lt;/SPAN&gt;&lt;SPAN&gt;: &lt;/SPAN&gt;&lt;SPAN&gt;_add_host_result is not failed&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Result after execute above task on Checkpoint instance in Standby mode:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;TASK [add host host_4.4.4.4] ***************************************************&lt;BR /&gt;task path: /runner/project/playbooks/add_host_custom.yml:9&lt;BR /&gt;redirecting (type: connection) ansible.builtin.httpapi to ansible.netcommon.httpapi&lt;BR /&gt;&amp;lt;x.x.x.x&amp;gt; attempting to start connection&lt;BR /&gt;&amp;lt;x.x.x.x&amp;gt; using connection plugin ansible.netcommon.httpapi&lt;BR /&gt;Found ansible-connection at path /usr/bin/ansible-connection&lt;BR /&gt;&amp;lt;x.x.x.x&amp;gt; found existing local domain socket, using it!&lt;BR /&gt;&amp;lt;x.x.x.x&amp;gt; updating play_context for connection&lt;BR /&gt;&amp;lt;x.x.x.x&amp;gt; Loading collection ansible.builtin from&lt;BR /&gt;&amp;lt;x.x.x.x&amp;gt; local domain socket path is /home/runner/.ansible/pc/fc492a18ce&lt;BR /&gt;The full traceback is:&lt;BR /&gt;Traceback (most recent call last):&lt;BR /&gt;File "/runner/requirements_collections/ansible_collections/check_point/mgmt/plugins/module_utils/checkpoint.py", line 1858, in _httpapi_error_handle&lt;BR /&gt;result = self.api_call(&lt;BR /&gt;File "/runner/requirements_collections/ansible_collections/check_point/mgmt/plugins/module_utils/checkpoint.py", line 1769, in api_call&lt;BR /&gt;session_uid = connection.get_session_uid()&lt;BR /&gt;File "/usr/lib/python3.9/site-packages/ansible/module_utils/connection.py", line 200, in __rpc__&lt;BR /&gt;raise ConnectionError(to_text(msg, errors='surrogate_then_replace'), code=code)&lt;BR /&gt;ansible.module_utils.connection.ConnectionError: 'Connection' object has no attribute '_session_uid'&lt;/P&gt;&lt;P&gt;During handling of the above exception, another exception occurred:&lt;/P&gt;&lt;P&gt;Traceback (most recent call last):&lt;BR /&gt;File "/usr/lib/python3.9/site-packages/ansible/executor/task_executor.py", line 165, in run&lt;BR /&gt;res = self._execute()&lt;BR /&gt;File "/usr/lib/python3.9/site-packages/ansible/executor/task_executor.py", line 656, in _execute&lt;BR /&gt;result = self._handler.run(task_vars=vars_copy)&lt;BR /&gt;File "/runner/requirements_collections/ansible_collections/check_point/mgmt/plugins/action/cp_mgmt_hosts.py", line 266, in run&lt;BR /&gt;) = self.configure_module_api(&lt;BR /&gt;File "/runner/requirements_collections/ansible_collections/check_point/mgmt/plugins/action/cp_mgmt_hosts.py", line 210, in configure_module_api&lt;BR /&gt;result = conn_request.post(&lt;BR /&gt;File "/runner/requirements_collections/ansible_collections/check_point/mgmt/plugins/module_utils/checkpoint.py", line 1880, in post&lt;BR /&gt;return self._httpapi_error_handle(obj, state, **kwargs)&lt;BR /&gt;File "/runner/requirements_collections/ansible_collections/check_point/mgmt/plugins/module_utils/checkpoint.py", line 1869, in _httpapi_error_handle&lt;BR /&gt;raise _fail_json("connection error occurred: {0}".format(e))&lt;BR /&gt;File "/runner/requirements_collections/ansible_collections/check_point/mgmt/plugins/module_utils/checkpoint.py", line 101, in _fail_json&lt;BR /&gt;raise Exception(msg)&lt;BR /&gt;Exception: connection error occurred: 'Connection' object has no attribute '_session_uid'&lt;BR /&gt;fatal: [localhost]: FAILED! =&amp;gt; {&lt;BR /&gt;"msg": "Unexpected failure during module execution: connection error occurred: 'Connection' object has no attribute '_session_uid'",&lt;BR /&gt;"stdout": ""&lt;BR /&gt;}&lt;BR /&gt;...ignoring&lt;/P&gt;&lt;P&gt;I have masked IP address of Checkpoint instance to&amp;nbsp;x.x.x.x in above log.&amp;nbsp;Interesting is, that if I execute a command on Checkpoint instance running in Active mode, and try to simulate some error situation there, then Retries/Delay/Until attributes are not ignored. Please advice if this is a bug or if there is some better way to implements the connection retries to Checkpoint.&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 10 May 2024 13:31:12 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/Ansible/Connection-object-has-no-attribute-session-uid/m-p/213744#M790</guid>
      <dc:creator>memet</dc:creator>
      <dc:date>2024-05-10T13:31:12Z</dc:date>
    </item>
    <item>
      <title>Re: Connection' object has no attribute '_session_uid'</title>
      <link>https://community.checkpoint.com/t5/Ansible/Connection-object-has-no-attribute-session-uid/m-p/213772#M791</link>
      <description>&lt;P&gt;I assume based on the Playbook and what you're trying to do, this is a Management HA configuration, correct?&lt;BR /&gt;What version/JHF is the management?&lt;/P&gt;</description>
      <pubDate>Thu, 09 May 2024 14:55:37 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/Ansible/Connection-object-has-no-attribute-session-uid/m-p/213772#M791</guid>
      <dc:creator>PhoneBoy</dc:creator>
      <dc:date>2024-05-09T14:55:37Z</dc:date>
    </item>
    <item>
      <title>Re: Connection' object has no attribute '_session_uid'</title>
      <link>https://community.checkpoint.com/t5/Ansible/Connection-object-has-no-attribute-session-uid/m-p/214873#M792</link>
      <description>&lt;P&gt;We have opened an official service request for this. Thank you. This thread can be closed.&lt;/P&gt;</description>
      <pubDate>Tue, 21 May 2024 07:50:50 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/Ansible/Connection-object-has-no-attribute-session-uid/m-p/214873#M792</guid>
      <dc:creator>memet</dc:creator>
      <dc:date>2024-05-21T07:50:50Z</dc:date>
    </item>
  </channel>
</rss>

