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

dev: clean up and update ansible, upgrade to mongo 8 #2921

Merged
merged 9 commits into from
Dec 22, 2024
Merged
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
8 changes: 0 additions & 8 deletions .gitmodules

This file was deleted.

489 changes: 1 addition & 488 deletions deploy/ansible.cfg

Large diffs are not rendered by default.

175 changes: 0 additions & 175 deletions deploy/dependencies.yml

This file was deleted.

184 changes: 184 additions & 0 deletions deploy/dev-server.playbook.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,184 @@
---
- name: Scripture Forge local server for development and testing
hosts: all
become: true
vars_files:
# conditional import
- "vars/{{ ansible_distribution }}-{{ ansible_distribution_major_version | int }}.yml"
- "vars/{{ ansible_distribution }}.yml"
- "vars/{{ ansible_os_family }}.yml"
- "vars/os_defaults.yml"
vars:
node_version: "18.20.2"
mongodb_version: "8.0"
repo_path: "{{ playbook_dir }}/.."
pre_tasks:
- name: Add apt key for mongodb server version {{ mongodb_version }}
ansible.builtin.get_url:
url: https://www.mongodb.org/static/pgp/server-{{ mongodb_version }}.asc
dest: /usr/share/keyrings/mongodb-server-{{ mongodb_version }}.asc
mode: "0644"
- name: Add Mongo repository for version {{ mongodb_version }}
ansible.builtin.copy:
dest: /etc/apt/sources.list.d/mongodb-org.sources
mode: "0644"
content: |
Enabled: yes
Types: deb
URIs: https://repo.mongodb.org/apt/{{ base_distribution }}
Suites: {{ base_distribution_release }}/mongodb-org/{{ mongodb_version }}
Components: {{ 'multiverse' if base_distribution == 'ubuntu' else 'main' }}
Architectures: amd64
Signed-By: /usr/share/keyrings/mongodb-server-{{ mongodb_version }}.asc
tasks:
- name: Install packages
ansible.builtin.apt:
update_cache: true
# Using 'latest' so we upgrade mongo.
state: latest
name:
- "dotnet-sdk-8.0"
- ffmpeg
- "mongodb-org"
- nodejs
- npm

- name: Restart and enable mongod service
# Note that the mongodb-org packages install a service named "mongod", not "mongodb"
ansible.builtin.service:
name: mongod
state: restarted
enabled: true

- name: Wait for mongod to start
# We don't want to try to connect using mongosh until the service is running.
ansible.builtin.wait_for:
port: 27017
delay: 1
timeout: 300

- name: Get current mongod feature compatibility version
ansible.builtin.command: "mongosh --eval 'db.adminCommand( { getParameter: 1, featureCompatibilityVersion: 1 } )'"
register: current_fcv
changed_when: false

- name: Set mongod feature compatibility version
ansible.builtin.command: 'mongosh --eval ''db.adminCommand( { setFeatureCompatibilityVersion: "{{ mongodb_version }}", confirm: true } )'''
when: mongodb_version not in current_fcv.stdout

- name: Get npm prefix
ansible.builtin.command: "npm config get prefix"
register: npm_prefix
changed_when: false

- name: Set npm prefix
ansible.builtin.command: "npm config set prefix /usr/local"
when: npm_prefix.stdout != "/usr/local"

- name: Install n
community.general.npm:
name: n
path: "{{ repo_path }}/src/SIL.XForge.Scripture/ClientApp"
state: latest
global: true

- name: Check current node version
ansible.builtin.shell: node --version || echo error
register: node_version_installed
changed_when: false

- name: Set node version
ansible.builtin.command: "n {{ node_version }}"
when: "node_version_installed.stdout != 'v' + node_version"

# Install mercurial 4.7+ from system or pip
- name: Install pip mercurial dependencies
ansible.builtin.apt:
name:
- python-pip
- python2.7
when: ansible_distribution_major_version | int < 20
- name: Install pip mercurial
ansible.builtin.pip:
name: mercurial
version: 4.8.2
when: ansible_distribution_major_version | int < 20
- name: Install system package mercurial
ansible.builtin.apt:
name:
- mercurial
when: ansible_distribution_major_version | int >= 20

- name: Add folders
ansible.builtin.file:
path: "{{ item }}"
state: directory
owner: "{{ lookup('env', 'USER') }}"
mode: "u=rwX,g=rX,o=rX"
with_items:
- "/var/lib/scriptureforge"
- "/var/lib/scriptureforge/sync"
- "/var/lib/scriptureforge/audio"
- "/var/lib/scriptureforge/training-data"
- "/var/lib/xforge"
- "/var/lib/xforge/avatars"
- "{{ lookup('env', 'HOME') }}/.local/share/SIL/WritingSystemRepository/3"

- name: Add localhost to dnsmasq
ansible.builtin.lineinfile:
path: /etc/NetworkManager/dnsmasq.d/localhost-domain
line: "{{ item }}"
state: present
create: true
mode: "u=rw,g=r,o=r"
with_items:
- "address=/localhost/127.0.0.1"
- "address=/localhost/::1"
when: inventory_hostname == "localhost" and base_distribution_release == 'xenial'
notify: restart network

- name: Enable convenient access to ng from commandline | bin dir
become: false
ansible.builtin.file:
path: "{{ lookup('env', 'HOME') }}/bin"
state: directory
mode: "0755"
when: inventory_hostname == "localhost"
- name: Enable convenient access to ng from commandline | symlink
become: false
ansible.builtin.file:
src: "{{ repo_path }}/src/SIL.XForge.Scripture/ClientApp/node_modules/.bin/ng"
path: "{{ lookup('env', 'HOME') }}/bin/ng"
state: link
force: true
follow: false
when: inventory_hostname == "localhost"

- name: Use chromium for unit tests
become: false
ansible.builtin.lineinfile:
path: "{{ lookup('env', 'HOME') }}/.pam_environment"
line: "CHROME_BIN=chromium-browser"
create: true
mode: "0644"

- name: Install or update reportgenerator
become: false
ansible.builtin.command: dotnet tool update --global dotnet-reportgenerator-globaltool

- name: Install or update csharpier
become: false
ansible.builtin.command: dotnet tool update csharpier

- name: Set initial PT connection settings
become: false
ansible.builtin.copy:
src: InternetSettings.xml
dest: ~/.local/share/Paratext95/
mode: "0644"

handlers:
- name: Restart network
ansible.builtin.service:
name: network-manager
state: restarted
29 changes: 0 additions & 29 deletions deploy/dev.yml

This file was deleted.

Loading
Loading