diff --git a/README.md b/README.md index 8128777..4e5eb8a 100644 --- a/README.md +++ b/README.md @@ -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 @@ -23,15 +23,15 @@ As this demo uses a collection available on [Red Hat Automation Hub](https://www 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 @@ -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 @@ -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 diff --git a/molecule/default/prepare.yml b/molecule/default/prepare.yml deleted file mode 100644 index b5770bd..0000000 --- a/molecule/default/prepare.yml +++ /dev/null @@ -1,23 +0,0 @@ ---- -- name: Prepare - hosts: all - tasks: - - ansible.builtin.set_fact: - down_server: "{{ lookup('env','MIDDLEWARE_DOWNLOAD_RELEASE_SERVER_URL') }}" - - - ansible.builtin.assert: - that: - - down_server is defined - - down_server | length > 0 - quiet: True - - - name: "Download JBoss EAP zipfile from {{ down_server }}//eap7/7.4.0/jboss-eap-7.4.0.zip" - get_url: - url: "{{ down_server }}//eap7/7.4.0/jboss-eap-7.4.0.zip" - dest: /opt/jboss-eap-7.4.0.zip - loop: - - 7.3 - - 7.4 - loop_control: - loop_var: jboss_version - diff --git a/molecule/default/requirements.yml b/molecule/default/requirements.yml index 5faa4b4..e90b5da 100644 --- a/molecule/default/requirements.yml +++ b/molecule/default/requirements.yml @@ -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 diff --git a/molecule/default/verify.yml b/molecule/default/verify.yml index 7d32603..8e08072 100644 --- a/molecule/default/verify.yml +++ b/molecule/default/verify.yml @@ -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'" diff --git a/perform_migration.yml b/perform_migration.yml index a4d0cb6..cdbb3df 100644 --- a/perform_migration.yml +++ b/perform_migration.yml @@ -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 @@ -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: @@ -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 }}" diff --git a/playbook.yml b/playbook.yml index 61cd64b..c19d1ae 100644 --- a/playbook.yml +++ b/playbook.yml @@ -2,13 +2,3 @@ - import_playbook: setup_eap.yml - import_playbook: prepare_migration.yml - import_playbook: perform_migration.yml - -- 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 diff --git a/prepare_migration.yml b/prepare_migration.yml index 03db836..70dcb6b 100644 --- a/prepare_migration.yml +++ b/prepare_migration.yml @@ -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 diff --git a/requirements.yml b/requirements.yml index ef42a0e..5836eb7 100644 --- a/requirements.yml +++ b/requirements.yml @@ -1,5 +1,5 @@ --- collections: - - name: redhat.jboss_eap + - name: redhat.eap - name: ansible.posix diff --git a/setup_eap.yml b/setup_eap.yml index e2e3791..9c53afd 100644 --- a/setup_eap.yml +++ b/setup_eap.yml @@ -1,59 +1,52 @@ --- -- name: Ensures EAP {{ eap_source_version }} is installed and configured +- name: "Ensures EAP {{ eap_source_version }} is installed and configured" hosts: all vars: - # vars for source, rpm based installed - eap_source_version: 7.2 - jboss_eap_group_install_name: jboss-eap7-jdk11 - installed_eap_source: True - jboss_eap_home: /opt/rh/eap7/root/usr/share/wildfly/ + eap_source_version: 7.3.0 + eap_home: "/opt/jboss_eap/jboss-eap-{{ (eap_source_version.split('.'))[0:2] | join('.') }}/" vars_files: - vars/jdbc_driver.yml - vars/eap_system_info.yml collections: - - redhat.jboss_eap + - redhat.eap tasks: - - - name: "Ensure EAP {{ eap_source_version }} is installed." + - name: "Install EAP {{ eap_source_version }}" ansible.builtin.include_role: - name: jboss_eap_subs + name: eap_install vars: eap_version: "{{ eap_source_version }}" + omit_rhn_output: False - - name: "Install Maria DB driver in {{ jboss_eap_home }}" + - name: "Install Maria DB driver in {{ eap_home }}" ansible.builtin.include_role: - name: jboss_eap_driver - vars: - jdbc_driver_jar_url: "https://repo1.maven.org/maven2/org/mariadb/jdbc/mariadb-java-client/{{ jdbc_driver_version }}/mariadb-java-client-{{ jdbc_driver_version }}.jar" + name: eap_driver - name: "Ensures JBoss EAP {{ eap_source_version }} is running" ansible.builtin.include_role: - name: jboss_eap_systemd + name: eap_systemd vars: - wildfly_home: "{{ jboss_eap_home }}" - wildfly_systemd_enabled: True + eap_systemd_enabled: True + eap_version: "{{ eap_source_version }}" - ansible.builtin.set_fact: - path_to_driver: "{{ jdbc_driver_module_dir }}/{{ jdbc_driver_jar_filename }}" + path_to_driver: "{{ eap_driver_module_dir }}/{{ eap_driver_jar_filename }}" - block: - name: "Checks if 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" + jboss_cli_query: "/subsystem=datasources/jdbc-driver={{ eap_driver_module_name }}:read-resource" rescue: - 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: "{{ item }}" + jboss_cli_query: "{{ item }}" loop: - - "'/subsystem=datasources/jdbc-driver={{ jdbc_driver_module_name }}:add(driver-name={{ jdbc_driver_name }}, driver-module-name={{ jdbc_driver_module_name }}, driver-class-name={{ jdbc_driver_classname }})'" - - "'data-source add --jndi-name={{ mariadb_jndi_name }} --name={{ mariadb_ds_name }} --connection-url={{ mariadb_connection_url }} --driver-name={{ jdbc_driver_module_name }}'" + - "'/subsystem=datasources/jdbc-driver={{ eap_driver_module_name }}:add(driver-name={{ eap_driver_name }}, driver-module-name={{ eap_driver_module_name }}, driver-class-name={{ eap_driver_classname }})'" + - "'data-source add --jndi-name={{ mariadb_jndi_name }} --name={{ mariadb_ds_name }} --connection-url={{ mariadb_connection_url }} --driver-name={{ eap_driver_module_name }}'" - ":write-config()" diff --git a/templates/environment.properties.j2 b/templates/eap.environment.properties.j2 similarity index 98% rename from templates/environment.properties.j2 rename to templates/eap.environment.properties.j2 index 63670ef..bd5ea1c 100644 --- a/templates/environment.properties.j2 +++ b/templates/eap.environment.properties.j2 @@ -16,7 +16,7 @@ report.xml.fileName=migration-report.xml #server.source.standalone.serverDir=standalone #server.source.standalone.configDir=configuration -server.source.standalone.configFiles=standalone.xml,standalone-full.xml,jboss_eap.xml +server.source.standalone.configFiles=standalone.xml,standalone-full.xml,eap.xml #server.source.standalone.serverDir=standalone #server.source.standalone.configDir=configuration @@ -45,7 +45,7 @@ extensions.includes= #management.setup-http-upgrade.socket-binding.management-https.update-port.skip=true # a list with module names to migrate -modules.includes={{ jdbc_driver_module_name }} +modules.includes={{ eap_driver_module_name }} # a list with module names to not migrate modules.excludes= #modules.migrate-modules-requested-by-configuration.skip=true diff --git a/vars/eap_system_info.yml b/vars/eap_system_info.yml index d641ced..bd0e373 100644 --- a/vars/eap_system_info.yml +++ b/vars/eap_system_info.yml @@ -1,5 +1,5 @@ --- -jboss_eap_java_package_name: java-11-openjdk-headless -jboss_eap_group_install_name: jboss-eap7-jdk11 -jboss_eap_user: root -jboss_eap_group: root +eap_java_package_name: java-11-openjdk-headless +eap_apply_cp: false +eap_user: root +eap_group: root diff --git a/vars/jdbc_driver.yml b/vars/jdbc_driver.yml index 08392bc..93a4414 100644 --- a/vars/jdbc_driver.yml +++ b/vars/jdbc_driver.yml @@ -1,10 +1,11 @@ --- -jdbc_driver_module_name: "org.mariadb" -jdbc_driver_name: "org.mariadb" -jdbc_driver_version: 2.7.4 -jdbc_driver_jar_filename: "mariadb-java-client-{{ jdbc_driver_version }}.jar" -jdbc_driver_module_dir: "{{ jboss_eap_home }}/modules/org/mariadb/main" -jdbc_driver_classname: "org.mariadb.jdbc.Driver" +eap_driver_module_name: "org.mariadb" +eap_driver_name: "org.mariadb" +eap_driver_version: 2.7.4 +eap_driver_jar_filename: "mariadb-java-client-{{ eap_driver_version }}.jar" +eap_driver_module_dir: "{{ eap_home }}/modules/org/mariadb/main" +eap_driver_classname: "org.mariadb.jdbc.Driver" +eap_driver_jar_url: "https://repo.maven.apache.org/maven2/org/mariadb/jdbc/mariadb-java-client/{{eap_driver_version}}/mariadb-java-client-{{eap_driver_version}}.jar" mariadb_ds_name: "MariaDBPool" mariadb_jndi_name: "java:/MariaDS"