Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 67 additions & 1 deletion roles/wildfly_migration/tasks/install/rhn.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,70 @@
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
- rhn_username is defined
- rhn_password is defined
- eap_version is defined
quiet: True
fail_msg: "Missing required parameters."

- name: "Esclade privileges if needed"

Check warning on line 12 in roles/wildfly_migration/tasks/install/rhn.yml

View workflow job for this annotation

GitHub Actions / ci / linter (3.12, 2.19)

key-order[task]

You can improve the task key order to: name, become, become_user, block

Check warning on line 12 in roles/wildfly_migration/tasks/install/rhn.yml

View workflow job for this annotation

GitHub Actions / ci / linter (3.12, 2.18)

key-order[task]

You can improve the task key order to: name, become, become_user, block

Check warning on line 12 in roles/wildfly_migration/tasks/install/rhn.yml

View workflow job for this annotation

GitHub Actions / ci / linter (3.12, 2.20)

key-order[task]

You can improve the task key order to: name, become, become_user, block
block:
- name: "Query RHN to find migration tool for EAP {{ eap_version }}"
redhat.runtimes_common.product_search:
client_id: "{{ rhn_username }}"
client_secret: "{{ rhn_password }}"
product_type: DISTRIBUTION
product_version: "{{ eap_version | regex_replace('([0-9]+)[.]([0-9]+)[.][0-9]+[.]?([A-Za-z]+)?', '\\1.\\2 \\3') }}"
product_category: "appplatform"
register: rhn_migration_search
no_log: "{{ omit_rhn_output | default(true) }}"
delegate_to: localhost
run_once: true

- name: "Determine major.minor version for fallback"
ansible.builtin.set_fact:
eap_major_minor: "{{ (eap_version.split('.'))[0:2] | join('.') }}"
delegate_to: localhost
run_once: true

- name: "Try to find exact version migration tool first"
ansible.builtin.set_fact:
eap_migration_tool_found: "{{ rhn_migration_search.results | selectattr('file_path', 'match', '.*jboss-eap-' + eap_version + '-server-migration.zip$') | list }}"
delegate_to: localhost
run_once: true

- name: "If exact version not found, use base version (X.Y.0) migration tool"
ansible.builtin.set_fact:
eap_migration_tool_found: "{{ rhn_migration_search.results | selectattr('file_path', 'match', '.*jboss-eap-' + eap_major_minor + '.0-server-migration.zip$') | list }}"
when:
- eap_migration_tool_found | length == 0
delegate_to: localhost
run_once: true

- name: "Verify migration tool was found in RHN"
ansible.builtin.assert:
that:
- eap_migration_tool_found | length > 0
- (eap_migration_tool_found | first).id is defined
quiet: True
fail_msg: "Migration tool for EAP {{ eap_version }} (or base {{ eap_major_minor }}.0) not found in RHN. Available migration tools: {{ rhn_migration_search.results | selectattr('file_path', 'match', '.*server-migration.zip$') | map(attribute='file_path') | list }}"

- name: "Set migration tool product ID from RHN query"
ansible.builtin.set_fact:
eap_migration_server_tool_product_id: "{{ (eap_migration_tool_found | first).id }}"
eap_migration_tool_actual_file: "{{ (eap_migration_tool_found | first).file_path }}"
delegate_to: localhost
run_once: true

- name: "Display discovered migration tool"
ansible.builtin.debug:
msg:
- "Discovered migration tool from RHN:"
- " Target Version: {{ eap_version }}"
- " Migration Tool: {{ eap_migration_tool_actual_file }}"
- " Product ID: {{ eap_migration_server_tool_product_id }}"
- " Note: {{ 'Using base ' + eap_major_minor + '.0 tool (compatible with all ' + eap_major_minor + '.x versions)' if (eap_migration_tool_actual_file.find(eap_version) == -1) else 'Exact version match' }}"

- name: "Load metadata on server migration tool archive"
ansible.builtin.stat:
path: "{{ eap_migration_server_tool_path_to_archive }}"
Expand Down Expand Up @@ -49,6 +107,14 @@
when:
- not eap_migration_script_stat.stat.exists

- name: "Ensure migration tool logs directory exists"
ansible.builtin.file:
path: "{{ eap_migration_server_tool_install_dir }}/jboss-server-migration/logs"
state: directory
mode: "0755"
owner: "{{ wildfly_user | default(omit) }}"
group: "{{ wildfly_group | default(omit) }}"

- name: "Set EAP migration tool paths for EAP 8.0+"
ansible.builtin.set_fact:
wildfly_migration_server_tool_home: "{{ eap_migration_server_tool_install_dir }}/jboss-server-migration"
Expand Down
8 changes: 8 additions & 0 deletions roles/wildfly_migration/tasks/install/web.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
- name: "Escalate privileges if needed"

Check warning on line 2 in roles/wildfly_migration/tasks/install/web.yml

View workflow job for this annotation

GitHub Actions / ci / linter (3.12, 2.19)

key-order[task]

You can improve the task key order to: name, become, become_user, block

Check warning on line 2 in roles/wildfly_migration/tasks/install/web.yml

View workflow job for this annotation

GitHub Actions / ci / linter (3.12, 2.18)

key-order[task]

You can improve the task key order to: name, become, become_user, block

Check warning on line 2 in roles/wildfly_migration/tasks/install/web.yml

View workflow job for this annotation

GitHub Actions / ci / linter (3.12, 2.20)

key-order[task]

You can improve the task key order to: name, become, become_user, block
block:
- name: "Set migration tool version based on target WildFly version"
ansible.builtin.set_fact:
Expand Down Expand Up @@ -38,5 +38,13 @@
when:
- not wildfly_migration_script_stat.stat.exists

- name: "Ensure migration tool logs directory exists"
ansible.builtin.file:
path: "{{ wildfly_migration_server_tool_home }}/logs"
state: directory
mode: "0755"
owner: "{{ wildfly_user | default(omit) }}"
group: "{{ wildfly_group | default(omit) }}"

become: "{{ wildfly_migration_require_privileges_escalation | default('yes') }}"
become_user: "{{ wildfly_migration_jdk_package_install_requires_privileges_escalation_user | default('root') }}"
2 changes: 2 additions & 0 deletions roles/wildfly_uninstall/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ wildfly uninstall role

Role to uninstall WildFly and clean the target nodes.

NOTE: The migration role will only migrate to the latest version of wildfly

<!--start argument_specs-->
Role Defaults
-------------
Expand Down
Loading