Skip to content
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

Fix eap-migration-demo in Olympus #1

Merged
merged 1 commit into from
Aug 5, 2024
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
22 changes: 11 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Wildfly Migration
This repository contains a set of Ansible based playbooks that demonstrate how to use a the [JBoss Migration tool](https://access.redhat.com/documentation/en-us/red_hat_jboss_enterprise_application_platform/7.1/html/using_the_jboss_server_migration_tool/index) to migrate the configuration of a Wildfly or JBoss EAP
instance to a newer version.

Note: this demonstration is using JBoss EAP rpm installation and the Red Hat productized collection (redhat.jboss_eap) available on Automation Hub. Thus it requires access to those assets. However, the content can easily be adapted to use the upstream version of JBoss EAP (Wildfly) and the upstream version of the collection [Wildfly](https://github.com/middleware_automation/wildfly)
Note: this demonstration is using JBoss EAP rpm installation and the Red Hat productized collection (redhat.eap) available on Automation Hub. Thus it requires access to those assets. However, the content can easily be adapted to use the upstream version of JBoss EAP (Wildfly) and the upstream version of the collection [Wildfly](https://github.com/middleware_automation/wildfly)

## Prerequistes

Expand All @@ -23,15 +23,15 @@ As this demo uses a collection available on [Red Hat Automation Hub](https://www

token=<your-token>

The playbook prepare_migration expects the jboss-eap-7.3.zip to be available on the target system (localhost), you'll need to retrieve this archive from the [Red Hat Customers portal](https://access.redhat.com/).
The playbook prepare_migration expects the jboss-eap-7.3.0.zip to be available on the target system (localhost), you'll need to retrieve this archive from the [Red Hat Customers portal](https://access.redhat.com/).

## Set up

Three playbooks compose this demo:

1. setup_eap.yml - this playbook will setup and configure the EAP 7.2 instance to use a MariaDB datasources and deploy the associated JDBC driver.
1. setup_eap.yml - this playbook will setup and configure the EAP 7.2.0 instance to use a MariaDB datasources and deploy the associated JDBC driver.

2. prepare_migration - this playbook prepare the migration from EAP 7.2 to EAP 7.3
2. prepare_migration - this playbook prepare the migration from EAP 7.2.0 to EAP 7.3.0

3. perform_migration - this playbook execute the migration

Expand All @@ -45,9 +45,9 @@ Then you can simply each playbook, one after the other:

$ ansible-playbook -i inventory setup_eap.yml

At the end of this first playbook's execution, the 'jboss_eap' service is running and the instance is configured to use MariaDB:
At the end of this first playbook's execution, the 'eap' service is running and the instance is configured to use MariaDB:

# systemctl status jboss_eap
# systemctl status eap
# /opt/rh/eap7/root/usr/share/wildfly/bin/jboss-cli.sh --connect
[standalone@localhost:9990 /] ls /subsystem=datasources/data-source=
ExampleDS MariaDBPool
Expand All @@ -60,13 +60,13 @@ And finally, perform the migration itself:

$ ansible-playbook -i inventory perform_migration.yml

Note that the same playbooks can be used to migrate again from 7.3 to 7.4 :
Note that the same playbooks can be used to migrate again from 7.3.0 to 7.4.0 :

$ ansible-playbook -i inventory \
-e eap_source_version=7.3 \
-e target_eap_version=7.4 \
-e eap_source_version=7.3.0 \
-e target_eap_version=7.4.0 \
prepare_migration.yml
$ ansible-playbook -i inventory \
-e eap_source_version=7.3 \
-e target_eap_version=7.4 \
-e eap_source_version=7.3.0 \
-e target_eap_version=7.4.0 \
perform_migration.yml
23 changes: 0 additions & 23 deletions molecule/default/prepare.yml

This file was deleted.

3 changes: 1 addition & 2 deletions molecule/default/requirements.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,4 @@ collections:
- name: community.general
- name: community.docker
- name: ansible.posix
- name: redhat.jboss_eap
version: ">=1.1.0"
- name: redhat.eap
34 changes: 20 additions & 14 deletions molecule/default/verify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,33 @@
hosts: instance
vars:
mariadb_ds: MariaDBPool
jboss_eap_service_name: jboss_eap.service
jboss_eap_home: /opt/rh/eap7/root/usr/share/wildfly/
eap_service_name: eap.service
target_eap_version: 7.4.0
target_eap_home: "{{ eap_install_workdir }}/jboss-eap-{{ (target_eap_version.split('.'))[0:2] | join('.') }}/"
vars_files:
- ../../vars/jdbc_driver.yml
- ../../vars/eap_system_info.yml
collections:
- redhat.jboss_eap
- redhat.eap
tasks:
- name: Populate service facts
ansible.builtin.service_facts:
- name: Populate service facts
ansible.builtin.service_facts:

- name: "Check that JBoss EAP service '{{ jboss_eap_service_name }}' is running."
- name: "Check that JBoss EAP service '{{ eap_service_name }}' is running."
ansible.builtin.assert:
that:
- ansible_facts is defined
- ansible_facts.services is defined
- ansible_facts.services[jboss_eap_service_name] is defined
- ansible_facts.services[jboss_eap_service_name]['state'] == 'running'
- ansible_facts is defined
- ansible_facts.services is defined
- ansible_facts.services[eap_service_name] is defined
- ansible_facts.services[eap_service_name]['state'] == 'running'
quiet: True

- name: "Check that MariaDB DS is defined."
- name: "Deploy MariaDB driver is activated"
ansible.builtin.include_role:
name: jboss_eap_utils
name: eap_utils
tasks_from: jboss_cli.yml
vars:
jboss_home: "{{ jboss_eap_home }}"
query: "/subsystem=datasources/jdbc-driver={{ jdbc_driver_module_name }}:read-resource"
eap_home: "{{ target_eap_home }}"
jboss_cli_query: "{{ item }}"
loop:
- "'/subsystem=datasources/jdbc-driver={{ eap_driver_module_name }}:read-resource'"
76 changes: 34 additions & 42 deletions perform_migration.yml
Original file line number Diff line number Diff line change
@@ -1,77 +1,69 @@
---
- name: EAP {{ eap_source_version }} to {{ target_eap_version }} migration playbook
- name: "EAP {{ eap_source_version }} to {{ target_eap_version }} migration playbook"
hosts: all
vars:
eap_source_version: 7.2
target_eap_version: 7.3
eap_configuration_file: jboss_eap.xml
eap_source_version: 7.3.0
target_eap_version: 7.4.0
eap_configuration_file: eap.xml
installed_eap_source: True
migrated_jboss_eap_home: "/opt/jboss_eap/jboss-eap-{{ target_eap_version }}/"
# vars for target EAP, installed with zipfle
target_jboss_eap_home: /opt/rh/eap7/root/usr/share/wildfly/
eap_install_workdir: /opt/jboss_eap/
migrated_eap_home: "{{ eap_install_workdir }}/jboss-eap-{{ (target_eap_version.split('.'))[0:2] | join('.') }}/"
previous_eap_home: "{{ eap_install_workdir }}/jboss-eap-{{ (eap_source_version.split('.'))[0:2] | join('.') }}/"
target_eap_home: "{{ eap_install_workdir }}/jboss-eap-{{ (target_eap_version.split('.'))[0:2] | join('.') }}/"
skip_group_remove: False
jboss_eap_service_name: jboss_eap
jboss_eap_systemd_service_name: "{{ jboss_eap_service_name }}.service"
eap_service_name: eap
eap_systemd_service_name: "{{ eap_service_name }}.service"
vars_files:
- vars/eap_system_info.yml
collections:
- redhat.jboss_eap
- redhat.eap
pre_tasks:

- name: "Populate service facts"
ansible.builtin.service_facts:

- name: "Check if service is running"
ansible.builtin.command: "systemctl stop {{ jboss_eap_service_name }}"
- name: "Stop EAP service"
ansible.builtin.service:
name: "{{ eap_service_name }}"
state: stopped
become: yes
become_user: root
when:
- ansible_facts is defined
- ansible_facts.services is defined
- ansible_facts.services[jboss_eap_systemd_service_name] is defined
- ansible_facts.services[jboss_eap_systemd_service_name]['state'] is defined
- ansible_facts.services[jboss_eap_systemd_service_name]['state'] == 'running'

- name: "Ensure EAP {{ eap_source_version }} has been removed."
ansible.builtin.include_role:
name: jboss_eap_subs
tasks_from: disable_repo.yml
vars:
eap_version: "{{ eap_source_version }}"

- name: "Ensure EAP {{ target_eap_version }} has been installed."
ansible.builtin.include_role:
name: jboss_eap_subs
vars:
eap_version: "{{ target_eap_version }}"
- ansible_facts.services[eap_systemd_service_name] is defined
- ansible_facts.services[eap_systemd_service_name]['state'] is defined
- ansible_facts.services[eap_systemd_service_name]['state'] == 'running'

tasks:
- ansible.builtin.set_fact:
migration_state_file: /opt/rh/eap7/root/usr/share/wildfly/migration/.migrated
migration_state_file: "{{ migrated_eap_home }}/migration/reports/migration-report.xml"

- name: "Load migration state file data"
ansible.builtin.stat:
path: "{{ migration_state_file }}"
register: is_migration_done
become: yes
become_user: root

- ansible.builtin.assert:
that:
- is_migration_done is defined
- is_migration_done.stat is defined
- is_migration_done.stat.exists is defined
quiet: True
fail_msg: "Failed to retrieve metadata on migration state file: {{ migration_state_file }}."

- block:

- ansible.builtin.set_fact:
migrated_conf: "{{ migrated_jboss_eap_home }}/standalone/configuration/{{ eap_configuration_file }}"
target_conf: "{{ target_jboss_eap_home }}/standalone/configuration/{{ eap_configuration_file }}"
migrated_conf: "{{ migrated_eap_home }}/standalone/configuration/{{ eap_configuration_file }}"
target_conf: "{{ target_eap_home }}/standalone/configuration/{{ eap_configuration_file }}"

- name: "Copy migrated configuration from {{ migrated_conf }} file to target {{ target_conf }}."
ansible.builtin.copy:
src: "{{ migrated_conf }}"
dest: "{{ target_conf }}"
owner: "{{ jboss_eap_user }}"
group: "{{ jboss_eap_group }}"
owner: "{{ eap_user }}"
group: "{{ eap_group }}"
mode: '0644'
remote_src: True

Expand All @@ -82,11 +74,11 @@

- name: "Synchronize custom modules"
ansible.posix.synchronize:
src: "{{ migrated_jboss_eap_home }}/modules"
dest: "{{ target_jboss_eap_home }}/"
src: "{{ migrated_eap_home }}/modules"
dest: "{{ target_eap_home }}/"
copy_links: no
rsync_opts:
- "--exclude {{ migrated_jboss_eap_home }}/modules/system"
- "--exclude {{ migrated_eap_home }}/modules/system"

- name: "Ensures state file exists"
ansible.builtin.file:
Expand All @@ -106,11 +98,11 @@
msg: "Server has already been migrated."
when:
- is_migration_done.stat.exists
post_tasks:

post_tasks:
- name: "Ensures JBoss EAP {{ target_eap_version }} is running"
ansible.builtin.include_role:
name: jboss_eap_systemd
name: eap_systemd
vars:
jboss_eap_home: "{{ target_jboss_eap_home }}"
jboss_eap_systemd_enabled: True
eap_systemd_enabled: True
eap_version: "{{ target_eap_version }}"
10 changes: 0 additions & 10 deletions playbook.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,3 @@
- import_playbook: setup_eap.yml
- import_playbook: prepare_migration.yml
- import_playbook: perform_migration.yml

rpelisse marked this conversation as resolved.
Show resolved Hide resolved
- import_playbook: prepare_migration.yml
vars:
eap_source_version: 7.3
target_eap_version: 7.4

- import_playbook: perform_migration.yml
vars:
eap_source_version: 7.3
target_eap_version: 7.4
42 changes: 17 additions & 25 deletions prepare_migration.yml
Original file line number Diff line number Diff line change
@@ -1,35 +1,27 @@
---
- name: EAP {{ eap_source_version }} to {{ target_eap_version }} migration playbook
- name: "EAP {{ eap_source_version }} to {{ target_eap_version }} migration playbook"
hosts: all
vars:
eap_source_version: 7.2
target_eap_version: 7.3
previous_jboss_eap_home: /opt/rh/eap7/root/usr/share/wildfly/
target_zipfile: "jboss-eap-{{ target_eap_version }}.0.zip"
target_jboss_install_dir: /opt/jboss_eap/
target_jboss_eap_home: "{{ target_jboss_install_dir }}/jboss-eap-{{ target_eap_version }}/"
eap_source_version: 7.3.0
target_eap_version: 7.4.0
eap_install_workdir: /opt/jboss_eap/
previous_eap_home: "{{ eap_install_workdir }}/jboss-eap-{{ (eap_source_version.split('.'))[0:2] | join('.') }}/"
target_eap_home: "{{ eap_install_workdir }}/jboss-eap-{{ (target_eap_version.split('.'))[0:2] | join('.') }}/"
vars_files:
- vars/jdbc_driver.yml
- vars/eap_system_info.yml
collections:
- redhat.jboss_eap
- redhat.eap
pre_tasks:
- name: "Ensures required dependencies are installed."
ansible.builtin.package:
name: unzip
state: present

- name: "Ensures {{ target_jboss_install_dir }} exists."
ansible.builtin.file:
path: "{{ target_jboss_install_dir }}"
state: directory

- name: "Ensures new EAP version {{ target_zipfile }} has been unarchive into {{ target_jboss_install_dir }}"
ansible.builtin.unarchive:
src: "{{ target_zipfile }}"
dest: "{{ target_jboss_install_dir }}"
creates: "{{ target_jboss_eap_home }}/bin/standalone.sh"
- name: "Ensures new EAP {{ target_eap_version }} is installed"
ansible.builtin.include_role:
name: eap_install
vars:
eap_version: "{{ target_eap_version }}"

tasks:
- name: "Peform migration from {{ previous_jboss_eap_home }} to {{ target_jboss_eap_home }}."
- name: "Perform migration from {{ previous_eap_home }} to {{ target_eap_home }}."
ansible.builtin.include_role:
name: jboss_eap_migration
name: eap_migration
vars:
eap_migration_environment_props: eap.environment.properties.j2
2 changes: 1 addition & 1 deletion requirements.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
collections:
- name: redhat.jboss_eap
- name: redhat.eap
- name: ansible.posix

Loading