Automation Hubæ¥ç¶ã«ä½¿ç¨ãããªãã©ã¤ã³ãã¼ã¯ã³ã¯30æ¥éã¢ã¯ãã£ãã§ãªãç¶æ
ãç¶ãã¨æéåãã¨ãªã£ã¦ãã¾ãã
å
¬å¼ã§ã¯curlã³ãã³ããå®è¡ããã¨è¨è¼ããããã©ãããªãPlaybookã«ãã¦ã¿ã
æ¦è¦
- å ¬å¼ã§æä¾ãããcurlã³ãã³ãããã¨ã«uriã¢ã¸ã¥ã¼ã«ã使ç¨ããPlaybookãµã³ãã«ãä½æ
ç°å¢
- ansible
- 2.14.2
ãªãã©ã¤ã³ãã¼ã¯ã³æéåãé²æ¢ã®Playbookä½æ
Red Hatå ¬å¼ãµã¤ãã§æä¾ãããcurlã³ãã³ã
-
Private Automation HubããAutomation Hubã«ã¢ã¯ã»ã¹ããããã®ãã¼ã¯ã³çºè¡ç»é¢ã«ã¦æéåãé²æ¢ã®ããã®curlã³ãã³ããç´¹ä»ããã¦ãã
curlã³ãã³ã
curl https://sso.redhat.com/auth/realms/redhat-external/protocol/openid-connect/token -d grant_type=refresh_token -d client_id="cloud-services" -d refresh_token="{{ user_token }}" --fail --silent --show-error --output /dev/null
- å®è¡ã³ãã³ã
- ã¬ã¹ãã³ã¹ã¯æ¬²ããã®ã§å¾åã®ãªãã·ã§ã³ãçã
curl https://sso.redhat.com/auth/realms/redhat-external/protocol/openid-connect/token -d grant_type=refresh_token -d client_id="cloud-services" -d refresh_token="{{ user_token }}" | python -m json.tool
- å®è¡ãã°
{ "access_token": "ããããããªããã¼ã¯ã³", "expires_in": 900, "refresh_expires_in": 0, "refresh_token": "ããããããªããã¼ã¯ã³", "token_type": "Bearer", "id_token": "ããããããªããã¼ã¯ã³", "not-before-policy": 0, "session_state": "beb141b6-1b55-4586-9ac7-a0090a201359", "scope": "openid api.iam.service_accounts api.iam.organization offline_access" }
ãªãã©ã¤ã³ãã¼ã¯ã³æéåãé²æ¢ã®ãµã³ãã«Playbookä½æ
- Playbook
- hosts: localhost gather_facts: false connection: local vars: ah_offline_token: <ãªãã©ã¤ã³ãã¼ã¯ã³æ¸ãã¦ã> tasks: - name: "Automation Hub Offline Token Expiration Prevention API" ansible.builtin.uri: url: "https://sso.redhat.com/auth/realms/redhat-external/protocol/openid-connect/token" method: POST body_format: "form-urlencoded" body: grant_type: "refresh_token" client_id: "cloud-services" refresh_token: "{{ ah_offline_token }}" register: response - name: "Debug response" ansible.builtin.debug: var: response
- å®è¡ãã°
PLAY [localhost] *********************************************************************************************************************************************************************************************************** TASK [Automation Hub Offline Token Expiration Prevention API] ************************************************************************************************************************************************************** ok: [localhost] TASK [Debug response] ****************************************************************************************************************************************************************************************************** ok: [localhost] => { "response": { "cache_control": "no-store", "changed": false, "connection": "close", "content_length": "5660", "content_type": "application/json", "cookies": { "2a4bcc483fa585dc0ad94b51550d0923": "29857b1cb4903eae4c4774926bc13f28" }, "cookies_string": "2a4bcc483fa585dc0ad94b51550d0923=29857b1cb4903eae4c4774926bc13f28", "date": "Thu, 06 Apr 2023 12:21:19 GMT", "elapsed": 0, "failed": false, "json": { "access_token": "ããããããªããã¼ã¯ã³", "expires_in": 900, "id_token": "ããããããªããã¼ã¯ã³", "not-before-policy": 0, "refresh_expires_in": 0, "refresh_token": "ããããããªããã¼ã¯ã³", "scope": "openid api.iam.service_accounts api.iam.organization offline_access", "session_state": "beb141b6-1b55-4586-9ac7-a0090a201359", "token_type": "Bearer" }, "keep_alive": "timeout=300", "msg": "OK (5660 bytes)", "pragma": "no-cache", "redirected": false, "referrer_policy": "strict-origin", "set_cookie": "2a4bcc483fa585dc0ad94b51550d0923=29857b1cb4903eae4c4774926bc13f28; path=/; HttpOnly; Secure; SameSite=None", "status": 200, "strict_transport_security": "max-age=31536000; includeSubDomains", "url": "https://sso.redhat.com/auth/realms/redhat-external/protocol/openid-connect/token", "x_content_type_options": "nosniff", "x_frame_options": "SAMEORIGIN", "x_rh_edge_cache_status": "Miss from child, Miss from parent", "x_rh_edge_reference_id": "0.2f9e3a17.1680783679.40bfc1bd", "x_rh_edge_request_id": "40bfc1bd", "x_site": "prod-spoke-aws-us-east-1", "x_xss_protection": "1; mode=block" } }
- ã¬ã¹ãã³ã¹ãããããåããªã®ã§æåã£ã½ã(ã¹ãã¼ã¿ã¹ã200)