-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
migration: rework role to support (downstream) EAP8 and allow user to…
… configure JVM used by the migration tool
- Loading branch information
Showing
8 changed files
with
233 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,14 @@ | ||
--- | ||
wildfly_migration_environment_props: templates/environment.properties.j2 | ||
wildfy_migration_require_privileges_escalation: true | ||
wildfly_migration_java_home: '/usr/lib/jvm/jre' | ||
wildfly_migration_jdk_package_name: 'java-17-openjdk-devel' | ||
wildfly_migration_jdk_package_skip_install: False | ||
wildfly_migration_server_tool_home: "{{ target_wildfly_home }}" | ||
wildfly_migration_tool_bin_folder: 'bin' | ||
wildfly_migration_tool_bin_script_name: 'jboss-server-migration.sh' | ||
wildfly_migration_server_tool_path_to_script: "{{ wildfly_migration_server_tool_home }}/{{ wildfly_migration_tool_bin_folder }}/{{ wildfly_migration_tool_bin_script_name }}" | ||
wildfly_migration_server_tool_subfolder_to_configuration: '/migration' | ||
wildfly_migration_server_tool_env_properties_file: 'configuration/environment.properties' | ||
wildfly_migration_path_to_env_properties: "{{ wildfly_migration_server_tool_home }}{{ wildfly_migration_server_tool_subfolder_to_configuration }}/{{ wildfly_migration_server_tool_env_properties_file }}" | ||
wildfly_migration_config_files: 'standalone.xml,standalone-full.xml' | ||
wildfly_migration_tool_configuration_template: 'templates/environment.properties.j2' | ||
wildfly_migration_require_privileges_escalation: True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,105 @@ | ||
argument_specs: | ||
main: | ||
options: | ||
# line 2 of defaults/main.yml | ||
target_wildfly_home: | ||
required: True | ||
description: "Path on the target to the server's home to migrate to" | ||
type: "str" | ||
previous_wildfly_home: | ||
required: True | ||
description: "Path on the target to the server's home to migrate from" | ||
type: "str" | ||
wildfly_migration_environment_props: | ||
default: "templates/environment.properties.j2" | ||
description: "Template to configure the migration tool" | ||
type: "str" | ||
wildfy_migration_require_privileges_escalation: | ||
default: True | ||
description: "Indicate if the server migration tool requires privileges escalation" | ||
type: "str" | ||
wildfly_migration_server_tool_home: | ||
default: "{{ target_wildfly_home }}" | ||
description: "Path to the server migration tool" | ||
type: "str" | ||
wildfly_migration_tool_bin_folder: | ||
default: "" | ||
description: "Folder, relatives to wildfly_migration_server_tool_home where the server migration tool script resides" | ||
type: "str" | ||
wildfly_migration_tool_bin_script_name: | ||
default: "jboss-server-migration.sh" | ||
description: "Name of the script lauching the server migration tool" | ||
type: "str" | ||
wildfly_migration_server_tool_path_to_script: | ||
default: "{{ wildfly_migration_server_tool_home }}/{{ wildfly_migration_tool_bin_folder }}/ {{ wildfly_migration_tool_bin_script_name }}" | ||
description: "Path to the script launching the server migration tool" | ||
type: "str" | ||
wildfly_migration_server_tool_subfolder_to_configuration: | ||
default: "/migration" | ||
description: "Subfolder, relatrives to server migration" | ||
type: "str" | ||
wildfly_migration_server_tool_env_properties_file: | ||
default: "configuration/environment.properties" | ||
description: "Relative path of the main configuration file of the server migration tool" | ||
type: "str" | ||
wildfly_migration_path_to_env_properties: | ||
description: "Absolute path to the main configuration" | ||
default: "{{ wildfly_migration_server_tool_home }}{{ wildfly_migration_server_tool_subfolder_to_configuration }}/{{ wildfly_migration_server_tool_env_properties_file }}" | ||
type: "str" | ||
wildfly_migration_config_files: | ||
default: 'standalone.xml,standalone-full.xml' | ||
description: "Name(s) of the configuration files to migrate to the new server" | ||
type: "str" | ||
wildfly_migration_tool_configuration_template: | ||
default: 'templates/environment.properties.j2' | ||
description: "Relative path to the jinja template for the server tool migration main configuration file" | ||
type: "str" | ||
wildfly_migration_require_privileges_escalation: | ||
default: True | ||
description: "Indicates whether or the migration server tool requires root privileges to run" | ||
type: "str" | ||
wildfly_migration_java_home: | ||
default: "/usr/lib/jvm/jre" | ||
description: "Path to the JAVA HOME to be used by the server migration tool" | ||
type: "str" | ||
wildfly_migration_jdk_package_name: | ||
default: "java-17-openjdk-devel" | ||
description: "Name of the RPM package to install for the JVM used by the server migration tool" | ||
type: "str" | ||
wildfly_migration_jdk_package_skip_install: | ||
default: False | ||
description: "Indicates if the install check of the RPM package for the JVM of the migration server tool can be skipped" | ||
type: "bool" | ||
downstream: | ||
options: | ||
eap_enable: | ||
default: True | ||
description: "Enable install of Red Hat JBoss EAP" | ||
type: "bool" | ||
eap_migration_server_tool_path_to_archive: | ||
default: "/opt/jboss-eap-{{ eap_version }}-server-migration.zip" | ||
description: "Path to the Red Hat provided archive for the server migration tool" | ||
type: "str" | ||
eap_migration_server_tool_product_id: | ||
default: 106310 | ||
description: "Red Hat ID for the server migration tool archive" | ||
type: "int" | ||
eap_migration_server_download_node: | ||
default: "localhost" | ||
description: "Hostname of the node used to download the server migration archive provided by Red Hat Customer Portal" | ||
type: "str" | ||
eap_migration_server_tool_install_dir: | ||
default: "/opt" | ||
description: "Directory where to install the server migration tool - if not provided with EAP" | ||
type: "str" | ||
eap_migration_server_tool_home: | ||
default: "{{ (eap_version != '8.0.0') | ternary(target_eap_home,'/opt/jboss-server-migration') }}" | ||
description: "Path to the server migration tool home - if not provided with EAP" | ||
type: "str" | ||
eap_migration_tool_bin_folder: | ||
default: "{{ (eap_version != '8.0.0') | ternary('/bin','') }}" | ||
description: "Indicates which subfolder, relative to eap_migration_server_tool_home, the server migration script resides." | ||
type: "str" | ||
eap_migration_server_tool_subfolder_to_configuration: | ||
default: "{{ (eap_version != '8.0.0') | ternary('/migration', '') }}" | ||
description: "Subfolder, relatives to eap_migration_server_tool_home, where are located server migration tool configurations files" | ||
type: "str" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
--- | ||
- name: "Ensure required parameters are provided." | ||
ansible.builtin.assert: | ||
that: | ||
- eap_migration_server_tool_path_to_archive is defined and eap_migration_server_tool_path_to_archive | length > 0 | ||
- eap_migration_server_tool_product_id is defined > 0 | ||
quiet: True | ||
fail_msg: "Missing required parameters." | ||
|
||
- name: "Load metadata on Migration Toolkit archive for EAP8" | ||
ansible.builtin.stat: | ||
path: "{{ eap_migration_server_tool_path_to_archive }}" | ||
register: eap_migration_archive_md | ||
delegate_to: "{{ eap_migration_server_download_node | default(omit) }}" | ||
|
||
- name: "Ensure Migration Toolkit for EAP8 has been downloaded" | ||
redhat.runtimes_common.product_download: | ||
client_id: "{{ rhn_username }}" | ||
client_secret: "{{ rhn_password }}" | ||
product_id: "{{ eap_migration_server_tool_product_id }}" | ||
dest: "{{ eap_migration_server_tool_path_to_archive }}" | ||
no_log: "{{ omit_rhn_output | default(true) }}" | ||
delegate_to: "{{ eap_migration_server_download_node | default(omit) }}" | ||
run_once: true | ||
when: | ||
- eap_migration_archive_md is defined | ||
- eap_migration_archive_md.stat is defined | ||
- eap_migration_archive_md.stat.exists is defined | ||
- not eap_migration_archive_md.stat.exists | ||
|
||
- name: "Compute archive is local to control or remote" | ||
ansible.builtin.set_fact: | ||
eap_migration_remote_src: no | ||
when: | ||
- eap_migration_server_download_node is defined | ||
- eap_migration_server_download_node == 'localhost' | ||
|
||
- name: "Ensure Migration Toolkit for EAP8 has been decompressed" | ||
ansible.builtin.unarchive: | ||
src: "{{ eap_migration_server_tool_path_to_archive }}" | ||
dest: "{{ eap_migration_server_tool_install_dir }}" | ||
remote_src: "{{ eap_migration_remote_src | default('yes') }}" | ||
creates: "{{ eap_migration_server_tool_path_to_script }}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
--- | ||
- name: "Load metadata on migration tool full path." | ||
ansible.builtin.stat: | ||
path: "{{ wildfly_migration_server_tool_path_to_script }}" | ||
register: migration_tool_state | ||
|
||
- name: "Check that path to migration tool is valid." | ||
ansible.builtin.assert: | ||
that: | ||
- migration_tool_state is defined | ||
- migration_tool_state.stat is defined | ||
- migration_tool_state.stat.exists is defined | ||
- migration_tool_state.stat.exists | ||
- migration_tool_state.stat.isreg is defined | ||
- migration_tool_state.stat.isreg | ||
quiet: True | ||
fail_msg: "Invalid path to migration tool: {{ wildfly_migration_server_tool_path_to_script }}." | ||
|
||
- name: "Ensure all files belong to the appropriate user: {{ wildfly_user }}/{{ wildfly_group }}" | ||
ansible.builtin.file: | ||
path: "{{ folder }}" | ||
recurse: yes | ||
owner: "{{ wildfly_user }}" | ||
group: "{{ wildfly_group }}" | ||
changed_when: False | ||
loop: | ||
- "{{ previous_wildfly_home }}" | ||
- "{{ target_wildfly_home }}" | ||
- "{{ wildfly_migration_server_tool_home }}" | ||
loop_control: | ||
loop_var: folder | ||
when: | ||
- not wildfly_migration_skip_file_ownership_check is defined | ||
- wildfly_user is defined and wildfly_user | length > 0 | ||
- wildfly_group is defined and wildfly_group | length > 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
--- | ||
- name: "Verify that Server Migration tool can run" | ||
ansible.builtin.include_tasks: prerun_checks.yml | ||
|
||
- name: "Lookup value of PATH on target" | ||
ansible.builtin.set_fact: | ||
target_path: "{{ lookup('env', 'PATH') }}" | ||
|
||
- name: "Run migration tool" | ||
become: yes | ||
become_user: wildfly | ||
ansible.builtin.command: "{{ wildfly_migration_server_tool_path_to_script }} --non-interactive --source {{ previous_wildfly_home }} --environment {{ wildfly_migration_path_to_env_properties }} --target {{ target_wildfly_home }}" | ||
register: migration_results | ||
changed_when: False | ||
failed_when: False | ||
environment: | ||
JAVA_HOME: "{{ wildfly_migration_java_home }}" | ||
PATH: "{{ wildfly_migration_java_home }}{{ target_path }}" | ||
|
||
- name: "Fails if command did not produced any result" | ||
ansible.builtin.fail: | ||
var: "{{ ansible_failed_task | default('Migration command failed to produce any results') }}" | ||
when: | ||
- not migration_results is defined |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.