Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Allow for installing/enabling JBoss EAP XP (Microprofile Extensions) #159

Open
InfoSec812 opened this issue Oct 18, 2023 · 1 comment
Open
Labels
enhancement New feature or request good first issue Good for newcomers hacktoberfest

Comments

@InfoSec812
Copy link

SUMMARY

It would be useful if the wildfly_install/eap_install could also install the XP extensions and enable them

Here's an example I have used to do this:

- name: Retrieve XP manager jar download using JBoss Network API
  redhat.runtimes_common.product_search:
    client_id: "{{ rhn_username }}"
    client_secret: "{{ rhn_password }}"
    product_category: "appplatform.xp"
  register: rhn_products
  no_log: "{{ omit_rhn_output | default(true) }}"
  delegate_to: localhost
  run_once: yes
  tags:
    - eap_xp
  when:
    - eap_xp_install | bool

- name: "Determine XP manager jar from search results."
  ansible.builtin.set_fact:
    rhn_filtered_products: "{{ rhn_products.results | selectattr('file_path', 'match', '[^/]*/jboss-eap-xp-' + eap_xp_version + '-manager.jar$') }}"
  delegate_to: localhost
  run_once: yes
  tags:
    - eap_xp
  when: eap_xp_install | bool

- name: Debug XP manager jar
  ansible.builtin.debug:
    msg: "Search Results: {{ rhn_products.results }}"
  delegate_to: localhost
  run_once: yes
  tags:
    - eap_xp
  when: eap_xp_install | bool

- name: Download XP manager jar
  redhat.runtimes_common.product_download: # noqa risky-file-permissions delegated, uses controller host user
    client_id: "{{ rhn_username }}"
    client_secret: "{{ rhn_password }}"
    product_id: "{{ (rhn_filtered_products | last).id }}"
    dest: "/tmp/jboss-eap-xp-manager.jar"
  no_log: "{{ omit_rhn_output | default(true) }}"
  delegate_to: localhost
  run_once: yes
  tags:
    - eap_xp
  when: eap_xp_install | bool

- name: "Determine XP patch zip from search results."
  ansible.builtin.set_fact:
    rhn_filtered_products: "{{ rhn_products.results | selectattr('file_path', 'match', '[^/]*/jboss-eap-xp.*-patch.zip$') }}"
  delegate_to: localhost
  run_once: yes
  tags:
    - eap_xp
  when: eap_xp_install | bool

- name: Download XP patch zip
  redhat.runtimes_common.product_download: # noqa risky-file-permissions delegated, uses controller host user
    client_id: "{{ rhn_username }}"
    client_secret: "{{ rhn_password }}"
    product_id: "{{ (rhn_filtered_products | last).id }}"
    dest: "/tmp/jboss-eap-xp-patch.zip"
  no_log: "{{ omit_rhn_output | default(true) }}"
  delegate_to: localhost
  run_once: yes
  tags:
    - eap_xp
  when: eap_xp_install | bool

- name: Copy EAP XP Manager To Target
  ansible.builtin.copy:
    src: "{{ eap_xp_manager_local_file | default('/tmp/jboss-eap-xp-manager.jar') }}"
    dest: "{{ eap_xp_manager_local_file | default('/tmp/jboss-eap-xp-manager.jar') }}"
    owner: "{{ eap_user }}"
    group: "{{ eap_group }}"
    mode: 755
  tags:
    - eap_xp
  when: eap_xp_install | bool

- name: Copy EAP XP Patch To Target
  ansible.builtin.copy:
    src: "{{ eap_xp_patch_local_file | default('/tmp/jboss-eap-xp-patch.zip') }}"
    dest: "{{ eap_xp_patch_local_file | default('/tmp/jboss-eap-xp-patch.zip') }}"
    owner: "{{ eap_user }}"
    group: "{{ eap_group }}"
    mode: 755
  tags:
    - eap_xp
  when: eap_xp_install | bool

- name: Check EAP XP Status
  ansible.builtin.shell:
    cmd: "java -jar {{ eap_xp_manager_local_file | default('/tmp/jboss-eap-xp-manager.jar') }} status --jboss-home={{ eap_install_workdir }}/jboss-eap-7.4 | grep 'Available commands' | awk -F':' '{print $2}'"
  register: eap_xp_status
  tags:
    - eap_xp
  when: eap_xp_install | bool

- name: Debug XP Manager Status
  ansible.builtin.debug:
    msg: "XP Manager Status: {{ eap_xp_status }}"
    verbosity: 0
  tags:
    - eap_xp
  when: eap_xp_install | bool

- name: Run EAP XP setup if needed
  ansible.builtin.shell:
    cmd: "java -jar {{ eap_xp_manager_local_file | default('/tmp/jboss-eap-xp-manager.jar') }} setup --jboss-home={{ eap_install_workdir }}/jboss-eap-7.4 --accept-support-policy"
  tags:
    - eap_xp
  when:
    - eap_xp_install | bool
    - eap_xp_status.stdout is search('setup') 

- name: Install EAP XP Extension
  ansible.builtin.shell:
    cmd: "java -jar {{ eap_xp_manager_local_file | default('/tmp/jboss-eap-xp-manager.jar') }} patch-apply --jboss-home={{ eap_install_workdir }}/jboss-eap-7.4 --patch={{ eap_xp_patch_local_file | default('/tmp/jboss-eap-xp-patch.zip') }}"
  tags:
    - eap_xp
  when:
    - eap_xp_install | bool
    - eap_xp_status.stdout is search('patch-apply')
  notify: Restart JBoss EAP
ISSUE TYPE
  • Feature Idea
@InfoSec812
Copy link
Author

InfoSec812 commented Oct 18, 2023

It would also be necessary to enable the various extensions/subsystems. For example, to enable metrics-smallrye, you need to:

  1. Enable the config-smallrye extension - jboss-cli.sh -c '/extension=org.wildfly.extension.microprofile.config-smallrye:add
  2. Reload JBoss - jboss-cli.sh -c 'reload'
  3. Enable the metrics-smallrye extension - jboss-cli.sh -c '/extension=org.wildfly.extension.microprofile.metrics-smallrye:add
  4. Reload JBoss - jboss-cli.sh -c 'reload'
  5. Enable the config subsystem: jboss-cli.sh -c '/subsystem=microprofile-config-smallrye:add'
  6. Enable the metrics subsystem: jboss-cli.sh -c '/subsystem=microprofile-metrics-smallrye:add'
  7. Reload JBoss - jboss-cli.sh -c 'reload'

@rpelisse rpelisse added the enhancement New feature or request label Apr 11, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
enhancement New feature or request good first issue Good for newcomers hacktoberfest
Projects
None yet
Development

No branches or pull requests

2 participants