Bug #30743
openOrder of steps when assigning policy directly to host should not matter
Description
Cloned from https://bugzilla.redhat.com/show_bug.cgi?id=1873842
Description of problem:
If a host is not part of any hostgroup but I am assigning a scap policy at host level, then after the ansible role gets executed, the "/etc/foreman_scap_client/config.yaml" on the host has all the necessary information except the server name i.e. openscap proxy name.
~~- Foreman proxy to which reports should be uploaded
:server:
:port: 9090
~~
How reproducible:
Always on a newly registered host without associating it with any hostgroup
Steps to Reproduce:
1. Register a host to foreman but don't associate any hostgroup.
2. Ensure that the host has openscap proxy selected and assign the "theforeman.foreman_scap_client" role for the host.
3. Assign a policy to that host using the Bulk Action from All Hosts page.
4. Run the "theforeman.foreman_scap_client" role on the host.
5. Check the "/etc/foreman_scap_client/config.yaml" file on the host.
6. Assign the same host to a hostgroup where same policy and scap capsule is selected and then re-run the same job.
7. Check the "/etc/foreman_scap_client/config.yaml" file on the host.
Actual results:
1. At step 5, The entire content of the "/etc/foreman_scap_client/config.yaml" file is OK but the "server" parameter is missing the openscap proxy name.~~
- Foreman proxy to which reports should be uploaded
:server:
:port: 9090
~~
~~
- Foreman proxy to which reports should be uploaded
:server: foreman.example.com
:port: 9090
~~
Expected results:
At step 5 i.e. when the host is not assigned with hostgroup, the content of "/etc/foreman_scap_client/config.yaml" should contain the smart-proxy name as long as correct openscap proxy is assigned at host level.
Additional info:
Reproducible only when scap proxy is assigned to host and policies afterwards. When a policy is assigned first and proxy after that, everything works as expected. foreman_openscap monkey-patches host object to set up variable overrides in after_save callback when scap proxy id changed, therefore policies need to be assigned before the proxy. These actions should not be order-dependent.
No data to display