Skip to content

Commit

Permalink
[FIX] bugs fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
ismoilovdevml committed Nov 14, 2024
1 parent 449248b commit 3f0a47d
Show file tree
Hide file tree
Showing 8 changed files with 221 additions and 204 deletions.
46 changes: 30 additions & 16 deletions Ansible/activemq-artemis/cluster/bootstrap_server.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,26 +13,40 @@
- wget
- net-tools
- git
- "{{ java_packages[ansible_distribution] }}"
- "{{ java_packages[ansible_os_family] }}"
state: present

- name: Find Java 11 installation path
command: "update-alternatives --list java"
register: java_alternatives_output
changed_when: false
- name: Locate Java 17 executable on Debian-based systems
ansible.builtin.shell: "find /usr/lib/jvm -name 'java' | grep 'java-17'"
register: debian_java_path
when: ansible_os_family == "Debian"

- name: Set default Java version to Java 11
alternatives:
- name: Locate Java 17 executable on RedHat-based systems
ansible.builtin.shell: "find /usr/lib/jvm -name 'java' | grep 'java-17'"
register: redhat_java_path
when: ansible_os_family == "RedHat"

- name: Set Java 17 as the default alternative on Debian-based systems
community.general.alternatives:
name: java
path: "{{ debian_java_path.stdout | trim }}"
priority: 100
when: ansible_os_family == "Debian"

- name: Set Java 17 as the default alternative on RedHat-based systems
community.general.alternatives:
name: java
path: "{{ java_alternatives_output.stdout_lines | select('search', 'java-11') | list | first }}"
when: java_alternatives_output.stdout_lines | select('search', 'java-11') | list | length > 0
path: "{{ redhat_java_path.stdout | trim }}"
link: "/usr/bin/java"
priority: 100
when: ansible_os_family == "RedHat"

- name: Verify Java installation
command: java -version
register: java_version_output
changed_when: false
- name: Verify Java 17 installation
ansible.builtin.command: java -version
register: java_version
ignore_errors: true

- name: Debug Java installation output
debug:
msg: "Java version output: {{ java_version_output.stdout }}"
- name: Display Java version
ansible.builtin.debug:
msg: "Java installed successfully. Version: {{ java_version.stderr_lines | default([]) | union(java_version.stdout_lines | default([])) }}"
when: java_version is defined
8 changes: 4 additions & 4 deletions Ansible/activemq-artemis/cluster/inventory.ini
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
[master]
master ansible_host=137.184.107.91 ansible_user=root
master ansible_host=142.93.56.4 ansible_user=root

[nodes]
node1 ansible_host=192.241.130.39 ansible_user=root
node2 ansible_host=165.22.186.108 ansible_user=root
node1 ansible_host=134.209.77.220 ansible_user=root
node2 ansible_host=198.211.96.150 ansible_user=root

[nfs_server]
node2 ansible_host=165.22.186.108 ansible_user=root
node2 ansible_host=198.211.96.150 ansible_user=root
8 changes: 3 additions & 5 deletions Ansible/activemq-artemis/cluster/vars.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
---
java_packages:
"Ubuntu": "openjdk-11-jdk"
"Debian": "openjdk-11-jdk"
"Rocky": "java-11-openjdk"
"CentOS": "java-11-openjdk"
Debian: "openjdk-17-jdk"
RedHat: "java-17-openjdk"

artemis_version: "2.38.0"
artemis_url: "https://downloads.apache.org/activemq/activemq-artemis/{{ artemis_version }}/apache-artemis-{{ artemis_version }}-bin.tar.gz"
Expand All @@ -18,7 +16,7 @@ nfs_allowed_hosts: "*"
nfs_service_name:
RedHat: nfs-server
Debian: nfs-kernel-server
nfs_server_ip: "10.116.0.2"
nfs_server_ip: "198.211.96.150"
nfs_mount_paths:
master: "/mnt/artemis-cluster-master-prod"
nodes:
Expand Down
254 changes: 140 additions & 114 deletions Ansible/activemq-artemis/install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,121 +13,147 @@
- wget
- net-tools
- git
- "{{ java_packages[ansible_distribution] }}"
- "{{ java_packages[ansible_os_family] }}"
state: present

- name: Find Java 17 installation path
command: "update-alternatives --list java"
register: java_alternatives_output
- name: Locate Java 17 executable on Debian-based systems
ansible.builtin.shell: "find /usr/lib/jvm -name 'java' | grep 'java-17'"
register: debian_java_path
when: ansible_os_family == "Debian"

- name: Set default Java version to Java 17
alternatives:
- name: Locate Java 17 executable on RedHat-based systems
ansible.builtin.shell: "find /usr/lib/jvm -name 'java' | grep 'java-17'"
register: redhat_java_path
when: ansible_os_family == "RedHat"

- name: Set Java 17 as the default alternative on Debian-based systems
community.general.alternatives:
name: java
path: "{{ debian_java_path.stdout | trim }}"
priority: 100
when: ansible_os_family == "Debian"

- name: Set Java 17 as the default alternative on RedHat-based systems
community.general.alternatives:
name: java
path: "{{ java_alternatives_output.stdout_lines | select('search', 'java-17') | list | first }}"

# - name: Download ActiveMQ Artemis
# get_url:
# url: "{{ artemis_url }}"
# dest: /tmp/apache-artemis-{{ artemis_version }}-bin.tar.gz

# - name: Extract ActiveMQ Artemis
# unarchive:
# src: /tmp/apache-artemis-{{ artemis_version }}-bin.tar.gz
# dest: /opt
# remote_src: yes

# - name: Check if Artemis installation directory exists
# stat:
# path: "{{ artemis_install_dir }}"
# register: artemis_install_dir_stat

# - name: Move extracted Artemis to installation directory
# command: mv /opt/apache-artemis-{{ artemis_version }} {{ artemis_install_dir }}
# when: not artemis_install_dir_stat.stat.exists

# - name: Create artemis group
# group:
# name: "{{ artemis_group }}"
# state: present

# - name: Create artemis user and assign to group
# user:
# name: "{{ artemis_user }}"
# group: "{{ artemis_group }}"
# createhome: yes
# shell: /bin/bash
# state: present

# - name: Change ownership of Artemis directories
# file:
# path: "{{ item }}"
# state: directory
# owner: "{{ artemis_user }}"
# group: "{{ artemis_group }}"
# recurse: yes
# loop:
# - "{{ artemis_install_dir }}"
# - "{{ artemis_instance_dir }}"

# - name: Ensure log directory exists and permissions are set
# file:
# path: "{{ artemis_instance_dir }}/log"
# state: directory
# owner: "{{ artemis_user }}"
# group: "{{ artemis_group }}"
# mode: '0755'

# - name: Ensure tmp/webapps directory exists and permissions are set
# file:
# path: "{{ artemis_instance_dir }}/tmp/webapps"
# state: directory
# owner: "{{ artemis_user }}"
# group: "{{ artemis_group }}"
# mode: '0755'
# recurse: yes

# - name: Set permissions Artemis instance data directory
# file:
# path: /opt/artemis-instance/data
# owner: "{{ artemis_user }}"
# group: "{{ artemis_group }}"
# state: directory
# recurse: yes

# - name: Create Artemis instance
# command: "{{ artemis_install_dir }}/bin/artemis create {{ artemis_instance_dir }} --user admin --password {{ artemis_password }} --allow-anonymous --force"

# - name: Deploy Artemis systemd service file
# template:
# src: artemis.service.j2
# dest: /etc/systemd/system/artemis.service
# owner: root
# group: root
# mode: '0644'

# - name: Reload systemd daemon
# command: systemctl daemon-reload

# - name: Enable and start the Artemis service
# systemd:
# name: artemis
# enabled: yes
# state: started

# - name: Update bootstrap.xml to bind to 0.0.0.0
# replace:
# path: "{{ artemis_instance_dir }}/etc/bootstrap.xml"
# regexp: '(<binding name="artemis" uri=")(.*)(:8161">)'
# replace: '\1http://0.0.0.0\3'

# - name: Update Jolokia access to allow all origins
# replace:
# path: "{{ artemis_instance_dir }}/etc/jolokia-access.xml"
# regexp: '<allow-origin>.*</allow-origin>'
# replace: '<allow-origin>*://*</allow-origin>'

# - name: Restart Artemis service after config changes
# systemd:
# name: artemis
# state: restarted
# enabled: yes
path: "{{ redhat_java_path.stdout | trim }}"
link: "/usr/bin/java"
priority: 100
when: ansible_os_family == "RedHat"

- name: Verify Java 17 installation
ansible.builtin.command: java -version
register: java_version
ignore_errors: true

- name: Display Java version
ansible.builtin.debug:
msg: "Java installed successfully. Version: {{ java_version.stderr_lines | default([]) | union(java_version.stdout_lines | default([])) }}"
when: java_version is defined

- name: Download ActiveMQ Artemis
get_url:
url: "{{ artemis_url }}"
dest: /tmp/apache-artemis-{{ artemis_version }}-bin.tar.gz

- name: Extract ActiveMQ Artemis
unarchive:
src: /tmp/apache-artemis-{{ artemis_version }}-bin.tar.gz
dest: /opt
remote_src: yes

- name: Check if Artemis installation directory exists
stat:
path: "{{ artemis_install_dir }}"
register: artemis_install_dir_stat

- name: Move extracted Artemis to installation directory
command: mv /opt/apache-artemis-{{ artemis_version }} {{ artemis_install_dir }}
when: not artemis_install_dir_stat.stat.exists

- name: Create artemis group
group:
name: "{{ artemis_group }}"
state: present

- name: Create artemis user and assign to group
user:
name: "{{ artemis_user }}"
group: "{{ artemis_group }}"
createhome: yes
shell: /bin/bash
state: present

- name: Change ownership of Artemis directories
file:
path: "{{ item }}"
state: directory
owner: "{{ artemis_user }}"
group: "{{ artemis_group }}"
recurse: yes
loop:
- "{{ artemis_install_dir }}"
- "{{ artemis_instance_dir }}"

- name: Ensure log directory exists and permissions are set
file:
path: "{{ artemis_instance_dir }}/log"
state: directory
owner: "{{ artemis_user }}"
group: "{{ artemis_group }}"
mode: '0755'

- name: Ensure tmp/webapps directory exists and permissions are set
file:
path: "{{ artemis_instance_dir }}/tmp/webapps"
state: directory
owner: "{{ artemis_user }}"
group: "{{ artemis_group }}"
mode: '0755'
recurse: yes

- name: Set permissions Artemis instance data directory
file:
path: /opt/artemis-instance/data
owner: "{{ artemis_user }}"
group: "{{ artemis_group }}"
state: directory
recurse: yes

- name: Create Artemis instance
command: "{{ artemis_install_dir }}/bin/artemis create {{ artemis_instance_dir }} --user admin --password {{ artemis_password }} --allow-anonymous --force"

- name: Deploy Artemis systemd service file
template:
src: artemis.service.j2
dest: /etc/systemd/system/artemis.service
owner: root
group: root
mode: '0644'

- name: Reload systemd daemon
command: systemctl daemon-reload

- name: Enable and start the Artemis service
systemd:
name: artemis
enabled: yes
state: started

- name: Update bootstrap.xml to bind to 0.0.0.0
replace:
path: "{{ artemis_instance_dir }}/etc/bootstrap.xml"
regexp: '(<binding name="artemis" uri=")(.*)(:8161">)'
replace: '\1http://0.0.0.0\3'

- name: Update Jolokia access to allow all origins
replace:
path: "{{ artemis_instance_dir }}/etc/jolokia-access.xml"
regexp: '<allow-origin>.*</allow-origin>'
replace: '<allow-origin>*://*</allow-origin>'

- name: Restart Artemis service after config changes
systemd:
name: artemis
state: restarted
enabled: yes
6 changes: 2 additions & 4 deletions Ansible/activemq-artemis/vars.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
---
java_packages:
"Ubuntu": "openjdk-17-jdk"
"Debian": "openjdk-17-jdk"
"Rocky": "java-17-openjdk"
"CentOS": "java-17-openjdk"
Debian: "openjdk-17-jdk"
RedHat: "java-17-openjdk"
artemis_version: "2.38.0"
artemis_url: "https://downloads.apache.org/activemq/activemq-artemis/{{ artemis_version }}/apache-artemis-{{ artemis_version }}-bin.tar.gz"
artemis_install_dir: "/opt/artemis"
Expand Down
Loading

0 comments on commit 3f0a47d

Please sign in to comment.