-
Bug
-
Resolution: Unresolved
-
Normal
-
None
-
None
Description of Problem
foreman-rake rh_cloud_inventory:report:upload and foreman-rake rh_cloud_inventory:sync ignore the organization_id env var, because foreman-rake drops env vars as described in SAT-34713. Please rewrite the tasks so that it's possible to pass an org ID to these rake tasks.
How reproducible
Always.
Steps to Reproduce
Execute foreman-rake rh_cloud_inventory:report:upload or foreman-rake rh_cloud_inventory:sync on a satellite.
Actual Behavior
The first half of this if block always executes, never the second half:
if ENV['organization_id'].nil? organizations = Organization.unscoped.all else organizations = [Organization.where(:id => ENV['organization_id']).first] end
Similarly:
desc "Synchronize Hosts inventory" task sync: [:environment, 'dynflow:client'] do if !ENV['organization_id'].nil? organizations = [Organization.where(:id => ENV['organization_id']).first] else organizations = Organization.all end
Example:
# organization_id=3 foreman-rake rh_cloud_inventory:sync Synchronized inventory for organization 'INSIGHTS_QA_6089719_REM' Synchronized inventory for organization 'My_Organization'
Expected Behavior
It's possible to pass a custom org ID. Example:
# organization_id=3 foreman-rake rh_cloud_inventory:sync Synchronized inventory for organization 'INSIGHTS_QA_6089719_REM'
Business Impact / Additional info
Rewrite the task to instead prompt for an org ID. Do not attempt to make the rake task read an env var; we already looked into this option in SAT-34713 and found the option fruitless.
Rake task definition: https://github.com/theforeman/foreman_rh_cloud/blob/foreman_3_14/lib/tasks/rh_cloud_inventory.rake