Create a Post
cancel
Showing results for 
Search instead for 
Did you mean: 
sundrys1
Explorer

ansible get session id using MSD and module uri

Hello,

can somebody help me to get session ID?

I have try to use this api call.

https://sc1.checkpoint.com/documents/latest/APIs/index.html#web/login~v1.5%20

but I dont know what is correct.

Request URL
POST https://<mgmt-server>:<port>/web_api/v1.5/login

but in example is  without /web_api/

POST {{server}}/v1.5/login

 

so what is correct ?

 

also I have create ansible playbook log to CPMGMT via MSD.

'''

- name: Login to Check Point Management API
  uri:
    url: "https://{{ mdss_server }}/v1.5/login"
    method: POST
    validate_certs: no
    timeout: 30
    headers:
      Content-Type: application/json
    body_format: json
    #body: { "user" : "{{ cp_user }}", "password" : "{{ cp_password }}", "domain": "{{ checkpoint_domain }}"  }
    body:
      user: "{{ cp_user }}"
      password: "{{ cp_password }}"
      domain": "{{ checkpoint_domain }}"
    return_content: yes
  register: result_login

- name: debug
  debug:
      msg: "{{ result_login }}"
'''
 
but I have this response with out session ID
 
{
"msg": {
"changed": false,
"connection": "close",
"content": "<!DOCTYPE html><HTML><HEAD>\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"><meta http-equiv=\"X-UA-Compatible\" content=\"IE=EmulateIE9,EmulateIE8\"><meta name=\"others\" content=\"WEBUI LOGIN PAGE\" /><TITLE>Gaia</TITLE>\n<link rel=\"shortcut icon\" href=\"/login/fav.ico\"> \n<link rel=\"stylesheet\" type=\"text/css\" href=\"/login/ext-all.css\" />\n<link rel=\"stylesheet\" type=\"text/css\" href=\"/login/login.css\" />\n<STYLE TYPE=\"text/css\">\n.ext-ie .webui-login-fld{font-size: 11px;}\n</STYLE>\n<script type=\"text/javascript\" src=\"/login/ext-base.js\"></script><script type=\"text/javascript\" src=\"/login/ext-all.js\"></script><script type=\"text/javascript\">var errMsgText = \"\";var bannerMsgText = \"\";bannerMsgText += \"This system is for authorized use only.<br>\";var hostname='prgdca-sd-mds';var version='R80.30';var formAction=\"/cgi-bin/home.tcl\";</script><script type=\"text/javascript\" src=\"/login/login.js\"></script></HEAD><BODY><noscript><div style='font-size:20px;position:relative;top:100px;'>For full functionality of this site it is necessary to enable JavaScript.</div></noscript></BODY></HTML>",
"content_type": "text/html",
"cookies": {
"Session": "Login"
},
"cookies_string": "Session=Login",
"date": "Wed, 12 Jan 2022 12:29:28 GMT",
"elapsed": 0,
"failed": false,
"msg": "OK (unknown bytes)",
"redirected": false,
"server": "CPWS",
"set_cookie": "Session=Login;path=/; secure; HttpOnly",
"status": 200,
"strict_transport_security": "max-age=31536000; includeSubDomains",
"transfer_encoding": "chunked",
"url": "https://10.10.10.10/v1.5/login",
"x_frame_options": "SAMEORIGIN",
"x_ua_compatible": "IE=EmulateIE8"
}
}
 
should I use some module or what is wrong in my playbook?
 
thank you
 
Radek
0 Kudos
1 Reply
PhoneBoy
Admin
Admin

That looks like the API server isn’t actually enabled on the management server.
See: https://community.checkpoint.com/t5/API-CLI-Discussion/Enabling-web-api/m-p/32641#M2011

Leaderboard

Epsum factorial non deposit quid pro quo hic escorol.

Upcoming Events

    CheckMates Events