forked from stackbill/marketplace
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathactivemq.yaml
125 lines (102 loc) · 4.22 KB
/
activemq.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
- name: ActiveMQ Setup
hosts: localhost
tasks:
- name: Restarting sshd
shell: "sed -i 's/#Match User anoncvs/ForceCommand echo Please wait until the installation is completed..../g' /etc/ssh/sshd_config && systemctl restart sshd"
- name: Updating Packages
ansible.builtin.apt:
update_cache: yes
- name: Installing Java
apt:
name: default-jdk
state: latest
- name: Creating a group for activemq
group:
name: activemq
state: present
system: yes
- name: Creating a user for activemq
ansible.builtin.user:
name: activemq
shell: /usr/sbin/nologin
groups: activemq
create_home: no
system: yes
- name: Get the directory listing
shell: |
curl -s https://dlcdn.apache.org/activemq/ \
| grep -oP '(?<=<a href=")[^/]+(?=/")' \
| grep -E '^[0-9]+\.[0-9]+\.[0-9]+$' \
| sort -V \
| head -n 1
register: latest_version
- name: Download activemq files
ansible.builtin.unarchive:
src: https://dlcdn.apache.org/activemq/{{ latest_version.stdout }}/apache-activemq-{{ latest_version.stdout }}-bin.tar.gz
dest: /opt/
remote_src: yes
- name: Change ownership of a directory
ansible.builtin.file:
path: /opt/apache-activemq-{{ latest_version.stdout }}
state: directory
recurse: yes
owner: activemq
group: activemq
- name: Generating activemq password
shell: openssl rand -hex 24
register: activemqadminpassword
- debug:
var: activemqadminpassword.stdout
- name: Storing activemq password
copy:
dest: "/root/.activemq_admin_password"
content: |
activemq_user = admin
activemq_pass = "{{ activemqadminpassword.stdout }}"
- name: Replacing localhost in the configuration file
shell: "{{ item }}"
with_items:
- "sed -i 's/127.0.0.1/0.0.0.0/g' /opt/apache-activemq-{{ latest_version.stdout }}/conf/jetty.xml"
- "sed -i 's/admin: admin, admin/admin: {{ activemqadminpassword.stdout }}, admin/g' /opt/apache-activemq-{{ latest_version.stdout }}/conf/jetty-realm.properties"
- "sed -i 's/user: user, user//g' /opt/apache-activemq-{{ latest_version.stdout }}/conf/jetty-realm.properties"
- name: change the version name on the activemq.service
replace:
path: /usr/local/src/activemq-22-04/etc/systemd/system/activemq.service
regexp: '5.17.4'
replace: '{{ latest_version.stdout }}'
- name: Copy files for shell script
copy:
src: "{{ item.confsrc }}"
dest: "{{ item.confdest }}"
with_items:
- { confsrc: '/usr/local/src/activemq-22-04/etc/systemd/system/activemq.service', confdest: '/etc/systemd/system/'}
- name: Reload Daemon
ansible.builtin.systemd:
daemon_reload: true
- name: Enable activemq
ansible.builtin.systemd:
name: activemq.service
state: started
enabled: true
- name: Getting the status of the service
shell: systemctl status activemq.service | grep 'since'
register: status
- debug:
var: status.stdout
- name: Creating a directory for shell script
ansible.builtin.file:
path: /opt/cloudstack
state: directory
- name: Copy files for shell script
copy:
src: "{{ item.confsrc }}"
dest: "{{ item.confdest }}"
with_items:
- { confsrc: '/usr/local/src/activemq-22-04/opt/cloudstack/activemq-cleanup.sh', confdest: '/opt/cloudstack/'}
- name: Adding a line for shell script
lineinfile:
path: /root/.bashrc
line: "chmod +x /opt/cloudstack/activemq-cleanup.sh && /opt/cloudstack/activemq-cleanup.sh"
state: present
- name: Restarting sshd
shell: "sed -i 's/ForceCommand echo Please wait until the installation is completed..../#Match User anoncvs/g' /etc/ssh/sshd_config && systemctl restart sshd"