infrastructure/playbooks/roles/phpvms/tasks/main.yml

170 lines
6.5 KiB
YAML

---
- name: Set common facts
ansible.builtin.include_tasks: "{{ tasks_dir }}/set-default-facts.yml"
- name: Deploy {{ service_name }}
vars:
svc: "{{ phpvms_svc }}"
env: "{{ phpvms_env }}"
compose: "{{ phpvms_compose }}"
block:
- name: Import prepare tasks for common service
ansible.builtin.include_tasks: "{{ tasks_dir }}/prepare-common-service.yml"
- name: Fetch resources from latest phpvms release
ansible.builtin.unarchive:
src: https://github.com/phpvms/phpvms/releases/download/{{ phpvms_version }}/phpvms-{{ phpvms_version }}.tar.gz
dest: "{{ service_path }}"
include:
- modules
- public
- storage
remote_src: true
owner: "{{ phpvms_uid }}"
group: "{{ phpvms_gid }}"
become: true
- name: Create resources_in directory
ansible.builtin.file:
path: "{{ (service_path, 'resources') | path_join }}"
state: directory
mode: "0755"
owner: "{{ phpvms_uid }}"
group: "{{ phpvms_gid }}"
become: true
- name: Template Caddyfile
ansible.builtin.template:
src: Caddyfile.j2
dest: "{{ (service_path, 'Caddyfile') | path_join }}"
mode: "0644"
notify: Restart service {{ service_name }}
- name: Import start tasks for common service
ansible.builtin.include_tasks: "{{ tasks_dir }}/start-common-service.yml"
# You must provide this file yourself.
- name: Load VMSArcas module
ansible.builtin.unarchive:
src: "{{ phpvms_acars_module_src }}"
remote_src: true
dest: "{{ (service_path, 'modules') | path_join }}"
owner: "{{ phpvms_uid }}"
group: "{{ phpvms_gid }}"
become: true
notify: Restart service {{ service_name }}
when: service_name == role_name # Only use on the "main" instance
- name: Get other modules from nextcloud share
ansible.builtin.uri:
url: "{{ phpvms_other_modules }}"
method: PROPFIND
return_content: true
status_code: [200, 207]
register: phpvms_other_modules_response
- name: Transform response into list
ansible.builtin.set_fact:
phpvms_other_modules_host: "{{ phpvms_other_modules | urlsplit('hostname') }}"
phpvms_other_modules_list: "{{ phpvms_other_modules_xml['d:multistatus']['d:response'] | map(attribute='d:href') }}"
delegate_to: localhost
vars:
phpvms_other_modules_xml: "{{ phpvms_other_modules_response.content | ansible.utils.from_xml }}"
- name: Load other modules
ansible.builtin.unarchive:
src: "https://{{ phpvms_other_modules_host }}{{ item }}"
dest: "{{ (service_path, 'modules') | path_join }}"
owner: "{{ phpvms_uid }}"
group: "{{ phpvms_gid }}"
remote_src: true
become: true
notify: Restart service {{ service_name }}
loop: "{{ phpvms_other_modules_list }}"
when: "item.endswith('.zip')"
- name: Load DisposableBasic
ansible.builtin.unarchive:
src: https://github.com/FatihKoz/DisposableBasic/releases/download/v3.7.4/DisposableBasic.zip
remote_src: true
dest: "{{ (service_path, 'modules') | path_join }}"
exclude:
- DisposableBasic/Resources/views/web/blank.blade.php # will be created by user
owner: "{{ phpvms_uid }}"
group: "{{ phpvms_gid }}"
become: true
notify: Restart service {{ service_name }}
- name: Load DisposableSpecial
ansible.builtin.unarchive:
src: https://github.com/FatihKoz/DisposableSpecial/releases/download/v3.7.8/DisposableSpecial.zip
remote_src: true
dest: "{{ (service_path, 'modules') | path_join }}"
owner: "{{ phpvms_uid }}"
group: "{{ phpvms_gid }}"
become: true
notify: Restart service {{ service_name }}
- name: Load SPTransfer
ansible.builtin.unarchive:
src: https://github.com/PaintSplasher/phpvms7_SPTransfer/archive/refs/tags/1.8.tar.gz
remote_src: true
dest: "{{ (service_path, 'modules') | path_join }}"
exclude:
- Resources/views/airline.blade.php # will be overwritten by SPTheme
- Resources/views/hub.blade.php # will be overwritten by SPTheme
extra_opts:
- --transform
- s/phpvms7_SPTransfer-1.8/SPTransfer/
owner: "{{ phpvms_uid }}"
group: "{{ phpvms_gid }}"
become: true
notify: Restart service {{ service_name }}
# You must provide this file yourself.
- name: Load SPTheme
ansible.builtin.unarchive:
src: "{{ phpvms_sptheme_src }}"
remote_src: true
dest: "{{ service_path }}"
exclude:
- README.md
- public/SPTheme/images/banner/ # provided by custom assets
- public/SPTheme/images/favicon.png # provided by custom assets
- public/SPTheme/images/logo.png # provided by custom assets
- public/SPTheme/css/colors.css # will be generated
- resources/lang/ # will be overwritten by SPTheme DSPack
- resources/views/layouts/SPTheme/config.json # will be created by user
- resources/views/layouts/SPTheme/dashboard/index.blade.php # will be overwritten by SPTheme DSPack
- resources/views/layouts/SPTheme/footer.blade.php # will be overwritten by SPTheme DSPack
- resources/views/layouts/SPTheme/nav.blade.php # will be overwritten by SPTheme DSPack
- resources/views/layouts/SPTheme/profile/index.blade.php # will be overwritten by SPTheme DSPack
- resources/views/layouts/SPTheme/sidebar.blade.php # will be overwritten by SPTheme DSPack
owner: "{{ phpvms_uid }}"
group: "{{ phpvms_gid }}"
become: true
notify: Restart service {{ service_name }}
# You must provide this file yourself.
- name: Load SPTheme DSPack
ansible.builtin.unarchive:
src: "{{ phpvms_sptheme_dspack_src }}"
remote_src: true
dest: "{{ service_path }}"
exclude:
- README.md
- public/SPTheme/images/banner/ # provided by custom assets
owner: "{{ phpvms_uid }}"
group: "{{ phpvms_gid }}"
become: true
notify: Restart service {{ service_name }}
- name: Load custom assets
ansible.builtin.unarchive:
src: "{{ phpvms_assets_url | mandatory }}"
remote_src: true
dest: "{{ service_path }}"
owner: "{{ phpvms_uid }}"
group: "{{ phpvms_gid }}"
become: true
notify: Restart service {{ service_name }}