<?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: Write multiple clish commands in Ansible task in Ansible</title>
    <link>https://community.checkpoint.com/t5/Ansible/Write-multiple-clish-commands-in-Ansible-task/m-p/200753#M769</link>
    <description>&lt;P&gt;This error is happening because of your FW:vars. Remove "ansible_connection=httpapi" and it should work.&lt;/P&gt;
&lt;P&gt;I recommend adding the "ansible_connection=httpapi" variable only to specific playbooks that use the Check Point Gaia/Mgmt Ansible modules. When using a built-in basic Ansible module like command or shell, it's not needed.&lt;/P&gt;</description>
    <pubDate>Fri, 15 Dec 2023 16:45:42 GMT</pubDate>
    <dc:creator>Erik_Lagzdins</dc:creator>
    <dc:date>2023-12-15T16:45:42Z</dc:date>
    <item>
      <title>Write multiple clish commands in Ansible task</title>
      <link>https://community.checkpoint.com/t5/Ansible/Write-multiple-clish-commands-in-Ansible-task/m-p/178064#M726</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;I treied to use the shell with the clish interpreter to execute multiple clish commands.&lt;/P&gt;
&lt;P&gt;But so far it did not result in a working setup. The tasks itself gives no errors.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;-&amp;nbsp;&lt;SPAN class="pl-ent"&gt;name&lt;/SPAN&gt;:&amp;nbsp;&lt;SPAN class="pl-s"&gt;AddHostClish&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN class="pl-s"&gt;&lt;SPAN class="pl-ent"&gt;  ansible.builtin.shell&lt;/SPAN&gt;: |&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN class="pl-s"&gt;    add host hostname {{ inventory_hostname }} ipv4-address ipv4-address ansible_default_ipv4.address&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN class="pl-s"&gt;    add host hostname {{ inventory_hostname }}.local ipv4-address ipv4-address ansible_default_ipv4.address&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN class="pl-s"&gt;    save config&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN class="pl-s"&gt;  args:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN class="pl-s"&gt;    executable: /usr/bin/clish&lt;BR /&gt;&lt;/SPAN&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 14 Apr 2023 07:36:40 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/Ansible/Write-multiple-clish-commands-in-Ansible-task/m-p/178064#M726</guid>
      <dc:creator>Hugo_vd_Kooij</dc:creator>
      <dc:date>2023-04-14T07:36:40Z</dc:date>
    </item>
    <item>
      <title>Re: Write multiple clish commands in Ansible task</title>
      <link>https://community.checkpoint.com/t5/Ansible/Write-multiple-clish-commands-in-Ansible-task/m-p/178112#M728</link>
      <description>&lt;P&gt;You realize there is an Ansible collection for Gaia itself, right?&lt;BR /&gt;&lt;A href="https://galaxy.ansible.com/check_point/gaia" target="_blank"&gt;https://galaxy.ansible.com/check_point/gaia&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 14 Apr 2023 16:29:23 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/Ansible/Write-multiple-clish-commands-in-Ansible-task/m-p/178112#M728</guid>
      <dc:creator>PhoneBoy</dc:creator>
      <dc:date>2023-04-14T16:29:23Z</dc:date>
    </item>
    <item>
      <title>Re: Write multiple clish commands in Ansible task</title>
      <link>https://community.checkpoint.com/t5/Ansible/Write-multiple-clish-commands-in-Ansible-task/m-p/178206#M730</link>
      <description>&lt;P&gt;Yes, I am aware of them. But they don't cover all of my use cases.&lt;/P&gt;
&lt;P&gt;To be honest not all firewall are up to spec.(R77.30 is pre API anyway.) And some features are not implemented. And some implemented in an impractical way.&lt;/P&gt;
&lt;P&gt;For example cp_gaia_put_file only allows you to insert a file with the text as variable. Not a very practical job in my view.&lt;/P&gt;
&lt;P&gt;So as it stands I have to rely on running clich commands by a user that has bash as it's default shell.&lt;/P&gt;
&lt;P&gt;THe actual clish command's are just a test case.&lt;/P&gt;</description>
      <pubDate>Mon, 17 Apr 2023 05:49:43 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/Ansible/Write-multiple-clish-commands-in-Ansible-task/m-p/178206#M730</guid>
      <dc:creator>Hugo_vd_Kooij</dc:creator>
      <dc:date>2023-04-17T05:49:43Z</dc:date>
    </item>
    <item>
      <title>Re: Write multiple clish commands in Ansible task</title>
      <link>https://community.checkpoint.com/t5/Ansible/Write-multiple-clish-commands-in-Ansible-task/m-p/178248#M731</link>
      <description>&lt;P&gt;Somehow I had to use the long form commands with `clish -c` in front of each command and skip the use of clish as interpretor.&lt;/P&gt;</description>
      <pubDate>Mon, 17 Apr 2023 14:54:26 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/Ansible/Write-multiple-clish-commands-in-Ansible-task/m-p/178248#M731</guid>
      <dc:creator>Hugo_vd_Kooij</dc:creator>
      <dc:date>2023-04-17T14:54:26Z</dc:date>
    </item>
    <item>
      <title>Re: Write multiple clish commands in Ansible task</title>
      <link>https://community.checkpoint.com/t5/Ansible/Write-multiple-clish-commands-in-Ansible-task/m-p/187538#M740</link>
      <description>&lt;P&gt;As mentioned previously, using the Gaia modules is the preferred method to accomplish the task.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If using Gaia modules is not possible, then you can use the shell module and expand on the example I've provided below.&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;     - name: "Apply Clish DNS Configurations"
       shell: "{{ item }}"
       with_items:
         - clish -c 'set dns primary 1.1.1.1' -s
         - clish -c 'set dns secondary 2.2.2.2' -s
&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 25 Jul 2023 14:24:25 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/Ansible/Write-multiple-clish-commands-in-Ansible-task/m-p/187538#M740</guid>
      <dc:creator>Erik_Lagzdins</dc:creator>
      <dc:date>2023-07-25T14:24:25Z</dc:date>
    </item>
    <item>
      <title>Re: Write multiple clish commands in Ansible task</title>
      <link>https://community.checkpoint.com/t5/Ansible/Write-multiple-clish-commands-in-Ansible-task/m-p/200296#M766</link>
      <description>&lt;P&gt;Hi Erik,&lt;/P&gt;&lt;P&gt;if I try your approach, the I get following error:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;/bin/bash: line 1: clish: command not found.&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My playbook:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;---
# version 2312121007

- name: Set LLDP to on
  hosts: FW
  
  tasks:
  - name: Set LLDP on management server
    ansible.builtin.shell: "{{item}}"
    with_items:
      - clish -c "set lldp state on"
      - clish -c "save config"
    
    args:
      executable: /bin/bash&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My host file:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;[FW]
x.x.x.x

[FW:vars]
ansible_connection=httpapi
ansible_httpapi_use_ssl=True
ansible_httpapi_validate_certs=False
ansible_network_os=checkpoint&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What am I doing wrong?&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Tue, 12 Dec 2023 12:37:59 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/Ansible/Write-multiple-clish-commands-in-Ansible-task/m-p/200296#M766</guid>
      <dc:creator>FWA-BD</dc:creator>
      <dc:date>2023-12-12T12:37:59Z</dc:date>
    </item>
    <item>
      <title>Re: Write multiple clish commands in Ansible task</title>
      <link>https://community.checkpoint.com/t5/Ansible/Write-multiple-clish-commands-in-Ansible-task/m-p/200506#M767</link>
      <description>&lt;P&gt;you will need to load the profiles.&lt;/P&gt;
&lt;P&gt;try to load one of the below:&lt;/P&gt;
&lt;P style="margin: 0in; font-family: Calibri; font-size: 11.0pt;" lang="en-US"&gt;source /etc/rc.d/init.d/functions&lt;/P&gt;
&lt;P style="margin: 0in; font-family: Calibri; font-size: 11.0pt;" lang="en-US"&gt;source /etc/profile.d/CP.sh&lt;/P&gt;
&lt;P style="margin: 0in; font-family: Calibri; font-size: 11.0pt;" lang="en-US"&gt;source /opt/CPshared/5.0/tmp/.CPprofile.sh&lt;/P&gt;
&lt;P style="margin: 0in; font-family: Calibri; font-size: 11.0pt;" lang="en-US"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="margin: 0in; font-family: Calibri; font-size: 11.0pt;" lang="en-US"&gt;source /opt/CPshared/5.0/tmp/.CPprofile.sh &amp;amp;&amp;amp; clish&amp;nbsp; -c "command"&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 13 Dec 2023 15:14:03 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/Ansible/Write-multiple-clish-commands-in-Ansible-task/m-p/200506#M767</guid>
      <dc:creator>Ofir_Shikolski</dc:creator>
      <dc:date>2023-12-13T15:14:03Z</dc:date>
    </item>
    <item>
      <title>Re: Write multiple clish commands in Ansible task</title>
      <link>https://community.checkpoint.com/t5/Ansible/Write-multiple-clish-commands-in-Ansible-task/m-p/200586#M768</link>
      <description>&lt;P&gt;Thanks for the quick response. I have a look into that next week&lt;/P&gt;</description>
      <pubDate>Thu, 14 Dec 2023 07:33:50 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/Ansible/Write-multiple-clish-commands-in-Ansible-task/m-p/200586#M768</guid>
      <dc:creator>FWA-BD</dc:creator>
      <dc:date>2023-12-14T07:33:50Z</dc:date>
    </item>
    <item>
      <title>Re: Write multiple clish commands in Ansible task</title>
      <link>https://community.checkpoint.com/t5/Ansible/Write-multiple-clish-commands-in-Ansible-task/m-p/200753#M769</link>
      <description>&lt;P&gt;This error is happening because of your FW:vars. Remove "ansible_connection=httpapi" and it should work.&lt;/P&gt;
&lt;P&gt;I recommend adding the "ansible_connection=httpapi" variable only to specific playbooks that use the Check Point Gaia/Mgmt Ansible modules. When using a built-in basic Ansible module like command or shell, it's not needed.&lt;/P&gt;</description>
      <pubDate>Fri, 15 Dec 2023 16:45:42 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/Ansible/Write-multiple-clish-commands-in-Ansible-task/m-p/200753#M769</guid>
      <dc:creator>Erik_Lagzdins</dc:creator>
      <dc:date>2023-12-15T16:45:42Z</dc:date>
    </item>
    <item>
      <title>Re: Write multiple clish commands in Ansible task</title>
      <link>https://community.checkpoint.com/t5/Ansible/Write-multiple-clish-commands-in-Ansible-task/m-p/200841#M770</link>
      <description>&lt;P&gt;Hi Erik,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thanks for the answer. This is what you get if you don't have your caffeine levels right&lt;/P&gt;</description>
      <pubDate>Mon, 18 Dec 2023 06:13:06 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/Ansible/Write-multiple-clish-commands-in-Ansible-task/m-p/200841#M770</guid>
      <dc:creator>FWA-BD</dc:creator>
      <dc:date>2023-12-18T06:13:06Z</dc:date>
    </item>
  </channel>
</rss>

