Skip to content
Snippets Groups Projects
php.yml 3.7 KiB
Newer Older
  • Learn to ignore specific revisions
  • jurgenhaas's avatar
    jurgenhaas committed
    ---
    # file: roles/php/tasks/php.yml
    
    
    jurgenhaas's avatar
    jurgenhaas committed
    - name: "PHP | Apt Repository"
      apt_repository:
        repo='{{ item }}'
        state='present'
    
    jurgenhaas's avatar
    jurgenhaas committed
      with_items: '{{ php_repositories }}'
    
    
    jurgenhaas's avatar
    jurgenhaas committed
    - name: "PHP | Install required packages."
      apt:
        pkg={{ item }}
        state=installed
    
    jurgenhaas's avatar
    jurgenhaas committed
        force=yes
    
    jurgenhaas's avatar
    jurgenhaas committed
      with_items: '{{ php_packages }}'
    
        - "Apache | Restart Apache"
    
    
    jurgenhaas's avatar
    jurgenhaas committed
    - name: "PHP | Hold em all"
      shell: dpkg --get-selections | grep ^php | sed s/install/hold/g | sudo dpkg --set-selections
      when: php_hold_version
    
    - name: "PHP | Install PECL packages"
    
      shell: 'pecl install --soft imagick-3.3.0'
    
    jurgenhaas's avatar
    jurgenhaas committed
      when: php_version|default('5.5') != '7'
    
      ignore_errors: true
    
    - name: "PHP | Install PECL packages"
    
      shell: 'pecl install --soft oauth'
    
    jurgenhaas's avatar
    jurgenhaas committed
      when: php_version|default('5.5') == '7'
    
      ignore_errors: true
    
    - name: "PHP | Ensure Apache config directory"
      file:
        dest=/etc/{{ php_base_dir }}/apache2
        state=directory
        owner=root
        group=root
        mode=0755
    
    jurgenhaas's avatar
    jurgenhaas committed
    
    - name: "PHP | Configuration file, php.ini"
      template:
        src=etc-php5-apache2-php.ini
    
        dest=/etc/{{ php_base_dir }}/apache2/php.ini
    
    jurgenhaas's avatar
    jurgenhaas committed
        owner=root
        group=root
        mode=0644
    
        - "Apache | Restart Apache"
    
    jurgenhaas's avatar
    jurgenhaas committed
    
    
    - include: php53.yml
      when: php_version|default('5.5') == '5.3'
    
    
    - name: "PHP | Configuration file, fcgid.conf"
      template:
        src=fcgid.conf
        dest=/etc/apache2/mods-available/fcgid.conf
        owner=root
        group=root
        mode=0644
      notify:
    
        - "Apache | Restart Apache"
    
    jurgenhaas's avatar
    jurgenhaas committed
    - name: "PHP | Cache configuration file, opcache.ini"
      template:
        src=etc-php5-conf-d-opcache.ini
    
        dest=/etc/{{ php_base_dir }}/{{ php_conf_dir }}/opcache.ini
    
    jurgenhaas's avatar
    jurgenhaas committed
        owner=root
        group=root
        mode=0644
      notify:
    
        - "Apache | Restart Apache"
    
    jurgenhaas's avatar
    jurgenhaas committed
    
    
    jurgenhaas's avatar
    jurgenhaas committed
    - name: "PHP | Create extra directory for browscap"
      file:
    
        dest=/etc/{{ php_base_dir }}/apache2/extra
    
    jurgenhaas's avatar
    jurgenhaas committed
        state=directory
        owner=root
        group=root
      when: php_browscap
    
    - name: "PHP | browscap.ini"
      copy:
        src=browscap.ini
    
        dest=/etc/{{ php_base_dir }}/apache2/extra/browscap.ini
    
    jurgenhaas's avatar
    jurgenhaas committed
        owner=root
        group=root
    
    jurgenhaas's avatar
    jurgenhaas committed
      when: php_browscap
    
        - "Apache | Restart Apache"
    
    jurgenhaas's avatar
    jurgenhaas committed
    
    - name: "PHP | Enable PHP modules"
      shell: php5enmod {{ item }}
      with_items:
        - mcrypt
        - imap
    
    jurgenhaas's avatar
    jurgenhaas committed
        - imagick
    
      when: php_version|default('5.5') != '7' and php_conf_dir == 'mods-available'
    
        - "Apache | Restart Apache"
    
    jurgenhaas's avatar
    jurgenhaas committed
    
    - name: "PHP | Create htdocs directory for apc status"
      file:
        dest=/var/www/apc
        state=directory
        owner=www-data
        group=www-data
    
    - name: "PHP | Copy APC status php script"
      copy:
        src=apc.php
        dest=/var/www/apc
        owner=www-data
        group=www-data
    
    - name: "PHP | Check OCI Requirement"
      shell: ls /usr/lib/php5/20090626/pdo_oci.so
      register: oci_available
      when: php_needs_oci8
      ignore_errors: yes
      changed_when: oci_available.stdout != '/usr/lib/php5/20090626/pdo_oci.so'
    
        - "Apache | Restart Apache"
    
    jurgenhaas's avatar
    jurgenhaas committed
    
    - include: oci.yml
      when: repository is defined and php_needs_oci8 and oci_available.stdout != '/usr/lib/php5/20090626/pdo_oci.so'
    
    
    - name: "PHP | Ensure ImageMagick config directory"
      file:
        dest=/etc/ImageMagick
        state=directory
        owner=root
        group=root
        mode=0755
    
    - name: "PHP | ImageMagick Policy File"
      template:
        src=etc-imagemagick-policy.xml
        dest=/etc/ImageMagick/policy.xml
        owner=root
        group=root
        mode=0644
    
    
    - block:
      - set_fact:
          phpLogRotatePrefix='7.0'
          phpLibPrefix=''
        when: php_version|default('5.5') == '7'
      - set_fact:
          phpLogRotatePrefix='5'
          phpLibPrefix='5'
        when: php_version|default('5.5') != '7'
    
      - name: "Install logrotate script"
        template:
          src=etc-logrotate-php
          dest=/etc/logrotate.d/php{{ phpLogRotatePrefix }}-fpm
          owner=root
          group=root
          mode=644
      tags: 'logrotate'