Skip to content
main.yml 4.75 KiB
Newer Older
jerome's avatar
jerome committed
---

  - import_role:
jerome's avatar
jerome committed
      name: _app_log_inventory
    vars:
      log_type: "server"
      server_name: "php-fpm"

jerome's avatar
jerome committed
  - name: "set fact php_ini_file"
    set_fact:
      php_ini_file: "{{ php_ini_file_apache2 }}"
    when: rev_proxy == "apache2"
    tags:
      - setpath
jerome's avatar
jerome committed

  - name: "set fact php_ini_file"
    set_fact:
      php_ini_file: "{{ php_ini_file_nginx }}"
    when: rev_proxy == "nginx"
    tags:
      - setpath
jerome's avatar
jerome committed

Jean-Yves's avatar
Jean-Yves committed
  - name: "PHP 7 repository for Ubuntu {{ ansible_distribution_release }}"
jerome's avatar
jerome committed
    apt_repository:
      repo: "ppa:ondrej/php"
      state: present
Jean-Yves's avatar
Jean-Yves committed
    when: ansible_distribution == 'Ubuntu'
    tags:
      - php

  - name:  "PHP 7 repository for Debian {{ ansible_distribution_release }}"
    block:
    - name: GPG key
      apt_key:
Jean-Yves's avatar
Jean-Yves committed
        url: https://packages.sury.org/php/apt.gpg
Jean-Yves's avatar
Jean-Yves committed

    - name: Add APT repository
      apt_repository:
        repo: deb [arch=amd64] https://packages.sury.org/php/ {{ ansible_distribution_release }} main
    when: ansible_distribution == 'Debian'
    tags:
      - php
jerome's avatar
jerome committed

jerome's avatar
jerome committed
  - name: "PHP packages"
jerome's avatar
jerome committed
    apt:
      name: "{{ php_package }}"
      state: present
jerome's avatar
jerome committed
    loop: "{{ php_packages }}"
jerome's avatar
jerome committed
    loop_control:
      loop_var: php_package
Jean-Yves's avatar
Jean-Yves committed
    tags:
      - php
jerome's avatar
jerome committed

jerome's avatar
jerome committed
  - name: "PHP package for apache"
jerome's avatar
jerome committed
    apt:
      name: "{{ php_apache_package }}"
      state: present
jerome's avatar
jerome committed
    loop: "{{ php_apache_packages }}"
jerome's avatar
jerome committed
    loop_control:
      loop_var: php_apache_package
    notify: restart apache2 php7_fpm
jerome's avatar
jerome committed
    when: rev_proxy == "apache2"

# TODO : review
#  - name: "a2enconf php{{ php_version }}"
#    command: "a2enconf php{{ php_version }}"
#    register: __a2enconf_rc
#    changed_when: '"service apache2 reload" in __a2enconf_rc.stdout'
#    notify: restart apache2

jerome's avatar
jerome committed
  - name: "template for monitoring php{{ php_version }}-fpm"
    template:
      src: "php7-fpm.monit.j2"
      dest: "/etc/monit/conf.d/php{{ php_version }}.conf"
    notify: reload monit php7_fpm
jerome's avatar
jerome committed


  - import_tasks: composer.yml

jerome's avatar
jerome committed
  - name: "redis server"
    apt: name="redis-server" state=present

  - name: "start redis"
    service: name=redis state=started

jerome's avatar
jerome committed
  - name: "cron stop redis.service for backup"
    cron:
      name: "stop redis"
      hour: "{{ backup_web_stop_hour }}"
      minute: "{{ backup_web_stop_minute }}"
      job: "/bin/systemctl stop redis.service"

  - name: "cron start redis.service for backup"
    cron:
      name: "start redis"
      hour: "{{ backup_web_start_hour }}"
      minute: "{{ backup_web_start_minute }}"
      job: "/bin/systemctl start redis.service"

  - name: "template for monitoring redis"
    template:
      src: "redis.monit.j2"
      dest: "/etc/monit/conf.d/redis.conf"
    notify: reload monit php7_fpm
jerome's avatar
jerome committed

  - import_tasks: configure_fpm.yml
jerome's avatar
jerome committed

jerome's avatar
jerome committed
  - name: "OP Cache for PHP{{ php_version }}"
    lineinfile:
      line: "opcache.enable=1"
      insertafter: ";opcache.enable="
      path: "{{ php_ini_file }}"
      state: present
      backup: yes
    notify: reload php-fpm php7_fpm
jerome's avatar
jerome committed

  - name: "OP Cache for PHP{{ php_version }}"
    lineinfile:
      line: "opcache.enable_cli=1"
      insertafter: ";opcache.enable_cli="
      path: "{{ php_ini_file }}"
      state: present
    notify: reload php-fpm php7_fpm
jerome's avatar
jerome committed

  - name: "OP Cache for PHP{{ php_version }}"
    lineinfile:
      line: "opcache.memory_consumption=128"
      insertafter: ";opcache.memory_consumption"
      path: "{{ php_ini_file }}"
      state: present
    notify: reload php-fpm php7_fpm
jerome's avatar
jerome committed

### NGINX

jerome's avatar
jerome committed
  - name: "env[HOSTNAME] for PHP{{ php_version }}"
jerome's avatar
jerome committed
    lineinfile:
      line: "env[HOSTNAME] = $HOSTNAME"
      insertafter: ";env\\[HOSTNAME\\] = \\$HOSTNAME"
      path: "{{ php_www_conf_file }}"
      state: present
      backup: yes
jerome's avatar
jerome committed
    when: rev_proxy == "nginx"
    notify: reload php-fpm php7_fpm
jerome's avatar
jerome committed

  - name: "env[PATH] for PHP{{ php_version }}"
    lineinfile:
      line: "env[PATH] = /usr/local/bin:/usr/bin:/bin"
      insertafter: ";env\\[PATH\\] = /usr/local/bin:/usr/bin:/bin"
      path: "{{ php_www_conf_file }}"
      state: present
jerome's avatar
jerome committed
    when: rev_proxy == "nginx"
    notify: reload php-fpm php7_fpm
jerome's avatar
jerome committed

jerome's avatar
jerome committed
  - name: "env[TMP] for PHP{{ php_version }}"
jerome's avatar
jerome committed
    lineinfile:
      line: "env[TMP] = /tmp"
      insertafter: ";env\\[TMP\\] = /tmp"
      path: "{{ php_www_conf_file }}"
      state: present
jerome's avatar
jerome committed
    when: rev_proxy == "nginx"
    notify: reload php-fpm php7_fpm
jerome's avatar
jerome committed

  - name: "env[TMPDIR] for PHP{{ php_version }}"
    lineinfile:
      line: "env[TMPDIR] = /tmp"
      insertafter: ";env\\[TMPDIR\\] = /tmp"
      path: "{{ php_www_conf_file }}"
      state: present
jerome's avatar
jerome committed
    when: rev_proxy == "nginx"
    notify: reload php-fpm php7_fpm
jerome's avatar
jerome committed

  - name: "env[TEMP] for PHP{{ php_version }}"
    lineinfile:
      line: "env[TEMP] = /tmp"
      insertafter: ";env\\[TEMP\\] = /tmp"
      path: "{{ php_www_conf_file }}"
      state: present
jerome's avatar
jerome committed
    when: rev_proxy == "nginx"
    notify: reload php-fpm php7_fpm