-
Notifications
You must be signed in to change notification settings - Fork 33
Add migration subcommand #446
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
66c5ea5
8fbd25a
10d4141
a00ae49
8fd740b
6bcd56b
262c1ed
523b8ed
9b1867f
630a418
5917b6b
3201abf
da48e99
18ad6d1
0b538d1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,138 @@ | ||
| # Migrating from foreman-installer to foremanctl | ||
|
|
||
| ## Overview | ||
|
|
||
| When upgrading from foreman-installer to foremanctl, the `foremanctl migrate` command helps convert your existing configuration to the new format. | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you think it would be good to have steps here to install foremanctl on foreman-installer based setups?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think since this guide is about how to upgrade from foreman-installer to foremanctl, that it should cover those steps for now. Like, prerequisites (e.g. foreman-installer installed, foremanctl present on the system) then run the steps. Or point to docs and say what steps should be run. |
||
|
|
||
| This guide explains how to migrate your foreman-installer answer files to foremanctl configuration files. | ||
|
|
||
| ## Prerequisites | ||
|
|
||
| Before migrating, ensure the following: | ||
|
|
||
| 1. **Foreman deployment using foreman-installer** - You should have an existing Foreman deployment has been installed using foreman-installer and has an answers file to migrate from. | ||
|
|
||
| 2. **foremanctl is installed** on the system: | ||
| ```bash | ||
| # Enable the foremanctl repository | ||
| dnf copr enable @theforeman/foremanctl rhel-9-x86_64 | ||
|
|
||
| # Install foremanctl | ||
| dnf install foremanctl | ||
| ``` | ||
|
|
||
| For more installation options, see the main [README](../README.md#packages). | ||
|
|
||
| ## Migration Workflow | ||
|
|
||
| 1. **Generate the migrated configuration**: | ||
| ```bash | ||
| foremanctl migrate --output /var/lib/foremanctl/parameters.yaml | ||
| ``` | ||
|
|
||
| 2. **Review the output** for any warnings about unmapped parameters | ||
|
|
||
| 3. **Use the migrated configuration** with foremanctl: | ||
| ```bash | ||
| foremanctl deploy | ||
| ``` | ||
| (foremanctl automatically loads configuration from `/var/lib/foremanctl/parameters.yaml`) | ||
|
|
||
| ## Command Usage | ||
|
|
||
| ### Basic Migration | ||
|
|
||
| Migrate from the default location (reads the currently active scenario): | ||
| ```bash | ||
| foremanctl migrate --output /var/lib/foremanctl/parameters.yaml | ||
| ``` | ||
|
|
||
| ### Custom Answer File | ||
|
|
||
| Migrate from a specific answer file: | ||
| ```bash | ||
| foremanctl migrate --answer-file /path/to/custom-answers.yaml --output /var/lib/foremanctl/parameters.yaml | ||
| ``` | ||
|
|
||
| ### Output to stdout | ||
|
|
||
| Preview the migrated configuration without writing a file: | ||
| ```bash | ||
| foremanctl migrate | ||
| ``` | ||
|
|
||
| ## Command Options | ||
|
|
||
| - `--answer-file PATH` - Path to the foreman-installer answer file. If not specified, reads the currently active scenario and extracts the answer file path from it. | ||
| - `--output PATH` - Path for the migrated configuration (default: stdout) | ||
|
|
||
| > [!NOTE] | ||
| > Unlike other `foremanctl` commands, migrate does not persist parameters between runs. Each migration is independent. | ||
|
|
||
| ## Parameter Mappings | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We have an overlap now with
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i've linked it, looks better? |
||
|
|
||
| The migrate command automatically maps foreman-installer parameters to foremanctl parameters. For a complete list of all parameter mappings, see the [Parameters documentation](parameters.md#mapping). | ||
|
|
||
| ## Example | ||
|
|
||
| Below is an example showing how the transformation works: | ||
|
|
||
| ### Input (foreman-installer format) | ||
|
|
||
| ```yaml | ||
| foreman: | ||
| db_host: database.example.com | ||
| db_port: 5432 | ||
| db_database: foreman | ||
| db_username: foreman_user | ||
| db_password: secret123 | ||
| db_manage: true | ||
| initial_admin_username: admin | ||
| initial_admin_password: changeme | ||
| ``` | ||
|
|
||
| ### Output (foremanctl format) | ||
|
|
||
| ```yaml | ||
| database_host: database.example.com | ||
| database_port: 5432 | ||
| database_mode: external | ||
| foreman_database_name: foreman | ||
| foreman_database_password: secret123 | ||
| foreman_database_user: foreman_user | ||
| foreman_initial_admin_password: changeme | ||
| foreman_initial_admin_username: admin | ||
| ``` | ||
|
|
||
| ## Handling Unmapped Parameters | ||
|
|
||
| When the migration completes, you may see warnings like: | ||
|
|
||
| > [!WARNING] | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is going to be tricky in practice. Users will need guidance on parameters that could not be mapped. Perhaps for now we can include as part of the warning output the high-level possible reasons they could not be mapped? For example:
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think that's something that we'll have to learn (and document) as we go.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, that is something we can focus on follow up work as well. Thanks for pointing it out. |
||
| > The following parameters could not be mapped: | ||
| > - katello::enable_ostree | ||
| > - foreman::some_other_param | ||
|
|
||
| These parameters need to be manually reviewed and added to the new configuration if needed. Check the [parameters documentation](parameters.md) for equivalent foremanctl parameters. | ||
|
evgeni marked this conversation as resolved.
|
||
|
|
||
| ## Using the Migrated Configuration | ||
|
|
||
| Once you've generated and reviewed the migrated configuration: | ||
|
|
||
| 1. **Save it to the foremanctl parameters file**: | ||
| ```bash | ||
| # Either generate directly to the parameters file | ||
| foremanctl migrate --output /var/lib/foremanctl/parameters.yaml | ||
|
|
||
| # Or copy after review | ||
| foremanctl migrate --output /tmp/migrated.yaml | ||
| # Review /tmp/migrated.yaml | ||
| cp /tmp/migrated.yaml /var/lib/foremanctl/parameters.yaml | ||
| ``` | ||
|
|
||
| 2. **Deploy using foremanctl**: | ||
| ```bash | ||
| foremanctl deploy | ||
| ``` | ||
|
|
||
| The `foremanctl deploy` command automatically loads configuration from `/var/lib/foremanctl/parameters.yaml`. | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| --- | ||
| help: | | ||
| Migrate foreman-installer answer file to foremanctl configuration format. | ||
|
|
||
| This command reads foreman-installer answer files and converts them to the | ||
| new foremanctl configuration format. Unmappable parameters are reported | ||
| as warnings but do not cause the command to fail. | ||
|
|
||
| variables: | ||
| answer_file: | ||
|
evgeni marked this conversation as resolved.
|
||
| help: Path to the foreman-installer answer file to migrate. If not specified, attempts to read from the default location. | ||
| persist: false | ||
| output: | ||
| help: Path where the migrated configuration should be written. If not specified, outputs to stdout. | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If not specified, it outputs to stdout currently, so just a thought should we also put those into default config /var/lib/foremanctl/parameters.yaml as well?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I kept stdout as the default for the safer side, so that users can review output before it overwrites existing config. However, I believe we could document the recommended command:
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That logic makes sense to me. |
||
| persist: false | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| --- | ||
| - name: Migrate foreman-installer answer file to foremanctl format | ||
| hosts: | ||
| - quadlet | ||
| gather_facts: false | ||
| tasks: | ||
| - name: Run migration | ||
| migrate_answers: | ||
| answer_file: "{{ answer_file | default(omit) }}" | ||
| output: "{{ output | default(omit) }}" | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if I pass
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. no it was not expected, i see a bug now, let me fix that and address other comments as well |
||
| working_directory: "{{ lookup('env', 'PWD') }}" | ||
| register: migration_result | ||
|
|
||
| - name: Display migrated configuration to stdout | ||
| when: migration_result.output_content | default('') != '' | ||
| ansible.builtin.debug: | ||
| msg: "{{ migration_result.output_content }}" | ||
|
|
||
| - name: Display migration results | ||
| ansible.builtin.debug: | ||
| msg: | ||
| - "Migration completed successfully!" | ||
| - "Mapped parameters: {{ migration_result.mapped_count }}" | ||
| - "Unmappable parameters: {{ migration_result.unmappable_count }}" | ||
| - "{{ _unmappable_warning if migration_result.unmappable | length > 0 else '' }}" | ||
| - "{{ _output_file_msg if migration_result.output_file is defined else '' }}" | ||
| vars: | ||
| _unmappable_warning: "Warning: {{ migration_result.unmappable | length }} parameter(s) could not be mapped - see warnings above" | ||
| _output_file_msg: "Output written to: {{ migration_result.output_file }}" | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given the title and focus of the doc, I think the filename could use an update to reflect this.