|
| 1 | +--- |
| 2 | +- name: Deploy Open Terms Archive applications |
| 3 | + hosts: all |
| 4 | + tasks: |
| 5 | + - name: Load OTA applications configs |
| 6 | + ansible.builtin.include_role: |
| 7 | + name: ota/apps |
| 8 | + public: true # ensure that the role's variables and defaults are accessible to the play |
| 9 | + vars: |
| 10 | + ota_apps_read_config_only: true |
| 11 | + |
| 12 | + - name: Set required variables |
| 13 | + set_fact: |
| 14 | + chromium_required: "{{ ota_apps_config['@opentermsarchive/engine'] is defined }}" |
| 15 | + # Skip Debian 11 with ARM architecture as it is not currently supported by MongoDB; see https://www.mongodb.com/docs/manual/installation/#supported-platforms |
| 16 | + mongo_required: |
| 17 | + "{{ |
| 18 | + (ansible_distribution != 'Debian' or (ansible_distribution == 'Debian' and ansible_facts['architecture'] != 'aarch64')) |
| 19 | + and ( |
| 20 | + (ota_apps_config['@opentermsarchive/engine'].recorder.versions.storage.type is defined and ota_apps_config['@opentermsarchive/engine'].recorder.versions.storage.type == 'mongo') |
| 21 | + or |
| 22 | + (ota_apps_config['@opentermsarchive/engine'].recorder.snapshots.storage.type is defined and ota_apps_config['@opentermsarchive/engine'].recorder.snapshots.storage.type == 'mongo') |
| 23 | + ) | bool |
| 24 | + }}" |
| 25 | + |
| 26 | + snapshots_repository: "{{ ota_apps_config['@opentermsarchive/engine'].recorder.snapshots.storage.git.repository is defined and ota_apps_config['@opentermsarchive/engine'].recorder.snapshots.storage.git.repository }}" |
| 27 | + snapshots_path: "{{ ota_apps_config['@opentermsarchive/engine'].recorder.snapshots.storage.git.path is defined and ota_apps_config['@opentermsarchive/engine'].recorder.snapshots.storage.git.path }}" |
| 28 | + |
| 29 | + versions_repository: "{{ ota_apps_config['@opentermsarchive/engine'].recorder.versions.storage.git.repository is defined and ota_apps_config['@opentermsarchive/engine'].recorder.versions.storage.git.repository }}" |
| 30 | + versions_path: "{{ ota_apps_config['@opentermsarchive/engine'].recorder.versions.storage.git.path is defined and ota_apps_config['@opentermsarchive/engine'].recorder.versions.storage.git.path }}" |
| 31 | + |
| 32 | + collection_api_basePath: "{{ ota_apps_config['@opentermsarchive/engine']['collection-api'].basePath is defined and ota_apps_config['@opentermsarchive/engine']['collection-api'].basePath }}" |
| 33 | + collection_api_port: "{{ ota_apps_config['@opentermsarchive/engine']['collection-api'].port is defined and ota_apps_config['@opentermsarchive/engine']['collection-api'].port }}" |
| 34 | + |
| 35 | + federation_api_basePath: "{{ ota_apps_config['@opentermsarchive/federation-api'].basePath is defined and ota_apps_config['@opentermsarchive/federation-api'].basePath }}" |
| 36 | + federation_api_port: "{{ ota_apps_config['@opentermsarchive/federation-api'].port is defined and ota_apps_config['@opentermsarchive/federation-api'].port }}" |
| 37 | + |
| 38 | + - name: Install infrastructure |
| 39 | + become: true |
| 40 | + tags: [infrastructure] |
| 41 | + block: |
| 42 | + - name: Install Node |
| 43 | + ansible.builtin.include_role: |
| 44 | + name: node |
| 45 | + |
| 46 | + - name: Install PM2 |
| 47 | + ansible.builtin.include_role: |
| 48 | + name: pm2/install |
| 49 | + |
| 50 | + - name: Install Chromium |
| 51 | + ansible.builtin.include_role: |
| 52 | + name: chromium |
| 53 | + when: chromium_required |
| 54 | + |
| 55 | + - name: Install Nginx |
| 56 | + ansible.builtin.include_role: |
| 57 | + name: nginx/install |
| 58 | + |
| 59 | + - name: Install Mongo |
| 60 | + ansible.builtin.include_role: |
| 61 | + name: mongo/install |
| 62 | + when: |
| 63 | + - mongo_required |
| 64 | + |
| 65 | + - name: Configure Mongo |
| 66 | + ansible.builtin.include_role: |
| 67 | + name: mongo/configure |
| 68 | + apply: |
| 69 | + become: true |
| 70 | + when: |
| 71 | + - mongo_required |
| 72 | + |
| 73 | + - name: Setup Git-based versions database |
| 74 | + ansible.builtin.include_role: |
| 75 | + name: ota/git-database |
| 76 | + vars: |
| 77 | + ota_git_database_repository: "{{ versions_repository }}" |
| 78 | + ota_git_database_directory: "{{ versions_path }}" |
| 79 | + ota_git_database_branch: main |
| 80 | + when: |
| 81 | + - versions_repository and versions_path |
| 82 | + |
| 83 | + - name: Setup Git-based snapshots database |
| 84 | + ansible.builtin.include_role: |
| 85 | + name: ota/git-database |
| 86 | + vars: |
| 87 | + ota_git_database_repository: "{{ snapshots_repository }}" |
| 88 | + ota_git_database_directory: "{{ snapshots_path }}" |
| 89 | + ota_git_database_branch: main |
| 90 | + when: |
| 91 | + - snapshots_repository and snapshots_path |
| 92 | + |
| 93 | + - name: Setup OTA applications |
| 94 | + ansible.builtin.include_role: |
| 95 | + name: ota/apps |
| 96 | + |
| 97 | + - name: Start OTA applications |
| 98 | + ansible.builtin.include_role: |
| 99 | + name: pm2/manage |
| 100 | + |
| 101 | + - name: Configure NGINX |
| 102 | + ansible.builtin.include_role: |
| 103 | + name: nginx/configure |
| 104 | + apply: |
| 105 | + become: true |
| 106 | + vars: |
| 107 | + ota_nginx_config_template: ./templates/nginx.conf.j2 |
| 108 | + ota_nginx_reverse_proxy_config_template: ./templates/nginx-reverse-proxy-conf.j2 |
0 commit comments