Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: ensure aerospike service is enabled at boot #9

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
280 changes: 141 additions & 139 deletions install-aerospike.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,160 +5,162 @@
become: yes
remote_user: "{{ os_config['remote_user'] }}"
vars_files:
- vars/cluster-config.yml
- vars/constants.yml
- vars/os-level-config.yml
- vars/cluster-config.yml
- vars/constants.yml
- vars/os-level-config.yml
tasks:
- name: Import configuration properties
include_vars:
dir: vars

- name: Get service facts
service_facts:
- name: Import configuration properties
include_vars:
dir: vars

- block:
- name: Installation previously completed message
debug:
msg: "Aerospike is already installed - not re-installing"

- meta: end_host
when: hostvars[inventory_hostname].services[aerospike_service_name] is defined

- block:
- debug:
msg: "Aerospike service is not installed - executing install steps"
- name: Get service facts
service_facts:

- block:
- name: If Ubuntu, update package cache
shell: |
sudo apt update
when: operating_system == ubuntu_os
- name: Installation previously completed message
debug:
msg: "Aerospike is already installed - not re-installing"

- meta: end_host
when: hostvars[inventory_hostname].services[aerospike_service_name] is defined

- block:
- name: "stat {{ feature_key_path }}"
local_action: "stat path={{ feature_key_path }}"
become: no
register: feature_key_meta

- name: "Check feature key {{ feature_key_path }} exists"
fail:
msg: "Specified feature key {{ feature_key_path }} not found"
when: not feature_key_meta.stat.exists
when: enterprise

- name: Check whether download exists
stat:
path: "{{ download_path }}"
register: stat_download_path

- name: Download Aerospike {{ 'Enterprise' if enterprise else 'Community' }}, version = {{ aerospike_version }}, distribution = {{ aerospike_distribution }} if not already downloaded
get_url:
url: "{{ download_url }}"
dest: "{{ download_path }}"
when: not stat_download_path.stat.exists

- name: Unpack installer
unarchive:
remote_src: "yes"
src: "{{ download_path }}"
dest: "{{ download_file_dir }}"
list_files: true
register: result

- name: Get install directory
set_fact:
install_directory: "{{ result.files[0] }}"

- name: "Install Aerospike with strong consistency = {{ strong_consistency }}, tls = {{ tls_enabled }}, encryption at rest = {{ encryption_at_rest }}"
command:
chdir: "{{ download_file_dir }}/{{ install_directory }}"
cmd: "{{ download_file_dir }}/{{ install_directory }}/asinstall"

- name: "Create {{ partition_script_name }} script"
template:
src: "assets/{{ partition_script_name }}.j2"
dest: "/tmp/{{ partition_script_name }}"
mode: 0755

- name: "Partition nvme drives"
shell: "/tmp/{{ partition_script_name }}"

- name: aerospike.conf
import_tasks: modules/aerospike-configuration-tasks.yml

- block:
- name: Feature key
copy:
src: "{{ feature_key_path }}"
dest: /etc/aerospike/features.conf
owner: root
group: root
mode: '0644'
when: enterprise

- import_tasks: modules/prometheus-exporter-install.yml
when: monitoring_enabled

# asadm requires python3 & roster set below requires asadm - so need to do install here
- name: Install python3
- debug:
msg: "Aerospike service is not installed - executing install steps"

- block:
- name: If Ubuntu, update package cache
shell: |
sudo apt update
when: operating_system == ubuntu_os

- block:
- name: "stat {{ feature_key_path }}"
local_action: "stat path={{ feature_key_path }}"
become: no
register: feature_key_meta

- name: "Check feature key {{ feature_key_path }} exists"
fail:
msg: "Specified feature key {{ feature_key_path }} not found"
when: not feature_key_meta.stat.exists
when: enterprise

- name: Check whether download exists
stat:
path: "{{ download_path }}"
register: stat_download_path

- name: Download Aerospike {{ 'Enterprise' if enterprise else 'Community' }}, version = {{ aerospike_version }}, distribution = {{ aerospike_distribution }} if not already downloaded
get_url:
url: "{{ download_url }}"
dest: "{{ download_path }}"
when: not stat_download_path.stat.exists

- name: Unpack installer
unarchive:
remote_src: "yes"
src: "{{ download_path }}"
dest: "{{ download_file_dir }}"
list_files: true
register: result

- name: Get install directory
set_fact:
install_directory: "{{ result.files[0] }}"

- name: "Install Aerospike with strong consistency = {{ strong_consistency }}, tls = {{ tls_enabled }}, encryption at rest = {{ encryption_at_rest }}"
command:
chdir: "{{ download_file_dir }}/{{ install_directory }}"
cmd: "{{ download_file_dir }}/{{ install_directory }}/asinstall"

- name: "Create {{ partition_script_name }} script"
template:
src: "assets/{{ partition_script_name }}.j2"
dest: "/tmp/{{ partition_script_name }}"
mode: 0755

- name: "Partition nvme drives"
shell: "/tmp/{{ partition_script_name }}"

- name: aerospike.conf
import_tasks: modules/aerospike-configuration-tasks.yml

- block:
- name: Feature key
copy:
src: "{{ feature_key_path }}"
dest: /etc/aerospike/features.conf
owner: root
group: root
mode: "0644"
when: enterprise

- import_tasks: modules/prometheus-exporter-install.yml
when: monitoring_enabled

# asadm requires python3 & roster set below requires asadm - so need to do install here
- name: Install python3
package:
name:
- python3
state: latest
become: yes

- name: Start service aerospike
ansible.builtin.service:
name: aerospike
state: started
enabled: "{{ aerospike_service_enabled }}"

- block:
- name: Copy roster set script
template:
src: "assets/strong-consistency/roster-set.sh.j2"
dest: "/tmp/roster-set.sh"
mode: "0755"

- name: "Set roster"
shell: "/tmp/roster-set.sh"

when: strong_consistency

- name: Installation complete message
debug:
msg: "Aerospike install complete"

when: ( hostvars[inventory_hostname].services[aerospike_service_name] is not defined ) or not(hostvars[inventory_hostname].services[aerospike_service_name].state == 'running')

# May not be available as standard - this is the case on GCP
- name: Install sysstat
package:
name:
- python3
- sysstat
state: latest
become: yes

- name: Start Aerospike service
shell:
cmd: "service aerospike start"

- block:
- name: Copy roster set script
template:
src: "assets/strong-consistency/roster-set.sh.j2"
dest: "/tmp/roster-set.sh"
mode: "0755"

- name: "Set roster"
shell: "/tmp/roster-set.sh"

when: strong_consistency

- name: Installation complete message
debug:
msg: "Aerospike install complete"

when: ( hostvars[inventory_hostname].services[aerospike_service_name] is not defined ) or not(hostvars[inventory_hostname].services[aerospike_service_name].state == 'running')

# May not be available as standard - this is the case on GCP
- name: Install sysstat
package:
name:
- sysstat
state: latest
become: yes

- name: Update monitoring if enabled
hosts: "{{ monitoring_tag }}"
gather_facts: true
become: yes
remote_user: "{{ os_config['remote_user'] }}"
vars_files:
- vars/cluster-config.yml
- vars/constants.yml
- vars/os-level-config.yml
- vars/cluster-config.yml
- vars/constants.yml
- vars/os-level-config.yml
tasks:
- name: Import configuration properties
include_vars:
dir: vars
- name: Get service facts
service_facts:

# When Prometheus is installed, we update the config file - might be necessary as we have added nodes
- import_tasks: modules/prometheus-configuration.yml
when: hostvars[inventory_hostname].services[prometheus_service_name] is defined

- name: Restart prometheus
service:
name: prometheus
state: restarted
- name: Import configuration properties
include_vars:
dir: vars

- name: Get service facts
service_facts:

# When Prometheus is installed, we update the config file - might be necessary as we have added nodes
- import_tasks: modules/prometheus-configuration.yml
when: hostvars[inventory_hostname].services[prometheus_service_name] is defined

- name: Restart prometheus
service:
name: prometheus
state: restarted
8 changes: 4 additions & 4 deletions vars/constants.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ spark_tag: "{{ cluster_identifier }}_spark"
# Tag for Kafka instances
kafka_tag: "{{ cluster_identifier }}_kafka"

# Downloading
# Downloading
aerospike_download_suffix: "/artifact"

aerospike_download_prefix: "http://www.aerospike.com/{{ 'enterprise/' if enterprise else ''}}download/server/"
Expand Down Expand Up @@ -37,10 +37,9 @@ prometheus_exporter_download_path: "{{ prometheus_exporter_download_file_dir }}/
scripts_directory_name: scripts
aerospike_conf_file_name: aerospike.conf
ip_address_script_name: ip-address-list.sh
quick_ssh_script_name: quick-ssh.sh
quick_ssh_script_name: quick-ssh.sh
partition_script_name: partition-script.sh


# Prometheus / Grafana
prometheus_service_name: "prometheus.service"
grafana_service_name: "grafana-server.service"
Expand All @@ -55,7 +54,7 @@ encryption_key_file_path: "/etc/aerospike/encryption-at-rest-key.dat"

# TLS
tls_name: "{{ cluster_name }}"
local_certs_directory: "assets/certificates/certs"
local_certs_directory: "assets/certificates/certs"
certificates_directory: /etc/aerospike/certs
private_key_directory: "{{ certificates_directory }}/private"

Expand Down Expand Up @@ -93,4 +92,5 @@ ansible_ssh_private_key_file: "{{cluster_identifier}}.aws.pem"
# Other
cluster_name: aerospike_ansible_demo_cluster
aerospike_service_name: "aerospike.service"
aerospike_service_enabled: false
temp_directory: "/tmp"