I use the following to call the Foreman API:
curl --netrc -H "Content-Type: application/json" https://foreman.example.com/api/hosts/node01.example.com
Output:
{
"ip": "10.xx.xx.x",
"ip6": "",
"environment_id": 2,
"environment_name": "production",
"last_report": null,
"mac": "00:xx:xx:xx:xx:xx",
"realm_id": null,
"realm_name": null,
"sp_mac": null,
"sp_ip": null,
"sp_name": null,
"domain_id": 1,
"domain_name": "example.com",
"architecture_id": 1,
"architecture_name": "x86_64",
"operatingsystem_id": 8,
"operatingsystem_name": "Debian 9.3",
"subnet_id": 28,
"subnet_name": "example-net",
"subnet6_id": null,
"subnet6_name": null,
"sp_subnet_id": null,
"ptable_id": 93,
"ptable_name": "xx BTRFS",
"medium_id": 9,
"medium_name": "Debian",
"pxe_loader": "None",
"build": true,
"comment": "",
"disk": "",
"installed_at": null,
"model_id": null,
"hostgroup_id": null,
"owner_id": 1,
"owner_type": "Usergroup",
"enabled": true,
"managed": true,
"use_image": null,
"image_file": "",
"uuid": "5026dac6-07b9-2bd9-8e96-d3065803d7a3",
"compute_resource_id": 1,
"compute_resource_name": "VMware",
"compute_profile_id": null,
"compute_profile_name": null,
"capabilities": [
"build",
"image"
],
"provision_method": "build",
"certname": "node01.example.com",
"image_id": null,
"image_name": null,
"created_at": "2018-02-20 15:36:18 UTC",
"updated_at": "2018-02-20 15:36:18 UTC",
"last_compile": null,
"global_status": 0,
"global_status_label": "Warning",
"location_id": 1,
"location_name": "xxx",
"puppet_status": 0,
"model_name": null,
"configuration_status": 0,
"configuration_status_label": "No reports",
"build_status": 1,
"build_status_label": "Pending installation",
"name": "node01.example.com",
"id": 2208,
"puppet_proxy_id": 36,
"puppet_proxy_name": "puppet.example.com",
"puppet_ca_proxy_id": 38,
"puppet_ca_proxy_name": "puppetca.example.com",
"puppet_proxy": {
"name": "puppet.example.com",
"id": 36,
"url": "https://puppet.example.com:8443"
},
"puppet_ca_proxy": {
"name": "puppetca.example.com",
"id": 38,
"url": "https://puppetca.example.com:8443"
},
"token": "0017109f-9d45-4180-aa24-7cb0a586adfe",
"hostgroup_name": null,
"hostgroup_title": null,
"parameters": [],
"all_parameters": [],
"interfaces": [
{
"id": 3524,
"name": "node01.example.com",
"ip": "10.xx.xx.x",
"ip6": "",
"mac": "00:xx:xx:xx:xx:xx",
"fqdn": "node01.example.com",
"identifier": "",
"primary": true,
"provision": true,
"type": "interface"
}
],
"puppetclasses": [],
"config_groups": [],
"all_puppetclasses": [],
"permissions": {
"view_hosts": true,
"create_hosts": true,
"edit_hosts": true,
"destroy_hosts": true,
"build_hosts": true,
"power_hosts": true,
"console_hosts": true,
"ipmi_boot_hosts": true,
"puppetrun_hosts": true,
"view_discovered_hosts": true,
"submit_discovered_hosts": true,
"auto_provision_discovered_hosts": true,
"provision_discovered_hosts": true,
"edit_discovered_hosts": true,
"destroy_discovered_hosts": true,
"view_monitoring_results": true,
"manage_host_downtimes": true
}
}
Hope this helps. Thanks alot.