Skip to content
Snippets Groups Projects
php.yml 4.46 KiB
Newer Older
  • Learn to ignore specific revisions
  • jurgenhaas's avatar
    jurgenhaas committed
    ---
    # file: roles/php/tasks/php.yml
    
    
    - name: Apt Repository
    
    jurgenhaas's avatar
    jurgenhaas committed
      apt_repository:
    
        repo: '{{ item }}'
        state: present
        mode: 0644
    
    jurgenhaas's avatar
    jurgenhaas committed
      with_items: '{{ php_repositories }}'
    
    
    - name: Install required packages.
    
    jurgenhaas's avatar
    jurgenhaas committed
      apt:
    
        pkg: '{{ php_packages }}'
        state: present
        force: yes
    
        - Restart Apache
    
    - name: Hold em all
      shell: dpkg --get-selections | grep ^sed s/install/hold/g | sudo dpkg --set-selections
    
    jurgenhaas's avatar
    jurgenhaas committed
      when: php_hold_version
    
    
    - name: Install PECL packages
    
      shell: pecl install --soft imagick-3.3.0
    
      when: php_version_main|default(7) != 7
    
      ignore_errors: yes
    
    jurgenhaas's avatar
    jurgenhaas committed
    # NOTE: If oauth is already installed and we install a new PHP 7 version then this fails and we need --force as well
    
    - name: Install PECL packages
    
      shell: pecl install --soft --force oauth
    
      when: php_version_main|default(7) == 7
    
      ignore_errors: yes
    
    - name: Ensure Apache config directory
    
        dest: /etc/{{ php_base_dir }}/apache2
        state: directory
        owner: root
        group: root
        mode: 0755
    
    jurgenhaas's avatar
    jurgenhaas committed
    
    
    - name: Configuration file, php.ini
    
    jurgenhaas's avatar
    jurgenhaas committed
      template:
    
        src: etc-php5-apache2-php.ini
        dest: /etc/{{ php_base_dir }}/apache2/php.ini
        owner: root
        group: root
        mode: 0644
    
        - Restart Apache
    
    jurgenhaas's avatar
    jurgenhaas committed
    
    
    - name: Import php53
      import_tasks: php53.yml
    
      when: php_version|default('5.5') == '5.3'
    
    
    - name: Configuration file, fcgid.conf
    
        src: fcgid.conf
        dest: /etc/apache2/mods-available/fcgid.conf
        owner: root
        group: root
        mode: 0644
    
        - Restart Apache
    
    - name: Configuration files
    
    jurgenhaas's avatar
    jurgenhaas committed
      template:
    
        src: etc-php5-conf-d-{{ item }}.ini
        dest: /etc/{{ php_base_dir }}/{{ php_conf_dir }}/{{ item }}.ini
        owner: root
        group: root
        mode: 0644
    
        - opcache
    
    jurgenhaas's avatar
    jurgenhaas committed
      notify:
    
        - Restart Apache
    
    jurgenhaas's avatar
    jurgenhaas committed
    
    
    - name: Create extra directory for browscap
    
    jurgenhaas's avatar
    jurgenhaas committed
      file:
    
        dest: /etc/{{ php_base_dir }}/apache2/extra
        state: directory
        owner: root
        group: root
    
    jurgenhaas's avatar
    jurgenhaas committed
      when: php_browscap
    
    
    - name: browscap.ini
    
    jurgenhaas's avatar
    jurgenhaas committed
      copy:
    
        src: browscap.ini
        dest: /etc/{{ php_base_dir }}/apache2/extra/browscap.ini
        owner: root
        group: root
    
    jurgenhaas's avatar
    jurgenhaas committed
      when: php_browscap
    
        - Restart Apache
    
    jurgenhaas's avatar
    jurgenhaas committed
    
    
    - name: Create htdocs directory for apc status
    
    jurgenhaas's avatar
    jurgenhaas committed
      file:
    
        dest: /var/www/apc
        state: directory
        owner: www-data
        group: www-data
    
    jurgenhaas's avatar
    jurgenhaas committed
    
    
    - name: Copy APC status php script
    
    jurgenhaas's avatar
    jurgenhaas committed
      copy:
    
        src: apc.php
        dest: /var/www/apc
        owner: www-data
        group: www-data
    
    jurgenhaas's avatar
    jurgenhaas committed
    
    
    - name: Include oci version
      include_tasks: oci-{{ php_version|default('5.5') }}.yml
    
      when: repository is defined and php_needs_oci8
    
    jurgenhaas's avatar
    jurgenhaas committed
    - name: Include mcrypt
      include_tasks: mcrypt-7.2.yml
      when: php_version|default('5.5') == '7.2' and php_needs_mcrypt
    
    
    - name: Import msodbc
      import_tasks: msodbc.yml
    
    - name: Ensure ImageMagick config directory
    
        dest: '{{ php_imagick_config_dir }}'
        state: directory
        owner: root
        group: root
        mode: 0755
    
    - name: ImageMagick Policy File
    
        src: etc-imagemagick-policy.xml
        dest: '{{ php_imagick_config_dir }}/policy.xml'
        owner: root
        group: root
        mode: 0644
    
        - name: Apache FPM Socket Configuration
          template:
            src: etc-apache2-conf-available-php-fpm
            dest: /etc/apache2/{{ apache_conf_dir }}/php{{ php_version_main }}-fpm.conf
            owner: root
            group: root
            mode: 0644
          notify:
    
            - Restart Apache
    
    
        - name: Enable Apache PHP FPM Configuration
          command: a2enconf php{{ php_version_main }}-fpm
          args:
            creates: /etc/apache2/conf-enabled/php{{ php_version_main }}-fpm{{ apache_conf_ext }}
          notify:
    
            - Restart Apache
    
    
      when: php_fpm_socket
    
    
    - name: FPM Default Pool Configuration
    
    jurgenhaas's avatar
    jurgenhaas committed
      template:
    
        src: php_pool.conf
        dest: /etc/{{ php_base_dir }}/fpm/pool.d/www.conf
        owner: root
        group: root
        mode: 0644
    
      when: (php_version_main|default(7) == 7) and php_fpm
    
    jurgenhaas's avatar
    jurgenhaas committed
    
    
        - name: Set facts for PHP 7
          set_fact:
    
            phpLogRotatePrefix: '{{php_version|default("7.0")}}'
            phpLibPrefix: ''
    
          when: php_version_main|default(7) == 7
    
        - name: Set facts for PHP 5
          set_fact:
    
            phpLogRotatePrefix: '5'
            phpLibPrefix: '5'
    
          when: php_version_main|default(7) != 7
    
    
        - name: Install logrotate script
          template:
            src: etc-logrotate-php
            dest: /etc/logrotate.d/php{{ phpLogRotatePrefix }}-fpm
            owner: root
            group: root
            mode: 0644
    
    jurgenhaas's avatar
    jurgenhaas committed
      when: php_fpm
    
      tags:
        - logrotate
    
    
    - name: Explicitly set PHP version for CLI
      alternatives:
        name: php
        path: /usr/bin/php{{ php_version }}