Is it possible to pull/fetch pre-patching and post-patching reporting data from foreman/katello

Problem:
Right now before updating a server, I can obtain the package list that are going to be updated from hammer command as @ehelms mentions here: How can I see which packages are going to be updated and can I create any report out of it?

However if another person does the patching who doesn’t know how to use hammer or let’s say even if I forget to capture this data before patching, is it possible to obtain those same data or similar data after patching? Does it get saved somewhere in the database? Doesn’t need to be a straight hammer command or API call, if it is available from some database query, I can try to test that out.

Foreman and Proxy versions:
Foreman 1.16

Foreman and Proxy plugin versions:
katello 3.4

I don’t think we store this data at the moment, neither it’s available in Pulp

The answer is that it depends on how you initiate the update. @iNecas is correct in that we do not store a historical record the package_profile over time for a host. If you initiate the package updates through Katello then there is a way to get a record of the updates post-action by way of the task data.

Take into account the following caveats:

  1. If you initiate a yum update from the client, then the yum.log is your only way to get some record of what transpired
  2. If you need this task output to be historical, ensure that any task purging you do does not clear these from the database

For any update action that kicked off a package update via katello-agent, get the task ID and go to:

/foreman_tasks/api/tasks/<task_id>

Depending on if the task was initiated by selecting packages or clicking ‘update all’, you should see the package list in one or more of the following fields:

  • output – the resulting updates from the task
  • packages – if you selected packages individually
  • input – the packages selected for update

I believe you can do the same and get similar output via using remote execution that shows up in the input field of the task output.

Here is an example task output to help:

{
"id": "13dc7914-a1b9-41f7-8bcd-871da5100f4b",
"label": "Actions::Katello::Host::Package::Update",
"pending": false,
"username": "ehelms",
"started_at": "2018-02-23 19:33:08 UTC",
"ended_at": "2018-02-23 19:33:20 UTC",
"state": "stopped",
"result": "success",
"progress": 1,
"input": {
"host": {
"id": 1582,
"name": "el7.woodford.example.com"
},
"packages": [
"libgudev1-219-42.el7_4.7.x86_64",
"systemd-219-42.el7_4.7.x86_64",
"systemd-libs-219-42.el7_4.7.x86_64",
"systemd-sysv-219-42.el7_4.7.x86_64",
"vim-common-7.4.160-2.el7.x86_64",
"vim-enhanced-7.4.160-2.el7.x86_64",
"vim-filesystem-7.4.160-2.el7.x86_64",
"vim-minimal-7.4.160-2.el7.x86_64"
],
"services_checked": [
"pulp",
"pulp_auth"
]
},
"output": {},
"humanized": {
"action": "Update package",
"input": [
"libgudev1-219-42.el7_4.7.x86_64, systemd-219-42.el7_4.7.x86_64, systemd-libs-219-42.el7_4.7.x86_64, systemd-sysv-219-42.el7_4.7.x86_64, vim-common-7.4.160-2.el7.x86_64, vim-enhanced-7.4.160-2.el7.x86_64, vim-filesystem-7.4.160-2.el7.x86_64, vim-minimal-7.4.160-2.el7.x86_64"
],
"output": "2:vim-common-7.4.160-2.el7.x86_64\n2:vim-enhanced-7.4.160-2.el7.x86_64\n2:vim-filesystem-7.4.160-2.el7.x86_64\n2:vim-minimal-7.4.160-2.el7.x86_64",
"errors": []
},
"cli_example": null
}
1 Like

Thanks Eric. Much appreciated.

One question: can I view the same tasks from CLI? With hammer or with foreman-tasks? That would be super nice.

I think you can run REX on host and with yum history you can find information

Not today – there is no hammer functionality to spit out task info. This is a gap that we should fill. Would you mind filing a Redmine issue so we can look into it for the next release?