Skip to content

Commit 3f0a47d

Browse files
committed
[FIX] bugs fixed
1 parent 449248b commit 3f0a47d

File tree

8 files changed

+221
-204
lines changed

8 files changed

+221
-204
lines changed

Ansible/activemq-artemis/cluster/bootstrap_server.yml

Lines changed: 30 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13,26 +13,40 @@
1313
- wget
1414
- net-tools
1515
- git
16-
- "{{ java_packages[ansible_distribution] }}"
16+
- "{{ java_packages[ansible_os_family] }}"
1717
state: present
1818

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

24-
- name: Set default Java version to Java 11
25-
alternatives:
24+
- name: Locate Java 17 executable on RedHat-based systems
25+
ansible.builtin.shell: "find /usr/lib/jvm -name 'java' | grep 'java-17'"
26+
register: redhat_java_path
27+
when: ansible_os_family == "RedHat"
28+
29+
- name: Set Java 17 as the default alternative on Debian-based systems
30+
community.general.alternatives:
31+
name: java
32+
path: "{{ debian_java_path.stdout | trim }}"
33+
priority: 100
34+
when: ansible_os_family == "Debian"
35+
36+
- name: Set Java 17 as the default alternative on RedHat-based systems
37+
community.general.alternatives:
2638
name: java
27-
path: "{{ java_alternatives_output.stdout_lines | select('search', 'java-11') | list | first }}"
28-
when: java_alternatives_output.stdout_lines | select('search', 'java-11') | list | length > 0
39+
path: "{{ redhat_java_path.stdout | trim }}"
40+
link: "/usr/bin/java"
41+
priority: 100
42+
when: ansible_os_family == "RedHat"
2943

30-
- name: Verify Java installation
31-
command: java -version
32-
register: java_version_output
33-
changed_when: false
44+
- name: Verify Java 17 installation
45+
ansible.builtin.command: java -version
46+
register: java_version
3447
ignore_errors: true
3548

36-
- name: Debug Java installation output
37-
debug:
38-
msg: "Java version output: {{ java_version_output.stdout }}"
49+
- name: Display Java version
50+
ansible.builtin.debug:
51+
msg: "Java installed successfully. Version: {{ java_version.stderr_lines | default([]) | union(java_version.stdout_lines | default([])) }}"
52+
when: java_version is defined
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
[master]
2-
master ansible_host=137.184.107.91 ansible_user=root
2+
master ansible_host=142.93.56.4 ansible_user=root
33

44
[nodes]
5-
node1 ansible_host=192.241.130.39 ansible_user=root
6-
node2 ansible_host=165.22.186.108 ansible_user=root
5+
node1 ansible_host=134.209.77.220 ansible_user=root
6+
node2 ansible_host=198.211.96.150 ansible_user=root
77

88
[nfs_server]
9-
node2 ansible_host=165.22.186.108 ansible_user=root
9+
node2 ansible_host=198.211.96.150 ansible_user=root

Ansible/activemq-artemis/cluster/vars.yml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
---
22
java_packages:
3-
"Ubuntu": "openjdk-11-jdk"
4-
"Debian": "openjdk-11-jdk"
5-
"Rocky": "java-11-openjdk"
6-
"CentOS": "java-11-openjdk"
3+
Debian: "openjdk-17-jdk"
4+
RedHat: "java-17-openjdk"
75

86
artemis_version: "2.38.0"
97
artemis_url: "https://downloads.apache.org/activemq/activemq-artemis/{{ artemis_version }}/apache-artemis-{{ artemis_version }}-bin.tar.gz"
@@ -18,7 +16,7 @@ nfs_allowed_hosts: "*"
1816
nfs_service_name:
1917
RedHat: nfs-server
2018
Debian: nfs-kernel-server
21-
nfs_server_ip: "10.116.0.2"
19+
nfs_server_ip: "198.211.96.150"
2220
nfs_mount_paths:
2321
master: "/mnt/artemis-cluster-master-prod"
2422
nodes:

Ansible/activemq-artemis/install.yml

Lines changed: 140 additions & 114 deletions
Original file line numberDiff line numberDiff line change
@@ -13,121 +13,147 @@
1313
- wget
1414
- net-tools
1515
- git
16-
- "{{ java_packages[ansible_distribution] }}"
16+
- "{{ java_packages[ansible_os_family] }}"
1717
state: present
1818

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

23-
- name: Set default Java version to Java 17
24-
alternatives:
24+
- name: Locate Java 17 executable on RedHat-based systems
25+
ansible.builtin.shell: "find /usr/lib/jvm -name 'java' | grep 'java-17'"
26+
register: redhat_java_path
27+
when: ansible_os_family == "RedHat"
28+
29+
- name: Set Java 17 as the default alternative on Debian-based systems
30+
community.general.alternatives:
31+
name: java
32+
path: "{{ debian_java_path.stdout | trim }}"
33+
priority: 100
34+
when: ansible_os_family == "Debian"
35+
36+
- name: Set Java 17 as the default alternative on RedHat-based systems
37+
community.general.alternatives:
2538
name: java
26-
path: "{{ java_alternatives_output.stdout_lines | select('search', 'java-17') | list | first }}"
27-
28-
# - name: Download ActiveMQ Artemis
29-
# get_url:
30-
# url: "{{ artemis_url }}"
31-
# dest: /tmp/apache-artemis-{{ artemis_version }}-bin.tar.gz
32-
33-
# - name: Extract ActiveMQ Artemis
34-
# unarchive:
35-
# src: /tmp/apache-artemis-{{ artemis_version }}-bin.tar.gz
36-
# dest: /opt
37-
# remote_src: yes
38-
39-
# - name: Check if Artemis installation directory exists
40-
# stat:
41-
# path: "{{ artemis_install_dir }}"
42-
# register: artemis_install_dir_stat
43-
44-
# - name: Move extracted Artemis to installation directory
45-
# command: mv /opt/apache-artemis-{{ artemis_version }} {{ artemis_install_dir }}
46-
# when: not artemis_install_dir_stat.stat.exists
47-
48-
# - name: Create artemis group
49-
# group:
50-
# name: "{{ artemis_group }}"
51-
# state: present
52-
53-
# - name: Create artemis user and assign to group
54-
# user:
55-
# name: "{{ artemis_user }}"
56-
# group: "{{ artemis_group }}"
57-
# createhome: yes
58-
# shell: /bin/bash
59-
# state: present
60-
61-
# - name: Change ownership of Artemis directories
62-
# file:
63-
# path: "{{ item }}"
64-
# state: directory
65-
# owner: "{{ artemis_user }}"
66-
# group: "{{ artemis_group }}"
67-
# recurse: yes
68-
# loop:
69-
# - "{{ artemis_install_dir }}"
70-
# - "{{ artemis_instance_dir }}"
71-
72-
# - name: Ensure log directory exists and permissions are set
73-
# file:
74-
# path: "{{ artemis_instance_dir }}/log"
75-
# state: directory
76-
# owner: "{{ artemis_user }}"
77-
# group: "{{ artemis_group }}"
78-
# mode: '0755'
79-
80-
# - name: Ensure tmp/webapps directory exists and permissions are set
81-
# file:
82-
# path: "{{ artemis_instance_dir }}/tmp/webapps"
83-
# state: directory
84-
# owner: "{{ artemis_user }}"
85-
# group: "{{ artemis_group }}"
86-
# mode: '0755'
87-
# recurse: yes
88-
89-
# - name: Set permissions Artemis instance data directory
90-
# file:
91-
# path: /opt/artemis-instance/data
92-
# owner: "{{ artemis_user }}"
93-
# group: "{{ artemis_group }}"
94-
# state: directory
95-
# recurse: yes
96-
97-
# - name: Create Artemis instance
98-
# command: "{{ artemis_install_dir }}/bin/artemis create {{ artemis_instance_dir }} --user admin --password {{ artemis_password }} --allow-anonymous --force"
99-
100-
# - name: Deploy Artemis systemd service file
101-
# template:
102-
# src: artemis.service.j2
103-
# dest: /etc/systemd/system/artemis.service
104-
# owner: root
105-
# group: root
106-
# mode: '0644'
107-
108-
# - name: Reload systemd daemon
109-
# command: systemctl daemon-reload
110-
111-
# - name: Enable and start the Artemis service
112-
# systemd:
113-
# name: artemis
114-
# enabled: yes
115-
# state: started
116-
117-
# - name: Update bootstrap.xml to bind to 0.0.0.0
118-
# replace:
119-
# path: "{{ artemis_instance_dir }}/etc/bootstrap.xml"
120-
# regexp: '(<binding name="artemis" uri=")(.*)(:8161">)'
121-
# replace: '\1http://0.0.0.0\3'
122-
123-
# - name: Update Jolokia access to allow all origins
124-
# replace:
125-
# path: "{{ artemis_instance_dir }}/etc/jolokia-access.xml"
126-
# regexp: '<allow-origin>.*</allow-origin>'
127-
# replace: '<allow-origin>*://*</allow-origin>'
128-
129-
# - name: Restart Artemis service after config changes
130-
# systemd:
131-
# name: artemis
132-
# state: restarted
133-
# enabled: yes
39+
path: "{{ redhat_java_path.stdout | trim }}"
40+
link: "/usr/bin/java"
41+
priority: 100
42+
when: ansible_os_family == "RedHat"
43+
44+
- name: Verify Java 17 installation
45+
ansible.builtin.command: java -version
46+
register: java_version
47+
ignore_errors: true
48+
49+
- name: Display Java version
50+
ansible.builtin.debug:
51+
msg: "Java installed successfully. Version: {{ java_version.stderr_lines | default([]) | union(java_version.stdout_lines | default([])) }}"
52+
when: java_version is defined
53+
54+
- name: Download ActiveMQ Artemis
55+
get_url:
56+
url: "{{ artemis_url }}"
57+
dest: /tmp/apache-artemis-{{ artemis_version }}-bin.tar.gz
58+
59+
- name: Extract ActiveMQ Artemis
60+
unarchive:
61+
src: /tmp/apache-artemis-{{ artemis_version }}-bin.tar.gz
62+
dest: /opt
63+
remote_src: yes
64+
65+
- name: Check if Artemis installation directory exists
66+
stat:
67+
path: "{{ artemis_install_dir }}"
68+
register: artemis_install_dir_stat
69+
70+
- name: Move extracted Artemis to installation directory
71+
command: mv /opt/apache-artemis-{{ artemis_version }} {{ artemis_install_dir }}
72+
when: not artemis_install_dir_stat.stat.exists
73+
74+
- name: Create artemis group
75+
group:
76+
name: "{{ artemis_group }}"
77+
state: present
78+
79+
- name: Create artemis user and assign to group
80+
user:
81+
name: "{{ artemis_user }}"
82+
group: "{{ artemis_group }}"
83+
createhome: yes
84+
shell: /bin/bash
85+
state: present
86+
87+
- name: Change ownership of Artemis directories
88+
file:
89+
path: "{{ item }}"
90+
state: directory
91+
owner: "{{ artemis_user }}"
92+
group: "{{ artemis_group }}"
93+
recurse: yes
94+
loop:
95+
- "{{ artemis_install_dir }}"
96+
- "{{ artemis_instance_dir }}"
97+
98+
- name: Ensure log directory exists and permissions are set
99+
file:
100+
path: "{{ artemis_instance_dir }}/log"
101+
state: directory
102+
owner: "{{ artemis_user }}"
103+
group: "{{ artemis_group }}"
104+
mode: '0755'
105+
106+
- name: Ensure tmp/webapps directory exists and permissions are set
107+
file:
108+
path: "{{ artemis_instance_dir }}/tmp/webapps"
109+
state: directory
110+
owner: "{{ artemis_user }}"
111+
group: "{{ artemis_group }}"
112+
mode: '0755'
113+
recurse: yes
114+
115+
- name: Set permissions Artemis instance data directory
116+
file:
117+
path: /opt/artemis-instance/data
118+
owner: "{{ artemis_user }}"
119+
group: "{{ artemis_group }}"
120+
state: directory
121+
recurse: yes
122+
123+
- name: Create Artemis instance
124+
command: "{{ artemis_install_dir }}/bin/artemis create {{ artemis_instance_dir }} --user admin --password {{ artemis_password }} --allow-anonymous --force"
125+
126+
- name: Deploy Artemis systemd service file
127+
template:
128+
src: artemis.service.j2
129+
dest: /etc/systemd/system/artemis.service
130+
owner: root
131+
group: root
132+
mode: '0644'
133+
134+
- name: Reload systemd daemon
135+
command: systemctl daemon-reload
136+
137+
- name: Enable and start the Artemis service
138+
systemd:
139+
name: artemis
140+
enabled: yes
141+
state: started
142+
143+
- name: Update bootstrap.xml to bind to 0.0.0.0
144+
replace:
145+
path: "{{ artemis_instance_dir }}/etc/bootstrap.xml"
146+
regexp: '(<binding name="artemis" uri=")(.*)(:8161">)'
147+
replace: '\1http://0.0.0.0\3'
148+
149+
- name: Update Jolokia access to allow all origins
150+
replace:
151+
path: "{{ artemis_instance_dir }}/etc/jolokia-access.xml"
152+
regexp: '<allow-origin>.*</allow-origin>'
153+
replace: '<allow-origin>*://*</allow-origin>'
154+
155+
- name: Restart Artemis service after config changes
156+
systemd:
157+
name: artemis
158+
state: restarted
159+
enabled: yes

Ansible/activemq-artemis/vars.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
---
22
java_packages:
3-
"Ubuntu": "openjdk-17-jdk"
4-
"Debian": "openjdk-17-jdk"
5-
"Rocky": "java-17-openjdk"
6-
"CentOS": "java-17-openjdk"
3+
Debian: "openjdk-17-jdk"
4+
RedHat: "java-17-openjdk"
75
artemis_version: "2.38.0"
86
artemis_url: "https://downloads.apache.org/activemq/activemq-artemis/{{ artemis_version }}/apache-artemis-{{ artemis_version }}-bin.tar.gz"
97
artemis_install_dir: "/opt/artemis"

0 commit comments

Comments
 (0)