Hello,
The issue is that -> i dont see facts in input json after foreman discovers
a VM/baremetal.
This is the workflow that i am trying with hooks and foreman discovery
VM/baremetal gets discovered -> JSON input to hooks -> Hooks use the facts
from JSON input to add more facts from CMDB -> Facts get uploaded to
foreman.
I have created the following hooks:
/usr/share/foreman/config/hooks/host/discovered/after_create/10-logger.py
ls /usr/share/foreman-community/hooks/
functions.py functions.pyc init.py
The scripts just get the input json and try to output the json to temp
directory, to help me understand the structure.
However - I dont see facts or any other useful information during input
json.
{
"id": 22,
"name": "mac00163e5426c9",
"last_compile": null,
"last_report": null,
"updated_at": "2017-08-18T20:13:44.058Z",
"created_at": "2017-08-18T20:13:44.058Z",
"root_pass": null,
"architecture_id": null,
"operatingsystem_id": null,
"environment_id": null,
"ptable_id": null,
"medium_id": null,
"build": false,
"comment": null,
"disk": null,
"installed_at": null,
"model_id": null,
"hostgroup_id": null,
"owner_id": null,
"owner_type": null,
"enabled": true,
"puppet_ca_proxy_id": null,
"managed": false,
"use_image": null,
"image_file": null,
"uuid": null,
"compute_resource_id": null,
"puppet_proxy_id": null,
"certname": null,
"image_id": null,
"organization_id": null,
"location_id": null,
"otp": null,
"realm_id": null,
"compute_profile_id": null,
"provision_method": null,
"grub_pass": "",
"global_status": 0,
"lookup_value_matcher": null,
"pxe_loader": null,
"discovery_rule_id": null
}
The workaround that i will have to use to get facts is:
- Extract the mac address from the name -> reformat it -> use that to
query the id of the host with discovery api - Use the id to query the facts of that host.
Do i have to follow the above workaround to get facts of the discovered
system? or am i missing something?
It would be so much easier, if i could just facts in the input json to the
hook.
I am using the following versions foreman and its plugins on CentOS7:
tfm-rubygem-foreman_setup-5.0.0-1.fm1_13.el7.noarch
foreman-release-1.15.3-1.el7.noarch
foreman-installer-1.15.3-1.el7.noarch
foreman-libvirt-1.15.3-1.el7.noarch
foreman-postgresql-1.15.3-1.el7.noarch
tfm-rubygem-foreman_hooks-0.3.14-1.fm1_15.el7.noarch
foreman-selinux-1.15.3-1.el7.noarch
foreman-debug-1.15.3-1.el7.noarch
foreman-release-scl-3-1.el7.noarch
tfm-rubygem-hammer_cli_foreman-0.10.2-1.el7.noarch
tfm-rubygem-foreman_discovery-9.1.1-1.fm1_15.el7.noarch
foreman-cli-1.15.3-1.el7.noarch
tfm-rubygem-foreman_memcache-0.0.6-1.fm1_15.el7.noarch
foreman-proxy-1.15.3-1.el7.noarch
foreman-1.15.3-1.el7.noarch
Thanks,
Lohit