Skip to content

Conversation

@ashiqueps
Copy link
Contributor

Description

This is a follow-up PR for #408. In this PR, we're primarily focusing on synchronising the install.sh/ps1 templates with the latest versions from the download APIs and adding support for the chef-ice product.

The changes enhance both Bash (install.sh) and PowerShell (install.ps1) script templates to support:

  1. Chef-ICE Product Support: Special handling for chef-ice product which uses package_manager (pm) parameter instead of platform_version (pv)
  2. Download API Sync: Templates updated to match the latest install.sh/ps1 structure from the download APIs
  3. Dynamic Filename Resolution: New endpoint integration to fetch actual filenames for licensed downloads
  4. Backward Compatibility: Maintains full compatibility with traditional Omnitruck API when no license_id is provided

Changes Made

Bash Script Templates (Bourne)

Modified Files:

  • lib/mixlib/install/generator/base.rb

    • Added omnitruck_endpoint calculation logic based on license_id
    • Ensures proper endpoint selection (trial/commercial/omnitruck) in ERB template context
  • lib/mixlib/install/generator/bourne.rb

    • Updated to pass base_url and license_id context to fetch_package.sh.erb
  • lib/mixlib/install/generator/bourne/scripts/platform_detection.sh

    • Added determine_package_type() function for detecting .rpm, .deb, .msi, .pkg, .dmg extensions
    • Added package_manager detection logic (auto-detects based on system)
    • Added chef-ice product validation (auto-sets package_manager=msi)
    • Added migrate-ice product validation (throws error - unsupported)
  • lib/mixlib/install/generator/bourne/scripts/script_cli_parameters.sh.erb

    • Added new flag -i for package_manager parameter
    • Maintains backward compatibility with existing flags
  • lib/mixlib/install/generator/bourne/scripts/fetch_metadata.sh.erb

    • Added conditional logic for license_id-based API vs traditional Omnitruck
    • Integrated modify_response function for JSON to text format conversion
    • Added chef-ice special handling (uses pm instead of pv parameter)
  • lib/mixlib/install/generator/bourne/scripts/fetch_package.sh → fetch_package.sh.erb

    • Renamed to .erb to enable ERB template processing
    • Added fileName endpoint integration for licensed downloads
  • lib/mixlib/install/generator/bourne/scripts/helpers.sh.erb

    • Added modify_response() function to convert JSON API responses to text format
    • Extracts url and sha256 fields from JSON for compatibility with existing code

PowerShell Script Templates

Modified Files:

  • lib/mixlib/install/generator/powershell.rb
    • Added get_project_filename.ps1 script inclusion in both class and instance methods
    • Updated script loading order: helpers → metadata → filename → install

New Files:

  • lib/mixlib/install/generator/powershell/scripts/get_project_filename.ps1.erb
    • New function Get-ProjectFileName for fetching actual filenames from /fileName endpoint
    • Supports license_id for commercial/trial API access
    • Handles chef-ice product with pm=msi parameter
    • Includes JSON parsing with ConvertFrom-Json
    • Error handling with fallback logic

Updated Files:

  • lib/mixlib/install/generator/powershell/scripts/get_project_metadata.ps1.erb

    • Added package_manager parameter (validateset: msi, pm)
    • Added chef-ice conditional logic (uses pm=msi instead of pv)
    • Added migrate-ice validation (throws error as unsupported)
    • Maintains license_id backward compatibility with omnitruck API
  • lib/mixlib/install/generator/powershell/scripts/install_project.ps1.erb

    • Added package_manager parameter with automatic detection
    • Chef-ice: auto-sets package_manager=msi
    • Standard products: uses pm parameter
    • Replaced Content-Disposition header extraction with Get-ProjectFileName API call
    • Simplified download logic - now uses dedicated filename endpoint
    • Enhanced error messages with log file paths and tail output

Related Issue

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Chore (non-breaking change that does not add functionality or fix an issue)

Checklist:

  • I have read the CONTRIBUTING document.
  • I have run the pre-merge tests locally and they pass.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • If Gemfile.lock has changed, I have used --conservative to do it and included the full output in the Description above.
  • All new and existing tests passed.
  • All commits have been signed-off for the Developer Certificate of Origin.

Signed-off-by: Ashique Saidalavi <Ashique.saidalavi@progress.com>
@sonarqubecloud
Copy link

Comment on lines +209 to +235
determine_package_type() {
case "$platform" in
"debian"|"ubuntu"|"linuxmint")
echo "deb"
;;
"centos"|"redhat"|"fedora"|"rocky"|"amazon"|"el")
echo "rpm"
;;
"sles"|"opensuseleap")
echo "rpm"
;;
"aix")
echo "bff"
;;
"solaris2")
echo "pkg"
;;
"mac_os_x")
echo "dmg"
;;
*)
echo "Unknown package type"
report_bug
exit 1
;;
esac
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This limit's what OS's are able to download where in the past due to many debian/ubuntu/rhel variants out there we have supported chef-client being able to be installed on those systems but are not officially supported and are self-supported by the users.

Comment on lines +49 to +54
if test -d "/opt/$project" && test "x$install_strategy" = "xonce"; then
echo "$project installation detected"
echo "install_strategy set to 'once'"
echo "Nothing to install"
exit
fi
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This only checks for the omnibus version of chef-client and doesn't support the new habitat pathing/packaging check. So chef-ice will repeat installing on every test-kitchen subsequent runs.

# $tmp_dir:
#
# $license_id
# $package_manager:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what does this new package_manager do and or used for? how does this affect linux clients?

@ashiqueps ashiqueps changed the title Install.sh/ps1 updates for chef-ice [CHEF-29379] Install.sh/ps1 updates for chef-ice Jan 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants