<?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: cp_mgmt_administrator creating administrator on SMS in Ansible</title>
    <link>https://community.checkpoint.com/t5/Ansible/cp-mgmt-administrator-creating-administrator-on-SMS/m-p/224445#M807</link>
    <description>&lt;P&gt;Thank you&amp;nbsp;&lt;a href="https://community.checkpoint.com/t5/user/viewprofilepage/user-id/7"&gt;@PhoneBoy&lt;/a&gt;&amp;nbsp; for the reply. I stepped away from this issue for a week, and just tried cprestart, cpstop &amp;amp;&amp;amp; cprestart. I don't have time to try on R81.10 to see if this is one of the R81.20 management issues. I switched to using ansible mgmt_cli command for this one step so I can continue with the rest.&lt;/P&gt;</description>
    <pubDate>Sun, 25 Aug 2024 18:01:45 GMT</pubDate>
    <dc:creator>nadmin</dc:creator>
    <dc:date>2024-08-25T18:01:45Z</dc:date>
    <item>
      <title>cp_mgmt_administrator creating administrator on SMS</title>
      <link>https://community.checkpoint.com/t5/Ansible/cp-mgmt-administrator-creating-administrator-on-SMS/m-p/223700#M805</link>
      <description>&lt;P&gt;Hello, does anyone have a working ansible playbook to create an administrator on and R81.20 SMS?&lt;/P&gt;&lt;P&gt;I want to create the user "ansible" in my Lab SMS using Ansible. I will then use ansible to automated must of my lab creating. Full details of how environment set up:&amp;nbsp;&lt;A href="https://github.com/doritoes/NUC-Labs/blob/xcp-ng-improvement/XCP-ng/Appendix-Ansible.md" target="_blank" rel="noopener"&gt;https://github.com/doritoes/NUC-Labs/blob/xcp-ng-improvement/XCP-ng/Appendix-Ansible.md&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Using the inventory file below (with ansible_checkpoint_domain=System Data commented out)&lt;/P&gt;&lt;P&gt;1. I can use cp_mgmt_host without problem&lt;/P&gt;&lt;P&gt;2. When I try to use cp_mgmt_administrator to create an administrator i get the error&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;Checkpoint device returned error 400 with message {'code': 'err_inappropriate_domain_type', 'message': 'This command can only work on domains of type MDS. Cannot execute it in the current domain (current domain type is Domain).'}&amp;nbsp; Unpublished changes were discarded.&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;From links here and looking at the API documentation I have found that the domain should be specified as "System Data" for an SMS. When I uncomment the line &lt;STRONG&gt;ansible_checkpoint_domain=System Data&lt;/STRONG&gt;&amp;nbsp;in the inventory file, I get a new error.&amp;nbsp;ansible.module_utils.connection.ConnectionError: Server returned response without token info during the connection authentication: 400&lt;/P&gt;&lt;P&gt;The odd thing is that I tried a couple dozen varieties of configuration got it working 2 times, but I can't get it working again to document what works.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;File: inventory&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;[check_point]
#sms IP
192.168.41.20

[check_point:vars]
ansible_httpapi_use_ssl_True
ansible_httpapi_validate_certs=False
ansible_user=cpadmin
ansible_password=supersecret
#ansible_checkpoint_domain=System Data
ansible_network_os=check_point.mgmt.checkpoint&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;File: add_user.yml&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;---
- name: Test playbook
  hosts: check_point
  connection:httpapi
  tasks:
    - name: add-administrator
      cp_mgmt_administrator:
      authentication_method: check point password
      email: admin@gmail.com
      must_change_password: False
      name: ansible
      password: anothersecret
      permissions_profile: read write all
      phone_number: 1800-800-800
      state: present
      auto_publish_session: True&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Command:&lt;/P&gt;&lt;P&gt;ansible-playbook -i inventory add_user.yml&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;FAQs&lt;/P&gt;&lt;P&gt;1) how did you install the ansible module?&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;sudo apt update &amp;amp;&amp;amp; sudo apt upgrade -y &amp;amp;&amp;amp; sudo apt autoremove -y&lt;/LI&gt;&lt;LI&gt;sudo apt install -y ansible python3-paramiko python3-pip&lt;/LI&gt;&lt;LI&gt;ansible-galaxy collection install community.general vyos.vyos check_point.mgmt&lt;/LI&gt;&lt;LI&gt;python3 -m pip install XenAPI&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;2) did you set up ssh keys? yes i did and that playbook to complete the FTW using ansible uses a separate inventory file and playbook. this is specifically using the mgmt API using ansible&lt;/P&gt;&lt;P&gt;3) Did you enable the API in smartconsole?&lt;/P&gt;&lt;P&gt;Yes. Manage &amp;amp; Settings &amp;gt; Blades &amp;gt; Management API &amp;gt; Advanced Settings &amp;gt; All IP addresses. And then publish. The other playbook task to add a host object works fine. Without specifying the domain.&lt;/P&gt;&lt;PRE&gt;    - name: Create host object
      cp_mgmt_host:
        color: dark green
        ipv4_address: 192.168.41.100
        name: Manager
        comments: management workstation
        state: present
        auto_publish_session: True&lt;/PRE&gt;&lt;P&gt;4) Did you read the docs?&lt;/P&gt;&lt;P&gt;Yes. For example:&amp;nbsp;&lt;A href="https://sc1.checkpoint.com/documents/latest/APIs/?#cli/add-administrator~v1.9.1%20" target="_blank" rel="noopener"&gt;https://sc1.checkpoint.com/documents/latest/APIs/?#cli/add-administrator~v1.9.1%20&lt;/A&gt;&lt;/P&gt;&lt;P&gt;This is were the "System Data" domain is mentioned.&lt;/P&gt;&lt;P&gt;5) Why not just created the administrator manually?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am using automation to build the enter lab to speed up testing. I use terraform with XCP-ng to deploy networks, routers, firewalls, servers, and workstations. I use ansible to complete FTW on firewalls. I will use ansible to deploy policies and configurations on the SMS and push to the firewalls. I really want to&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;EDIT: Yes mgmt_cli can be run using ansible to do the same thing&lt;/P&gt;&lt;LI-CODE lang="python"&gt;mgmt_cli -f json -r true login -d "System Data" &amp;gt; session.txt
mgmt_cli -s session.txt add administrator name "ansible2" password "secret" must-change-password false email "admin@gmail.com" phone-number "1800-800-800" authentication-method "check point password" permissions-profile "read write all"  --domain 'System Data' --format json
mgmt_cli -f json -s session.txt publish
rm session.txt&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 15 Aug 2024 02:37:42 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/Ansible/cp-mgmt-administrator-creating-administrator-on-SMS/m-p/223700#M805</guid>
      <dc:creator>nadmin</dc:creator>
      <dc:date>2024-08-15T02:37:42Z</dc:date>
    </item>
    <item>
      <title>Re: cp_mgmt_administrator creating administrator on SMS</title>
      <link>https://community.checkpoint.com/t5/Ansible/cp-mgmt-administrator-creating-administrator-on-SMS/m-p/223782#M806</link>
      <description>&lt;P&gt;Try performing a cprestart of your management server and see if that resolves the issue.&lt;BR /&gt;Otherwise, this might require a TAC case: &lt;A href="https://help.checkpoint.com" target="_blank"&gt;https://help.checkpoint.com&lt;/A&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 15 Aug 2024 17:17:43 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/Ansible/cp-mgmt-administrator-creating-administrator-on-SMS/m-p/223782#M806</guid>
      <dc:creator>PhoneBoy</dc:creator>
      <dc:date>2024-08-15T17:17:43Z</dc:date>
    </item>
    <item>
      <title>Re: cp_mgmt_administrator creating administrator on SMS</title>
      <link>https://community.checkpoint.com/t5/Ansible/cp-mgmt-administrator-creating-administrator-on-SMS/m-p/224445#M807</link>
      <description>&lt;P&gt;Thank you&amp;nbsp;&lt;a href="https://community.checkpoint.com/t5/user/viewprofilepage/user-id/7"&gt;@PhoneBoy&lt;/a&gt;&amp;nbsp; for the reply. I stepped away from this issue for a week, and just tried cprestart, cpstop &amp;amp;&amp;amp; cprestart. I don't have time to try on R81.10 to see if this is one of the R81.20 management issues. I switched to using ansible mgmt_cli command for this one step so I can continue with the rest.&lt;/P&gt;</description>
      <pubDate>Sun, 25 Aug 2024 18:01:45 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/Ansible/cp-mgmt-administrator-creating-administrator-on-SMS/m-p/224445#M807</guid>
      <dc:creator>nadmin</dc:creator>
      <dc:date>2024-08-25T18:01:45Z</dc:date>
    </item>
  </channel>
</rss>

