Skip to content

Commit e4df5b7

Browse files
author
Michael Ro
authored
chore(cassandra): Fix deploy scripts (#995)
* Add deployer scripts for debian * Fix deployer scripts for rhel * fix: Cassandra recipes
1 parent b860f85 commit e4df5b7

File tree

13 files changed

+233
-70
lines changed

13 files changed

+233
-70
lines changed

recipes/newrelic/infrastructure/ohi/cassandra/debian.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ install:
121121
HOSTNAME: {{.NR_CLI_DB_HOSTNAME}}
122122
CONFIG_PATH: /etc/cassandra/cassandra.yaml
123123
REMOTE_MONITORING: true
124-
inventory_source: config/redis
124+
inventory_source: config/cassandra
125125
interval: 60
126126
EOT
127127

recipes/newrelic/infrastructure/ohi/cassandra/rhel.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ install:
107107
sudo cp /etc/newrelic-infra/integrations.d/cassandra-config.yml.sample /etc/newrelic-infra/integrations.d/cassandra-config.yml;
108108
109109
- |
110-
sudo tee -a /etc/newrelic-infra/integrations.d/cassandra-config.yml > /dev/null <<"EOT"
110+
sudo tee /etc/newrelic-infra/integrations.d/cassandra-config.yml > /dev/null <<"EOT"
111111
integrations:
112112
- name: nri-cassandra
113113
env:
@@ -122,9 +122,9 @@ install:
122122
env:
123123
INVENTORY: true
124124
HOSTNAME: {{.NR_CLI_DB_HOSTNAME}}
125-
CONFIG_PATH: /etc/cassandra/cassandra.yaml
125+
CONFIG_PATH: /etc/cassandra/conf/cassandra.yaml
126126
REMOTE_MONITORING: true
127-
inventory_source: config/redis
127+
inventory_source: config/cassandra
128128
interval: 60
129129
EOT
130130

test/deploy/linux/cassandra/install/debian/roles/configure/tasks/main.yml

Lines changed: 30 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
- debug:
3-
msg: Install Cassandra
3+
msg: Configure
44

55
- name: Set default create_newrelic_user (default not create)
66
set_fact:
@@ -12,69 +12,42 @@
1212
create_env_var: "false"
1313
when: create_env_var is undefined
1414

15-
- name: Get latest packages info
16-
shell: "apt-get update -y"
15+
# By default JMX security is disabled.
16+
- name: Require authentication
1717
become: true
18+
ansible.builtin.lineinfile:
19+
path: /etc/cassandra/cassandra-env.sh
20+
regexp: "jmxremote.authenticate=false"
21+
line: ' JVM_OPTS="$JVM_OPTS -Dcom.sun.management.jmxremote.authenticate=true"'
1822

19-
- name: Install dependiences
20-
shell: sudo apt install apt-transport-https ca-certificates wget dirmngr gnupg software-properties-common -y
23+
- name: Configure access file
2124
become: true
25+
ansible.builtin.lineinfile:
26+
path: /etc/cassandra/cassandra-env.sh
27+
regexp: "jmxremote.access.file"
28+
line: JVM_OPTS="$JVM_OPTS -Dcom.sun.management.jmxremote.access.file=/etc/cassandra/jmxremote.access"
2229

23-
- name: Get java keys
24-
shell: wget -qO - https://adoptopenjdk.jfrog.io/adoptopenjdk/api/gpg/key/public | sudo apt-key add -
30+
- name: Add passwords file
2531
become: true
32+
ansible.builtin.copy:
33+
dest: /etc/cassandra/jmxremote.password
34+
content: |
35+
cassandra cassandra
36+
newrelic Virtuoso4all!
2637
27-
- name: Get java repo
28-
shell: sudo add-apt-repository --yes https://adoptopenjdk.jfrog.io/adoptopenjdk/deb/
29-
become: yes
30-
31-
- name: update packages
32-
shell: apt-get update -y
33-
become: yes
34-
35-
- name: install java
36-
shell: sudo apt install adoptopenjdk-8-hotspot -y
37-
become: yes
38-
39-
- name: add cassandra keys
40-
shell: wget -q -O - https://www.apache.org/dist/cassandra/KEYS | sudo apt-key add -
41-
become: yes
42-
43-
- name: add cassandra repo
44-
shell: sudo sh -c 'echo "deb https://www.apache.org/dist/cassandra/debian 311x main" > /etc/apt/sources.list.d/cassandra.list'
45-
become: yes
46-
47-
- name: update packages
48-
shell: apt-get update -y
49-
become: yes
50-
51-
- name: install cassandra
52-
shell: apt install cassandra -y
53-
become: yes
54-
55-
- name: Allow to create user
56-
shell: "sudo sed -i 's/authenticator: AllowAllAuthenticator/authenticator: PasswordAuthenticator/g' /etc/cassandra/cassandra.yaml"
57-
become: yes
58-
59-
- name: restart cassandra
60-
shell: systemctl restart cassandra
61-
become: yes
62-
63-
- name: Ensure Cassandra is ready to accept query
64-
shell: cqlsh localhost 9042 -ucassandra -pcassandra -e "SELECT dateof(now()) FROM system.local ;"
65-
register: output
66-
retries: 20
67-
delay: 15
68-
until: output is not failed
69-
70-
- fail:
71-
msg: "Cassandra is not available, details: {{output}}"
72-
when: output is failed
38+
- name: Add access file
39+
become: true
40+
ansible.builtin.copy:
41+
dest: /etc/cassandra/jmxremote.access
42+
content: |
43+
cassandra readwrite
44+
newrelic readonly
7345
74-
- name: Create newrelic login
75-
shell: cqlsh localhost 9042 -ucassandra -pcassandra -e "CREATE USER newrelic WITH PASSWORD 'Virtuoso4all!';"
76-
become: yes
77-
when: create_newrelic_user|bool
46+
- name: Restart Cassandra
47+
become: true
48+
ansible.builtin.systemd:
49+
name: cassandra
50+
state: restarted
7851

7952
- block:
8053
- name: Export USERNAME
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
- debug:
3+
msg: Install Cassandra
4+
5+
- name: Add cassandra repo
6+
shell: echo "deb https://debian.cassandra.apache.org 41x main" | sudo tee -a /etc/apt/sources.list.d/cassandra.sources.list
7+
become: true
8+
9+
- name: add cassandra keys
10+
shell: wget -q -O - https://www.apache.org/dist/cassandra/KEYS | sudo apt-key add -
11+
become: true
12+
13+
- name: Install cassandra
14+
ansible.builtin.apt:
15+
name: cassandra
16+
update_cache: yes
17+
become: true
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
---
2+
- debug:
3+
msg: Install dependencies
4+
5+
- name: Update repository cache and install packages
6+
ansible.builtin.apt:
7+
pkg:
8+
- apt-transport-https
9+
- ca-certificates
10+
- wget
11+
- dirmngr
12+
- gnupg
13+
- software-properties-common
14+
- wget
15+
update_cache: true
16+
become: true
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
---
2+
- include_tasks: installDependencies.yml
3+
- include_tasks: installCassandra.yml
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
---
2+
- debug:
3+
msg: Configure
4+
5+
- name: Set default create_newrelic_user (default not create)
6+
set_fact:
7+
create_newrelic_user: "false"
8+
when: create_newrelic_user is undefined
9+
10+
- name: Set default create_env_var (default not create)
11+
set_fact:
12+
create_env_var: "false"
13+
when: create_env_var is undefined
14+
15+
# By default JMX security is disabled.
16+
- name: Require authentication
17+
become: true
18+
ansible.builtin.lineinfile:
19+
path: /etc/cassandra/conf/cassandra-env.sh
20+
regexp: "jmxremote.authenticate=false"
21+
line: ' JVM_OPTS="$JVM_OPTS -Dcom.sun.management.jmxremote.authenticate=true"'
22+
23+
- name: Configure access file
24+
become: true
25+
ansible.builtin.lineinfile:
26+
path: /etc/cassandra/conf/cassandra-env.sh
27+
regexp: "jmxremote.access.file"
28+
line: JVM_OPTS="$JVM_OPTS -Dcom.sun.management.jmxremote.access.file=/etc/cassandra/jmxremote.access"
29+
30+
- name: Add passwords file
31+
become: true
32+
ansible.builtin.copy:
33+
dest: /etc/cassandra/jmxremote.password
34+
content: |
35+
cassandra cassandra
36+
newrelic Virtuoso4all!
37+
38+
- name: Add access file
39+
become: true
40+
ansible.builtin.copy:
41+
dest: /etc/cassandra/jmxremote.access
42+
content: |
43+
cassandra readwrite
44+
newrelic readonly
45+
46+
- name: Restart Cassandra
47+
become: true
48+
ansible.builtin.systemd:
49+
name: cassandra
50+
state: restarted
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
---
2+
- debug:
3+
msg: Install Cassandra
4+
5+
- name: Add Cassandra repo
6+
become: true
7+
ansible.builtin.blockinfile:
8+
create: true
9+
path: /etc/yum.repos.d/cassandra.repo
10+
block: |
11+
[cassandra]
12+
name=Apache Cassandra
13+
baseurl=https://redhat.cassandra.apache.org/41x/noboolean
14+
gpgcheck=1
15+
repo_gpgcheck=1
16+
gpgkey=https://downloads.apache.org/cassandra/KEYS
17+
18+
- name: Install Cassandra
19+
become: true
20+
ansible.builtin.yum:
21+
name: cassandra
22+
update_cache: true
23+
state: present
24+
25+
- name: Start Cassandra
26+
become: true
27+
ansible.builtin.systemd:
28+
name: cassandra
29+
enabled: true
30+
state: started
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
- debug:
3+
msg: Install dependencies
4+
5+
- name: Update repository cache and install packages
6+
ansible.builtin.yum:
7+
name:
8+
- curl
9+
- wget
10+
update_cache: true
11+
become: true
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
---
2+
- debug:
3+
msg: Install Java
4+
5+
- name: Install Java
6+
become: true
7+
ansible.builtin.yum:
8+
name: java-1.8.0-openjdk-devel
9+
update_cache: true
10+
state: present
11+
12+
- name: Add JAVA_HOME env root
13+
shell: "echo 'export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk' >> ~/.bashrc"
14+
become: true
15+
- name: Add JAVA_HOME env user
16+
shell: "echo 'export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk' >> ~/.bashrc"
17+
18+
- name: Add JRE_HOME env root
19+
shell: "echo 'export JRE_HOME=/usr/lib/jvm/java-1.8.0-openjdk/jre' >> ~/.bashrc"
20+
become: true
21+
- name: Add JRE_HOME env user
22+
shell: "echo 'export JRE_HOME=/usr/lib/jvm/java-1.8.0-openjdk/jre' >> ~/.bashrc"
23+
24+
- name: Add JAVA_HOME to path root
25+
shell: "echo 'export PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin' >> ~/.bashrc"
26+
become: true
27+
- name: Add JAVA_HOME to path user
28+
shell: "echo 'export PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin' >> ~/.bashrc"

0 commit comments

Comments
 (0)