--- # - name: Add Sury PHP GPG apt key # apt_key: # url: https://packages.sury.org/php/apt.gpg # keyring: /usr/share/keyrings/deb.sury.org-php.gpg # state: present - name: Add Sury PHP Repository command: add-apt-repository -y ppa:ondrej/php args: creates: "/etc/apt/sources.list.d/ondrej-ubuntu-php-{{ ansible_distribution_release }}.sources" when: php_version is defined # add repo when version is specified, otherwise use default repo - name: Uninstall old PHP version apt: name: "php{{ php_old_version }}*" state: absent purge: true when: php_old_version is defined # uninstall when old version is specified # - name: Print php_modules list # debug: # msg: "{{ ['php' + php_version] | product(php_modules) | map('join', '-') | list }}" - name: "Install custom PHP modules {{ php_modules }}" apt: name: "{{ ['php' + php_version] | product(php_modules) | map('join', '-') | list }}" state: latest update_cache: true cache_valid_time: 3600 - name: Copy Nginx PHP-Handler template: dest: /etc/nginx/conf.d/php-handler.conf src: php-handler.conf.j2 mode: "0644" when: '"fpm" in php_modules' notify: Reload nginx