Skip to content
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
5 changes: 5 additions & 0 deletions ansible/all.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@
- usegalaxy_ca.gxadmin
- galaxyproject.gxadmin
- usegalaxy_ca.backup_pg
- role: usegalaxy_ca.kui
when: inventory_hostname.startswith('prod-') # only set it up on prod
tags:
- never
- kui

- name: tusd
import_playbook: tusd.yml
Expand Down
3 changes: 3 additions & 0 deletions ansible/roles/usegalaxy_ca.kui/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
user_tables: "users-ca"
jobs_table: "jobs-ca"
usage_table: "usage-ca"
95 changes: 95 additions & 0 deletions ansible/roles/usegalaxy_ca.kui/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
---
- name: Download Google Cloud SDK repository key
become: true
ansible.builtin.get_url:
url: https://packages.cloud.google.com/apt/doc/apt-key.gpg
dest: /tmp/google-cloud-apt-key.gpg
mode: "0644"

- name: Install GnuPG (required to create the Google Cloud SDK keyring)
become: true
ansible.builtin.apt:
name: gnupg
state: present

- name: Create Google Cloud SDK keyring
ansible.builtin.command:
cmd: >
gpg --dearmor
--output /usr/share/keyrings/cloud.google.gpg
/tmp/google-cloud-apt-key.gpg
args:
creates: /usr/share/keyrings/cloud.google.gpg

- name: Add Google Cloud SDK repository
become: true
ansible.builtin.apt_repository:
repo: >-
deb [signed-by=/usr/share/keyrings/cloud.google.gpg]
https://packages.cloud.google.com/apt cloud-sdk main
filename: google-cloud-sdk
state: present

- name: Install Google Cloud CLI
become: true
ansible.builtin.apt:
name: google-cloud-cli
state: present
update_cache: true

- name: Download KUI script
ansible.builtin.get_url:
url: https://raw.githubusercontent.com/galaxyproject/kui/4e402afbca7d418413a853561de0a5a304cc6305/kui.sh
dest: "/home/{{ ansible_user }}/kui.sh"
owner: "{{ ansible_user }}"
group: "{{ ansible_user }}"
mode: '0755'
checksum: "sha256:1f2a3c9200c99e82347759fdb954b50c47b70b215b4e2b2a1c2bd062619e1269"

- name: Configure KUI script variables
ansible.builtin.lineinfile:
path: "/home/{{ ansible_user }}/kui.sh"
regexp: '^{{ item.key }}=.*'
line: '{{ item.key }}="{{ item.value }}"'
loop:
- {key: 'USERS_TABLE', value: "{{ user_tables }}"}
- {key: 'JOBS_TABLE', value: "{{ jobs_table }}"}
- {key: 'USAGE_TABLE', value: "{{ usage_table }}"}

- name: Change Galaxy server hostname
ansible.builtin.replace:
path: "/home/{{ ansible_user }}/kui.sh"
regexp: '^galaxy_server="https://usegalaxy\.org"$'
replace: 'galaxy_server="https://{{ usegalaxy_domain }}"'

Comment thread
ccoulombe marked this conversation as resolved.
- name: Set Postgres environment variables
ansible.builtin.lineinfile:
path: "/home/{{ ansible_user }}/kui.sh"
regexp: '^export {{ item.key }}='
line: 'export {{ item.key }}={{ item.value }}'
insertbefore: '^export PGDATABASE='
loop:
- key: PGHOST
value: "{{ groups['dbservers'][0] }}"
- key: PGUSER
value: "{{ galaxy_user_name }}"
- key: PGDATABASE
value: "{{ galaxy_db_name }}"

Comment thread
ccoulombe marked this conversation as resolved.
- name: Ensure KUI log directory exists
ansible.builtin.file:
path: "/home/{{ ansible_user }}/kui-logs"
state: directory
owner: "{{ ansible_user }}"
group: "{{ ansible_user }}"
mode: "0755"

- name: Set cron job to run KUI script monthly
ansible.builtin.cron:
name: Run KUI script
day: "1"
hour: "1"
minute: "0"
user: "{{ ansible_user }}"
job: >-
bash $HOME/kui.sh 2>&1 | tee -a "$HOME/kui-logs/kui-run-$(date -d "$(date +\%Y-\%m-01) -1 day" +\%Y\%m).log"
Comment thread
ccoulombe marked this conversation as resolved.
Loading