<?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: Automated Policy Install Verification in API / CLI Discussion</title>
    <link>https://community.checkpoint.com/t5/API-CLI-Discussion/Automated-Policy-Install-Verification/m-p/79378#M4619</link>
    <description>&lt;P&gt;Undoubtedly, &amp;nbsp;you could probably ask this question here and get a number of different answers. However, this method would pair with the notification script I referenced in the earlier post.&lt;/P&gt;
&lt;P&gt;#/bin/bash&lt;BR /&gt;#&lt;BR /&gt;# Push Firewall Policies&lt;BR /&gt;#&lt;BR /&gt;# You need this in order to run the script as a cron job&lt;BR /&gt;source /opt/&lt;STRONG&gt;CPshrd-R80.30&lt;/STRONG&gt;/tmp/.CPprofile.sh&lt;/P&gt;
&lt;P&gt;#Log Into API&lt;BR /&gt;mgmt_cli login user &lt;EM&gt;&lt;STRONG&gt;&amp;lt;username&amp;gt;&lt;/STRONG&gt;&amp;nbsp;&lt;/EM&gt;password &lt;EM&gt;&lt;STRONG&gt;&amp;lt;pw&amp;gt;&lt;/STRONG&gt;&lt;/EM&gt; &amp;gt; /home/admin/scripts/id.txt&lt;/P&gt;
&lt;P&gt;# Push Policies&lt;/P&gt;
&lt;P&gt;# &lt;STRONG&gt;If you only want to push the access policy portion:&lt;/STRONG&gt;&lt;BR /&gt;mgmt_cli install-policy policy-package "&lt;STRONG&gt;&lt;EM&gt;&amp;lt;your policy package name&amp;gt;&lt;/EM&gt;&lt;/STRONG&gt;" access true -s /home/admin/scripts/id.txt &amp;gt; &lt;STRONG&gt;/home/admin/scripts/push_result.txt&lt;/STRONG&gt;&lt;BR /&gt;cat &lt;STRONG&gt;/home/admin/scripts/push_result.txt&lt;/STRONG&gt; |grep "Installation" &amp;gt; &lt;STRONG&gt;/home/admin/scripts/pushlog.txt&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;# If you want to push both Access Policy and Threat Prevention Policy, use this:&lt;/STRONG&gt;&lt;BR /&gt;mgmt_cli install-policy policy-package "&lt;EM&gt;&lt;STRONG&gt;&amp;lt;your policy package name&amp;gt;&lt;/STRONG&gt;&lt;/EM&gt;" access true threat-prevention true -s /home/admin/scripts/id.txt &amp;gt; &lt;STRONG&gt;/home/admin/scripts/push_result.txt&lt;/STRONG&gt;&lt;BR /&gt;cat &lt;STRONG&gt;/home/admin/scripts/push_result.txt&lt;/STRONG&gt; |grep "Installation" &amp;gt;&amp;gt; &lt;STRONG&gt;/home/admin/scripts/pushlog.txt&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;# Log Out Of API&lt;BR /&gt;mgmt_cli logout -s /home/admin/scripts/id.txt&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;A couple of notes here, &lt;BR /&gt;1.) The&amp;nbsp;source "/opt/&lt;STRONG&gt;CPshrd-R80.30&lt;/STRONG&gt;/tmp/.CPprofile.sh" line needs to be modified to match the version of your management server.&lt;BR /&gt;2.) The output of the entire mgmt_cli command is captured in&amp;nbsp;&lt;STRONG&gt;/home/admin/scripts/push_result.txt&lt;/STRONG&gt;&lt;STRONG&gt;.&amp;nbsp;&lt;/STRONG&gt;Once it completes, I grep for "Installation" to single out the line from the output that indicates whether the installation Failed or Succeeded. I write the results of that to&amp;nbsp;&lt;STRONG&gt;pushlog.txt&lt;/STRONG&gt;&lt;STRONG&gt;.&amp;nbsp;&lt;BR /&gt;&lt;/STRONG&gt;The contends of this file are used in the notification script I referenced above. If you aren't looking to do any notifications, you can disregard all this and just focus on the&amp;nbsp;&lt;EM&gt;&lt;STRONG&gt;mgmt_cli&amp;nbsp;&lt;/STRONG&gt;&lt;/EM&gt;commands&lt;EM&gt;.&lt;BR /&gt;&lt;/EM&gt;3.) If you are performing multiple policy installs in one script, I would make sure you change the output to "&amp;gt;&amp;gt;" so it appends to that file instead of overwriting it.&lt;BR /&gt;4.) Be sure to use &lt;EM&gt;full paths&lt;/EM&gt; to files in scripts you intend to run under the task scheduler in GAIA or CRON. Its easy to forget to do this and suddenly things don't work as a scheduled task that worked when you ran it locally from some directory on the system.&amp;nbsp;&lt;BR /&gt;5.) It is possible to create a user solely with Install Policy permissions. I created a specific user with those limited permissions as a little bit of a safeguard for this task.&lt;/P&gt;
&lt;P&gt;Hope this helps!&lt;/P&gt;</description>
    <pubDate>Mon, 23 Mar 2020 16:31:41 GMT</pubDate>
    <dc:creator>Daniel_Taney</dc:creator>
    <dc:date>2020-03-23T16:31:41Z</dc:date>
    <item>
      <title>Automated Policy Install Verification</title>
      <link>https://community.checkpoint.com/t5/API-CLI-Discussion/Automated-Policy-Install-Verification/m-p/59385#M3755</link>
      <description>&lt;P&gt;Howdy All,&lt;/P&gt;&lt;P&gt;I am currently scripting/automating our access control policy installation, to run nightly.&amp;nbsp; This is working great, but I am trying to figure out a good way to send out an automatic update like "Policy has been installed on the following:&amp;nbsp; "&lt;/P&gt;&lt;P&gt;I am currently using the script itself to dump to a log, and checking that every morning, but would prefer an email or something similar.&lt;/P&gt;&lt;P&gt;Thanks in advance for any insight!&lt;/P&gt;</description>
      <pubDate>Wed, 31 Jul 2019 17:52:40 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/API-CLI-Discussion/Automated-Policy-Install-Verification/m-p/59385#M3755</guid>
      <dc:creator>kevin_t</dc:creator>
      <dc:date>2019-07-31T17:52:40Z</dc:date>
    </item>
    <item>
      <title>Re: Automated Policy Install Verification</title>
      <link>https://community.checkpoint.com/t5/API-CLI-Discussion/Automated-Policy-Install-Verification/m-p/59389#M3756</link>
      <description>&lt;P&gt;I figured out that the Check Point SMS already has the&amp;nbsp;&lt;STRONG&gt;msmtp&lt;/STRONG&gt; client built into it. You can create a config file under /etc/msmtprc that specifies an SMTP server to connect to and send mail through. If memory serves, this config file is not there by default. You can read up a little bit on how to structure the config file &lt;A href="https://wiki.archlinux.org/index.php/Msmtp" target="_self"&gt;here&lt;/A&gt;.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I accomplish this by collecting the results of the Policy Installation in a temporary file called "&lt;STRONG&gt;pushlog.txt&lt;/STRONG&gt;"; which it sounds like you already have since you check that log manually. Then, once the results of all the Policy Installs have been collected, I run the following actions at the end of my script to generate another temp file "&lt;STRONG&gt;tmp_email_report.txt&lt;/STRONG&gt;" to assemble the actual body of the e-mail communication:&lt;/P&gt;
&lt;P&gt;# Prepare to send e-mail&lt;BR /&gt;echo "Subject: Firewall Policy Install Results" &amp;gt; /home/admin/scripts/&lt;STRONG&gt;tmp_email_report.txt&lt;/STRONG&gt;&lt;BR /&gt;echo &amp;gt;&amp;gt; /home/admin/scripts/&lt;STRONG&gt;tmp_email_report.txt&lt;/STRONG&gt;&lt;BR /&gt;echo &amp;gt;&amp;gt; /home/admin/scripts/&lt;STRONG&gt;tmp_email_report.txt&lt;/STRONG&gt;&lt;BR /&gt;cat /home/admin/scripts/&lt;STRONG&gt;pushlog.txt&lt;/STRONG&gt; &amp;gt;&amp;gt; /home/admin/scripts/&lt;STRONG&gt;tmp_email_report.txt&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;# Send E-Mails&lt;BR /&gt;cat /home/admin/scripts/&lt;STRONG&gt;tmp_email_report.txt&lt;/STRONG&gt; |msmtp --debug --from=user@yourdomain.com -t recipient@yourdomain.com&lt;/P&gt;
&lt;P&gt;# Clean-up Scratch File&lt;BR /&gt;rm /home/admin/scripts/&lt;STRONG&gt;tmp_email_report.txt&lt;/STRONG&gt;&lt;BR /&gt;rm /home/admin/scripts/&lt;STRONG&gt;push_result.txt&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;Hope this helps!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 31 Jul 2019 20:10:57 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/API-CLI-Discussion/Automated-Policy-Install-Verification/m-p/59389#M3756</guid>
      <dc:creator>Daniel_Taney</dc:creator>
      <dc:date>2019-07-31T20:10:57Z</dc:date>
    </item>
    <item>
      <title>Re: Automated Policy Install Verification</title>
      <link>https://community.checkpoint.com/t5/API-CLI-Discussion/Automated-Policy-Install-Verification/m-p/59449#M3757</link>
      <description>That did the trick, never knew about msmtp!</description>
      <pubDate>Thu, 01 Aug 2019 18:43:15 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/API-CLI-Discussion/Automated-Policy-Install-Verification/m-p/59449#M3757</guid>
      <dc:creator>kevin_t</dc:creator>
      <dc:date>2019-08-01T18:43:15Z</dc:date>
    </item>
    <item>
      <title>Re: Automated Policy Install Verification</title>
      <link>https://community.checkpoint.com/t5/API-CLI-Discussion/Automated-Policy-Install-Verification/m-p/59524#M3759</link>
      <description>This is the kind of thing that SmartTasks will allow for, planned for R80.40.&lt;BR /&gt;Specifically triggering an action after a Policy Install action completes.</description>
      <pubDate>Fri, 02 Aug 2019 19:02:06 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/API-CLI-Discussion/Automated-Policy-Install-Verification/m-p/59524#M3759</guid>
      <dc:creator>PhoneBoy</dc:creator>
      <dc:date>2019-08-02T19:02:06Z</dc:date>
    </item>
    <item>
      <title>Re: Automated Policy Install Verification</title>
      <link>https://community.checkpoint.com/t5/API-CLI-Discussion/Automated-Policy-Install-Verification/m-p/79311#M4615</link>
      <description>&lt;P&gt;can you please share your automated policy install solution?&lt;/P&gt;</description>
      <pubDate>Mon, 23 Mar 2020 08:12:00 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/API-CLI-Discussion/Automated-Policy-Install-Verification/m-p/79311#M4615</guid>
      <dc:creator>motiami</dc:creator>
      <dc:date>2020-03-23T08:12:00Z</dc:date>
    </item>
    <item>
      <title>Re: Automated Policy Install Verification</title>
      <link>https://community.checkpoint.com/t5/API-CLI-Discussion/Automated-Policy-Install-Verification/m-p/79378#M4619</link>
      <description>&lt;P&gt;Undoubtedly, &amp;nbsp;you could probably ask this question here and get a number of different answers. However, this method would pair with the notification script I referenced in the earlier post.&lt;/P&gt;
&lt;P&gt;#/bin/bash&lt;BR /&gt;#&lt;BR /&gt;# Push Firewall Policies&lt;BR /&gt;#&lt;BR /&gt;# You need this in order to run the script as a cron job&lt;BR /&gt;source /opt/&lt;STRONG&gt;CPshrd-R80.30&lt;/STRONG&gt;/tmp/.CPprofile.sh&lt;/P&gt;
&lt;P&gt;#Log Into API&lt;BR /&gt;mgmt_cli login user &lt;EM&gt;&lt;STRONG&gt;&amp;lt;username&amp;gt;&lt;/STRONG&gt;&amp;nbsp;&lt;/EM&gt;password &lt;EM&gt;&lt;STRONG&gt;&amp;lt;pw&amp;gt;&lt;/STRONG&gt;&lt;/EM&gt; &amp;gt; /home/admin/scripts/id.txt&lt;/P&gt;
&lt;P&gt;# Push Policies&lt;/P&gt;
&lt;P&gt;# &lt;STRONG&gt;If you only want to push the access policy portion:&lt;/STRONG&gt;&lt;BR /&gt;mgmt_cli install-policy policy-package "&lt;STRONG&gt;&lt;EM&gt;&amp;lt;your policy package name&amp;gt;&lt;/EM&gt;&lt;/STRONG&gt;" access true -s /home/admin/scripts/id.txt &amp;gt; &lt;STRONG&gt;/home/admin/scripts/push_result.txt&lt;/STRONG&gt;&lt;BR /&gt;cat &lt;STRONG&gt;/home/admin/scripts/push_result.txt&lt;/STRONG&gt; |grep "Installation" &amp;gt; &lt;STRONG&gt;/home/admin/scripts/pushlog.txt&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;# If you want to push both Access Policy and Threat Prevention Policy, use this:&lt;/STRONG&gt;&lt;BR /&gt;mgmt_cli install-policy policy-package "&lt;EM&gt;&lt;STRONG&gt;&amp;lt;your policy package name&amp;gt;&lt;/STRONG&gt;&lt;/EM&gt;" access true threat-prevention true -s /home/admin/scripts/id.txt &amp;gt; &lt;STRONG&gt;/home/admin/scripts/push_result.txt&lt;/STRONG&gt;&lt;BR /&gt;cat &lt;STRONG&gt;/home/admin/scripts/push_result.txt&lt;/STRONG&gt; |grep "Installation" &amp;gt;&amp;gt; &lt;STRONG&gt;/home/admin/scripts/pushlog.txt&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;# Log Out Of API&lt;BR /&gt;mgmt_cli logout -s /home/admin/scripts/id.txt&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;A couple of notes here, &lt;BR /&gt;1.) The&amp;nbsp;source "/opt/&lt;STRONG&gt;CPshrd-R80.30&lt;/STRONG&gt;/tmp/.CPprofile.sh" line needs to be modified to match the version of your management server.&lt;BR /&gt;2.) The output of the entire mgmt_cli command is captured in&amp;nbsp;&lt;STRONG&gt;/home/admin/scripts/push_result.txt&lt;/STRONG&gt;&lt;STRONG&gt;.&amp;nbsp;&lt;/STRONG&gt;Once it completes, I grep for "Installation" to single out the line from the output that indicates whether the installation Failed or Succeeded. I write the results of that to&amp;nbsp;&lt;STRONG&gt;pushlog.txt&lt;/STRONG&gt;&lt;STRONG&gt;.&amp;nbsp;&lt;BR /&gt;&lt;/STRONG&gt;The contends of this file are used in the notification script I referenced above. If you aren't looking to do any notifications, you can disregard all this and just focus on the&amp;nbsp;&lt;EM&gt;&lt;STRONG&gt;mgmt_cli&amp;nbsp;&lt;/STRONG&gt;&lt;/EM&gt;commands&lt;EM&gt;.&lt;BR /&gt;&lt;/EM&gt;3.) If you are performing multiple policy installs in one script, I would make sure you change the output to "&amp;gt;&amp;gt;" so it appends to that file instead of overwriting it.&lt;BR /&gt;4.) Be sure to use &lt;EM&gt;full paths&lt;/EM&gt; to files in scripts you intend to run under the task scheduler in GAIA or CRON. Its easy to forget to do this and suddenly things don't work as a scheduled task that worked when you ran it locally from some directory on the system.&amp;nbsp;&lt;BR /&gt;5.) It is possible to create a user solely with Install Policy permissions. I created a specific user with those limited permissions as a little bit of a safeguard for this task.&lt;/P&gt;
&lt;P&gt;Hope this helps!&lt;/P&gt;</description>
      <pubDate>Mon, 23 Mar 2020 16:31:41 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/API-CLI-Discussion/Automated-Policy-Install-Verification/m-p/79378#M4619</guid>
      <dc:creator>Daniel_Taney</dc:creator>
      <dc:date>2020-03-23T16:31:41Z</dc:date>
    </item>
    <item>
      <title>Re: Automated Policy Install Verification</title>
      <link>https://community.checkpoint.com/t5/API-CLI-Discussion/Automated-Policy-Install-Verification/m-p/79462#M4621</link>
      <description>&lt;P&gt;Thanks a lot! much appreciated.&lt;/P&gt;</description>
      <pubDate>Tue, 24 Mar 2020 07:40:24 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/API-CLI-Discussion/Automated-Policy-Install-Verification/m-p/79462#M4621</guid>
      <dc:creator>motiami</dc:creator>
      <dc:date>2020-03-24T07:40:24Z</dc:date>
    </item>
    <item>
      <title>Re: Automated Policy Install Verification</title>
      <link>https://community.checkpoint.com/t5/API-CLI-Discussion/Automated-Policy-Install-Verification/m-p/79550#M4622</link>
      <description>&lt;P&gt;Glad it helped!&lt;/P&gt;</description>
      <pubDate>Tue, 24 Mar 2020 12:45:09 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/API-CLI-Discussion/Automated-Policy-Install-Verification/m-p/79550#M4622</guid>
      <dc:creator>Daniel_Taney</dc:creator>
      <dc:date>2020-03-24T12:45:09Z</dc:date>
    </item>
  </channel>
</rss>

