Skip to content

Commit

Permalink
[NEW] added Apache Artemis ActiveMQ cluster playbook
Browse files Browse the repository at this point in the history
  • Loading branch information
ismoilovdevml committed Nov 12, 2024
1 parent 4f5b6eb commit e163e3e
Show file tree
Hide file tree
Showing 12 changed files with 123 additions and 16 deletions.
38 changes: 38 additions & 0 deletions Ansible/activemq-artemis/cluster/bootstrap_server.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
---
- name: Boostratp Servers
hosts: master,nodes
become: yes
vars_files:
- vars.yml

tasks:
- name: Ensure required packages are installed
package:
name:
- curl
- wget
- net-tools
- git
- "{{ java_packages[ansible_distribution] }}"
state: present

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

- name: Set default Java version to Java 11
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

- name: Verify Java installation
command: java -version
register: java_version_output
changed_when: false
ignore_errors: true

- name: Debug Java installation output
debug:
msg: "Java version output: {{ java_version_output.stdout }}"
9 changes: 9 additions & 0 deletions Ansible/activemq-artemis/cluster/invnetory.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[master]
master ansible_host=147.182.174.211 ansible_user=root

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

[nfs]
node2 ansible_host=24.144.106.189 ansible_user=root
Empty file.
Empty file.
26 changes: 26 additions & 0 deletions Ansible/activemq-artemis/cluster/vars.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
---
java_packages:
"Ubuntu": "openjdk-11-jdk"
"Debian": "openjdk-11-jdk"
"Rocky": "java-11-openjdk"
"CentOS": "java-11-openjdk"

artemis_version: "2.37.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"
artemis_user: "artemis"
artemis_group: "artemis"
artemis_password: "329awfas"

nfs_export_path: "/srv/nfs"
nfs_allowed_hosts: "*"
nfs_service_name:
RedHat: nfs-server
Debian: nfs-kernel-server

nfs_mount_paths:
master: "/mnt/artemis-cluster-master-prod"
nodes:
node1: "/mnt/artemis-cluster-node1-prod"
node2: "/mnt/artemis-cluster-node2-prod"
Empty file.
15 changes: 2 additions & 13 deletions Ansible/activemq-artemis/install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,8 @@
- name: Install ActiveMQ Artemis on multiple OS
hosts: artemis_servers
become: yes
vars:
java_packages:
"Ubuntu": "openjdk-11-jdk"
"Debian": "openjdk-11-jdk"
"Rocky": "java-11-openjdk"
"CentOS": "java-11-openjdk"
artemis_version: "2.37.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"
artemis_user: "artemis"
artemis_group: "artemis"
artemis_password: "329awfas"
vars_files:
- vars.yml

tasks:
- name: Ensure required packages are installed
Expand Down
13 changes: 13 additions & 0 deletions Ansible/activemq-artemis/vars.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
java_packages:
"Ubuntu": "openjdk-11-jdk"
"Debian": "openjdk-11-jdk"
"Rocky": "java-11-openjdk"
"CentOS": "java-11-openjdk"
artemis_version: "2.37.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"
artemis_user: "artemis"
artemis_group: "artemis"
artemis_password: "329awfas"
File renamed without changes.
27 changes: 25 additions & 2 deletions Ansible/hashicorp-vault/configure_vault.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
---
- name: Configure and Initialize Vault
hosts: all
become: true
Expand Down Expand Up @@ -44,8 +43,32 @@
failed_when: vault_status_output.rc not in [0, 2]
changed_when: false

- name: Remove old Vault data if already initialized
file:
path: "{{ vault_data_path }}"
state: absent
when: "'Initialized: true' in vault_status_output.stdout"
notify: Restart Vault Service

- name: Recreate Vault data directory
file:
path: "{{ vault_data_path }}"
state: directory
mode: '0755'
owner: vault
group: vault
when: "'Initialized: true' in vault_status_output.stdout"

- name: Restart Vault service
service:
name: vault
state: restarted
when: "'Initialized: true' in vault_status_output.stdout"

- name: Initialize Vault if not already initialized
command: VAULT_ADDR={{ vault_api_addr }} vault operator init -format=json
command: vault operator init -format=json
environment:
VAULT_ADDR: "{{ vault_api_addr }}"
when: "'Initialized: true' not in vault_status_output.stdout"
register: vault_init_output
changed_when: false
Expand Down
11 changes: 10 additions & 1 deletion Ansible/hashicorp-vault/install_package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -90,4 +90,13 @@
ansible.builtin.yum:
name: vault
state: present
when: ansible_facts['os_family'] == "Amazon"
when: ansible_facts['os_family'] == "Amazon"

- name: Display Vault version after successful installation
ansible.builtin.shell: "vault --version"
register: vault_version
changed_when: false

- name: Show installation success message with Vault version
ansible.builtin.debug:
msg: "Vault has been successfully installed. Version: {{ vault_version.stdout }}"

0 comments on commit e163e3e

Please sign in to comment.