-
Notifications
You must be signed in to change notification settings - Fork 396
Expand file tree
/
Copy pathcassandra.yaml
More file actions
73 lines (63 loc) · 1.88 KB
/
cassandra.yaml
File metadata and controls
73 lines (63 loc) · 1.88 KB
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
- name: Cassandra Setup
hosts: "{{ host }}"
become: true
vars:
ansible_ssh_user: "{{ admin_user }}"
tasks:
- name: Check if cassandra is installed
stat:
path: /opt/cassandra/bin/cassandra
register: cassandra_exists
- name: Install java
apt:
pkg: openjdk-17-jre
- name: Create cassandra group
group:
name: cassandra
system: yes
- name: Create cassandra user
user:
name: cassandra
group: cassandra
shell: /sbin/nologin
system: yes
- name: Download cassandra
when: not cassandra_exists.stat.exists
get_url:
url: "https://dlcdn.apache.org/cassandra/{{ cassandra_version }}/apache-cassandra-{{ cassandra_version }}-bin.tar.gz "
dest: "/tmp/cassandra-{{ cassandra_version }}.tar.gz"
mode: '0644'
- name: Ensure /opt/cassandra directory exists
file:
path: /opt/cassandra
owner: "cassandra"
group: "cassandra"
state: directory
- name: Extract cassandra
when: not cassandra_exists.stat.exists
unarchive:
src: "/tmp/cassandra-{{ cassandra_version }}.tar.gz"
dest: /opt/cassandra/
remote_src: yes
owner: "cassandra"
group: "cassandra"
extra_opts:
- --strip-components=1
- name: Add /opt/cassandra/bin to PATH
lineinfile:
path: /home/{{ ansible_user }}/.bashrc
line: PATH=/opt/cassandra/bin:$PATH
state: present
- name: Create Cassandra systemd service
template:
src: services/cassandra.service.j2
dest: /etc/systemd/system/cassandra.service
vars:
cassandra_telemetry_user: "{{ lookup('ini', 'cassandra_telemetry_user', file=ini_file) }}"
cassandra_telemetry_pass: "{{ lookup('ini', 'cassandra_telemetry_pass', file=ini_file) }}"
- name: Start Cassandra
systemd_service:
name: cassandra
state: started
daemon_reload: true
enabled: true