Skip to content

Commit

Permalink
updated
Browse files Browse the repository at this point in the history
  • Loading branch information
ismoilovdevml committed Nov 14, 2024
1 parent ff3ddc6 commit 449248b
Show file tree
Hide file tree
Showing 8 changed files with 225 additions and 155 deletions.
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=147.182.174.211 ansible_user=root
master ansible_host=137.184.107.91 ansible_user=root

[nodes]
node1 ansible_host=67.207.87.177 ansible_user=root
node2 ansible_host=24.144.106.189 ansible_user=root
node1 ansible_host=192.241.130.39 ansible_user=root
node2 ansible_host=165.22.186.108 ansible_user=root

[nfs_server]
node2 ansible_host=24.144.106.189 ansible_user=root
node2 ansible_host=165.22.186.108 ansible_user=root
2 changes: 1 addition & 1 deletion Ansible/activemq-artemis/cluster/vars.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ java_packages:
"Rocky": "java-11-openjdk"
"CentOS": "java-11-openjdk"

artemis_version: "2.37.0"
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"
artemis_instance_dir: "/opt/artemis-instance"
Expand Down
220 changes: 110 additions & 110 deletions Ansible/activemq-artemis/install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,118 +16,118 @@
- "{{ java_packages[ansible_distribution] }}"
state: present

- name: Find Java 11 installation path
- name: Find Java 17 installation path
command: "update-alternatives --list java"
register: java_alternatives_output

- name: Set default Java version to Java 11
- name: Set default Java version to Java 17
alternatives:
name: java
path: "{{ java_alternatives_output.stdout_lines | select('search', 'java-11') | 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: "{{ 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
6 changes: 3 additions & 3 deletions Ansible/activemq-artemis/inventory.ini
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[artemis_servers]
rockylinux ansible_host=137.184.107.91 ansible_user=root
debian ansible_host=192.241.130.39 ansible_user=root
ubuntu ansible_host=165.22.186.108 ansible_user=root
debian ansible_host=157.245.130.56 ansible_user=root
ubuntu ansible_host=134.209.77.220 ansible_user=root
rockylinux ansible_host=142.93.56.4 ansible_user=root
10 changes: 5 additions & 5 deletions Ansible/activemq-artemis/vars.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
---
java_packages:
"Ubuntu": "openjdk-11-jdk"
"Debian": "openjdk-11-jdk"
"Rocky": "java-11-openjdk"
"CentOS": "java-11-openjdk"
artemis_version: "2.37.0"
"Ubuntu": "openjdk-17-jdk"
"Debian": "openjdk-17-jdk"
"Rocky": "java-17-openjdk"
"CentOS": "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"
artemis_instance_dir: "/opt/artemis-instance"
Expand Down
78 changes: 49 additions & 29 deletions Ansible/java/install_java.yml
Original file line number Diff line number Diff line change
@@ -1,30 +1,50 @@
---
- hosts: java_servers
become: yes
- name: Install and configure Java 17 on multiple OS families
hosts: all
become: true
vars_files:
- vars.yml

tasks:
- name: Install Java on RHEL-based systems
include_role:
name: geerlingguy.java
vars:
java_packages:
- java-11-openjdk
- java-11-openjdk-devel
when: ansible_os_family == 'RedHat'

- name: Install Java on Debian-based systems
include_role:
name: geerlingguy.java
vars:
java_packages:
- openjdk-17-jdk
- default-jdk
- default-jre
when: ansible_os_family == 'Debian'

- name: Install Java on Ubuntu systems
include_role:
name: geerlingguy.java
vars:
java_packages:
- openjdk-11-jdk
when: ansible_distribution == 'Ubuntu'
- name: Install Java 17 on Debian-based systems
ansible.builtin.apt:
name: openjdk-17-jdk
state: present
when: ansible_os_family == "Debian"

- name: Install Java 17 on RedHat-based systems
ansible.builtin.yum:
name: java-17-openjdk
state: present
when: ansible_os_family == "RedHat"

- name: Identify Java 17 path on Debian-based systems
ansible.builtin.shell: "update-alternatives --list java | grep 'java-17'"
register: debian_java_path
when: ansible_os_family == "Debian"

- name: Identify Java 17 path on RedHat-based systems
ansible.builtin.shell: "update-alternatives --list | 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 }}"
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: "{{ redhat_java_path.stdout }}"
priority: 100
when: ansible_os_family == "RedHat"

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

- name: Display Java version
ansible.builtin.debug:
msg: "Java installed successfully. Version: {{ java_version.stdout_lines }}"
6 changes: 3 additions & 3 deletions Ansible/java/inventory.ini
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[java_servers]
rockylinux ansible_host=137.184.143.123 ansible_user=root
debian ansible_host=165.22.3.122 ansible_user=root
ubuntu ansible_host=159.223.131.6 ansible_user=root
debian ansible_host=157.245.130.56 ansible_user=root
ubuntu ansible_host=134.209.77.220 ansible_user=root
rockylinux ansible_host=142.93.56.4 ansible_user=root
Loading

0 comments on commit 449248b

Please sign in to comment.