How to use Ansible to connect to the Red Hat Satellite 6 API
Environment
- Red Hat Satellite 6
- Red Hat Ansible Automation Platform
Issue
- How to use an Ansible playbook to connect to the Red Hat Satellite 6 API?
- If you are looking for how to manage Satellite with Ansible, check the satellite collection here: This content is not included.This content is not included.https://console.redhat.com/ansible/automation-hub/repo/published/redhat/satellite
Resolution
- The Content from docs.ansible.com is not included.
urimodule can be used to access the Red Hat Satellite 6 API - To find information about accessing the Red Hat Satellite 6 API, please see here: https://access.redhat.com/solutions/3727591.
- Below are two examples to demonstrate the usage (replace the variables with your actual data):
-
Example 1: Get all organizations from Satellite
- name: API call to Red Hat Satellite 6 hosts: localhost gather_facts: no vars: satellite_url: $SATELLITE_URL user_name: $USERNAME password: $PASSWORD tasks: - name: get all organizations from Satellite 6 uri: url: "{{ satellite_url }}/api/v2/organizations" method: GET user: "{{ user_name }}" password: "{{ password }}" force_basic_auth: yes validate_certs: no register: api_data - name: output client data debug: msg="{{ api_data.json }}" -
Example 2: Get the lifecycle environment of a single host
- name: API call to Red Hat Satellite 6 hosts: localhost gather_facts: no vars: satellite_url: $SATELLITE_URL user_name: $USERNAME password: $PASSWORD host_name: $HOST_NAME tasks: - name: get lifecycle environment name for client from Satellite 6 uri: url: "{{ satellite_url }}/api/v2/hosts/{{ host_name }}" method: GET user: "{{ user_name }}" password: "{{ password }}" force_basic_auth: yes validate_certs: no register: api_data - name: output client date debug: msg="{{ api_data.json.content_facet_attributes.lifecycle_environment_name }}"
-
For more KB articles/solutions related to Red Hat Satellite 6.x API Issues, please refer to the Red Hat Satellite Consolidated Troubleshooting Article for Red Hat Satellite 6.x API Issues
Category
Tags
This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.