Skip to content

Commit

Permalink
Merge pull request #99 from glormph/deploy-change-to-different-setup-vms
Browse files Browse the repository at this point in the history
Deploy change to different setup
  • Loading branch information
glormph authored Jun 25, 2024
2 parents f6fe991 + 83ce67e commit 237288f
Show file tree
Hide file tree
Showing 51 changed files with 665 additions and 453 deletions.
17 changes: 14 additions & 3 deletions deploy/analysis_deploy.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,15 @@
---
- import_playbook: analysis_stop.yml
- import_playbook: analysis_update.yml
- import_playbook: analysis_start.yml
- hosts: analysis
remote_user: "{{ analysis_connect_user }}"
tasks:
- name: Stop running workers
ansible.builtin.import_tasks:
file: stop_celery.yml

- name: Specific analysis tasks
ansible.builtin.import_tasks:
file: analysis_tasks.yml

- name: General kantele/celery updates
ansible.builtin.import_tasks:
file: update_analysis_storage_tasks.yml
56 changes: 56 additions & 0 deletions deploy/analysis_from_scratch.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
---
# Tasks to only run once when you get a provisioned VM
# Installs packages, nextflow and prepares directories.
#
# Upgrading of these can later be done in another playbook (or in code)

- hosts: analysis
remote_user: '{{ analysis_connect_user }}'
become: yes
tasks:
- name: Install packages
ansible.builtin.apt:
pkg:
- git
- docker.io
- docker-compose-v2
- default-jre-headless
- python3-venv
- libpq-dev
- python3-dev
- build-essential
- cifs-utils
- slurm-wlm
- slurm-client
- slurmdbd
- munge
- mariadb-server
- python3-mysqldb
state: present
update_cache: yes

- name: Create kantele group
ansible.builtin.group:
name: "{{ kantelegroup }}"
state: present

- name: Create kantele user
ansible.builtin.user:
name: "{{ kanteleuser }}"
group: "{{ kantelegroup }}"
create_home: yes

- name: Download nextflow
become_user: "{{ kanteleuser }}"
ansible.builtin.shell:
cmd: "curl -s https://get.nextflow.io | bash"
chdir: "/home/{{ kanteleuser }}"

- name: Put NF in path
ansible.builtin.copy:
src: "/home/{{ kanteleuser }}/nextflow"
dest: /usr/local/bin/nextflow
mode: u=rwx,g=rx,a=rx
owner: kanteleadmin
group: kanteleadmin
remote_src: yes
80 changes: 0 additions & 80 deletions deploy/analysis_start.yml

This file was deleted.

11 changes: 0 additions & 11 deletions deploy/analysis_stop.yml

This file was deleted.

104 changes: 104 additions & 0 deletions deploy/analysis_tasks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
---
# Tasks for analysis node
#
- name: Create scratch dir for running
become: yes
ansible.builtin.file:
path: "{{ baserun_dir }}"
state: directory
owner: "{{ kanteleuser }}"
group: "{{ kanteleuser }}"

- name: Mount storages
become: yes
mount:
path: "{{ item.0 }}"
src: "{{ item.1 }}"
state: mounted
fstype: cifs
opts: "credentials={{ mount_cred }},uid={{ kanteleuser }},domain={{ mount_domain }}"
loop: "{{ storagedirs | zip(storageservers) | list }}"

- name: Set mariaDB root password
become: yes
community.mysql.mysql_user:
name: root
host: "{{ item }}"
password: "{{ slurm_mysql_root_passwd }}"
with_items:
- localhost
# Default is no remote access, so do not set root password for below interfaces
#- 127.0.0.1
#- ::1

- name: Set ~/.my.cnf file with root pass so prev task does not error on idempotent multiple runs
become: yes
template:
src: slurm_mariadb_my.cnf.j2
dest: /root/.my.cnf
mode: 0600

- name: Slurm config file
become: yes
ansible.builtin.template:
src: slurm_conf.j2
dest: /etc/slurm/slurm.conf
mode: '755'
owner: slurm

- name: Slurm DBD config file
become: yes
ansible.builtin.template:
src: slurmdbd.conf.j2
dest: /etc/slurm/slurmdbd.conf
mode: '600'
owner: slurm

- name: Create Slurm dir in spool
become: yes
ansible.builtin.file:
path: /var/spool/slurm
state: directory
owner: slurm
group: slurm

- name: Set Slurm user in mariaDB
become: yes
community.mysql.mysql_user:
login_user: root
login_password: "{{ slurm_mysql_root_passwd }}"
host: localhost
name: slurm
password: "{{ slurm_mysql_user_passwd }}"
priv: 'slurm_acct.*:ALL'

- name: Start Slurm
become: yes
systemd:
state: started
enabled: true
daemon_reload: yes
name: "{{ item }}"
with_items:
- munge
- slurmctld
- slurmd
- slurmdbd

- name: Get QOS in slurm
ansible.builtin.shell:
cmd: "sacctmgr show qos filter name=qc"
register: qos_qc

- name: Set QOS in slurm if not set
become: yes
become_user: slurm
ansible.builtin.shell:
cmd: "{{ item }}"
# 3 lines if exists: headerfields, header-separator-horizontal-line, row-with-qc-qos
# so only run if 2 lines (no row-with-qc-qos)
when: qos_qc.stdout_lines | length == 2
# -i is for immediate (no prompt y/n)
with_items:
- "sacctmgr -i add qos qc"
- "sacctmgr -i modify qos qc set priority=100"
36 changes: 0 additions & 36 deletions deploy/analysis_update.yml

This file was deleted.

4 changes: 2 additions & 2 deletions deploy/db-archive-restore.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
---
# DB restoring on production from backup

- hosts: kantele
- hosts: web
become: yes
become_user: '{{ web_user }}'
become_user: '{{ kanteleuser }}'
tasks:
- name: Remove running docker containers
community.docker.docker_compose:
Expand Down
55 changes: 11 additions & 44 deletions deploy/default_inventory/group_vars/all
Original file line number Diff line number Diff line change
Expand Up @@ -6,55 +6,22 @@ mq_vhost: kantele_vhost
rabbituser: kantele

kanteledir: '{{ homedir }}/kantele'
kantelevenv: "{{ kanteledir }}/venv"

# DB accessed also from storage node for DB dumping
kanteledb: kanteledb
kanteledbuser: kanteleuser
pgdatadir: "{{ homedir }}/pgdata"
web_homedir: "/home/{{ web_user }}"
host_pgbackup_path: "{{ web_homedir }}/pgbackups"

compose_env_file: '{{ web_homedir }}/kantele/.compose.prod.env'

tls_cert: server.crt
tls_cert_key: server.key

# DB backups in web container
# DB dumping needs dir to dump in and uses compose so needs the env file
host_pgbackup_path: "{{ homedir }}/pgbackups"
container_backuppath: /pgbackups
compose_env_file: '{{ homedir }}/kantele/.compose.prod.env'

# Upload paths in nginx container
container_uploadpath: /uploads
host_uploadpath: "{{ kanteledir }}/uploads"
upload_path_url: /uploads

# Analysis paths in nginx container
container_analysispath: /analysisfiles
host_analysispath: "{{ kanteledir }}/srv_analysis"
analysis_path_url: /analysisfiles

# DEPRECATE if not used in backup DL script
web_backupfolder: backups
backup_dl_url: "https://{{ kantele_host }}{{ analysis_path_url }}/{{ web_backupfolder }}"

storagesharenames: "storage,s3storage"
celeryenv_file: "{{ kanteledir }}/celery.env"
kantelelogdir: "{{ kanteledir }}/log"

storage_env:
SECRET_KEY: "{{ secret_key }}"
PROTOCOL: https
KANTELEHOST: "{{ kantele_host }}"
RABBITHOST: "{{ kantele_host }}"
RABBIT_VHOST: '{{ mq_vhost }}'
RABBITPASS: "{{ amqppass }}"
RABBITUSER: "{{ rabbituser }}"
APIKEY: "{{ storage_apikey }}"
ADMIN_APIKEY: "{{ admin_apikey }}"
STORAGESHARENAMES: "{{ storagesharenames }}"
STORAGESHARES: "{{ storage_shares }}"
ANALYSISSHARE: "{{ analysis_share }}"
TMPSHARE: "{{ tmp_share }}"
MZMLINSHARE: "{{ mzml_in_share }}"
DSM_DIR: "{{ dsm_dir }}"
DATABASE_FTID: "{{ database_ftid }}" # for download/register ensembl
RSYNC_SSHPORT: 22 # ssh port on upload
RSYNC_SSHUSER: '{{ web_user }}'
RSYNC_SSHKEY: '{{ rsync_ssh_key }}'
PRIMARY_STORAGE: '{{ primary_storagename }}'
queue_local: mv_md5_storage
queue_dl: file_download
queue_backup: backup_archive
queue_scan: scaninbox
1 change: 1 addition & 0 deletions deploy/default_inventory/host_vars/analysis
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
celery_env_template_file: celery_analysis_env.j2
5 changes: 5 additions & 0 deletions deploy/default_inventory/host_vars/storadmin
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
celery_env_template_file: celery_storage_env.j2

tivoli_client_url: "https://aix.software.ibm.com/storage/tivoli-storage-management/maintenance/client/v8r1/Linux/LinuxX86_DEB/BA/v8122/8.1.22.0-TIV-TSMBAC-LinuxX86_DEB.tar"

dsm_dir: "{{ homedir }}/dsmc_conf"
Loading

0 comments on commit 237288f

Please sign in to comment.