Skip to content
Snippets Groups Projects
install.yml 3.36 KiB
Newer Older
  • Learn to ignore specific revisions
  • jurgenhaas's avatar
    jurgenhaas committed
    ---
    # file: roles/matomo/tasks/install.yml
    
    - block:
    
        - name: Set facts without jail
          set_fact:
    
            webRoot: /var/www/matomo/{{ matomo.id }}
            apacheUser: www-data
            apacheLogDir: /var/log/apache2
          when: matomo.jail is not defined
    
        - name: Set facts with jail
          set_fact:
    
            webRoot: '{{ jailroot }}/{{ matomo.id }}/var/www/matomo'
            apacheUser: '{{ matomo.id }}'
            apacheLogDir: '{{ jailroot }}/{{ matomo.id }}/var/log/apache2'
          when: matomo.jail is defined
    
      tags:
        - always
    
    jurgenhaas's avatar
    jurgenhaas committed
    
    
    - name: Configure Apache
    
    jurgenhaas's avatar
    jurgenhaas committed
      include_tasks: apache.yml
    
      tags:
        - ApacheConfig
    
    jurgenhaas's avatar
    jurgenhaas committed
    
    
    - name: Remove existing components
    
    jurgenhaas's avatar
    jurgenhaas committed
      file:
        path: '{{ item }}'
    
        state: absent
    
    jurgenhaas's avatar
    jurgenhaas committed
      with_items:
    
    jurgenhaas's avatar
    jurgenhaas committed
      when: matomo_force_reset
    
      tags:
        - always
    
    jurgenhaas's avatar
    jurgenhaas committed
    
    
    - name: Ensure Root Directories
    
    jurgenhaas's avatar
    jurgenhaas committed
      file:
    
        path: '{{ item }}'
        state: directory
        owner: '{{ apacheUser }}'
        group: '{{ apacheUser }}'
        mode: 0775
    
    jurgenhaas's avatar
    jurgenhaas committed
      with_items:
    
      tags:
        - always
    
    jurgenhaas's avatar
    jurgenhaas committed
    
    
    - name: File Modes and Ownership
    
    jurgenhaas's avatar
    jurgenhaas committed
      file:
    
        path: '{{ webRoot }}'
        owner: '{{ apacheUser }}'
        group: '{{ apacheUser }}'
        mode: g+w
        recurse: yes
        follow: no
    
      tags:
        - deploy
    
    jurgenhaas's avatar
    jurgenhaas committed
    
    
    - name: Clone Git Repository
    
    jurgenhaas's avatar
    jurgenhaas committed
      git:
        accept_hostkey: yes
    
        repo: 'git@github.com:matomo-org/matomo.git'
    
    jurgenhaas's avatar
    jurgenhaas committed
        dest: '{{ webRoot }}'
        track_submodules: yes
        force: yes
        version: '{{ matomo_version }}'
    
    jurgenhaas's avatar
    jurgenhaas committed
        depth: 1
    
      become: no
    
    jurgenhaas's avatar
    jurgenhaas committed
      environment:
    
        GIT_LFS_SKIP_SMUDGE: 1
      tags:
        - deploy
    
    jurgenhaas's avatar
    jurgenhaas committed
    
    
    - name: Download plugins
      unarchive:
        src: '{{ item }}'
        dest: '{{ webRoot }}/plugins'
        remote_src: yes
      with_items:
    
        - https://plugins.matomo.org/api/2.0/plugins/LoginOIDC/download/0.1.4
    
    - name: Configuration file
    
    jurgenhaas's avatar
    jurgenhaas committed
      template:
    
        src: config.ini.php
        dest: '{{ webRoot }}/config/config.ini.php'
        owner: '{{ apacheUser }}'
        group: '{{ apacheUser }}'
        mode: 0664
    
      tags:
        - deploy
    
    jurgenhaas's avatar
    jurgenhaas committed
    
    
    - name: Composer
    
    jurgenhaas's avatar
    jurgenhaas committed
      composer:
    
        command: update
        working_dir: '{{ webRoot }}'
        no_dev: yes
        optimize_autoloader: yes
        prefer_dist: yes
      ignore_errors: yes
    
      tags:
        - deploy
    
    - name: Ensure Working Directories
    
    jurgenhaas's avatar
    jurgenhaas committed
      file:
    
        path: '{{ item }}'
        state: directory
        owner: '{{ apacheUser }}'
        group: '{{ apacheUser }}'
        mode: 0775
    
    jurgenhaas's avatar
    jurgenhaas committed
      with_items:
    
      tags:
        - always
    
    - name: Enable Plugins
      command: '{{ webRoot }}/console plugin:activate {{ item }}'
      become_user: '{{ apacheUser }}'
      ignore_errors: yes
      with_items:
        - LoginOIDC
      tags:
        - deploy
    
    
    - name: File Modes and Ownership
    
    jurgenhaas's avatar
    jurgenhaas committed
      file:
    
        path: '{{ webRoot }}'
        owner: '{{ apacheUser }}'
        group: '{{ apacheUser }}'
        mode: a-w
        recurse: yes
        follow: no
    
      tags:
        - deploy
    
    - name: File Modes for .git Directory
    
    jurgenhaas's avatar
    jurgenhaas committed
      file:
    
        path: '{{ webRoot }}/.git'
        mode: og+w
        recurse: yes
        follow: no
    
      tags:
        - deploy
    
    - name: File Modes for tmp
    
    jurgenhaas's avatar
    jurgenhaas committed
      file:
    
        path: '{{ webRoot }}/tmp'
        mode: ug+w
        recurse: yes
        follow: no
    
      tags:
        - deploy
    
    - name: Ensure Database
    
    jurgenhaas's avatar
    jurgenhaas committed
      mysql_db:
    
        name: matomo_{{ matomo.id }}
        login_user: root
        login_password: '{{ mysql_root_password|default("root") }}'
        login_host: 127.0.0.1
    
        login_port: '{{ matomo.db_port|default("3306") }}'
    
    - name: Run Upgrade
    
    jurgenhaas's avatar
    jurgenhaas committed
      command: '{{ webRoot }}/console core:update --yes --no-interaction'
      become_user: '{{ apacheUser }}'
    
      ignore_errors: yes
    
      tags:
        - deploy