--- - hosts: all vars: vhost: 'test.local' php_extra_packages: - '{{ php_apt_prefix }}recode' php_install_xdebug: true pre_tasks: - name: APT | Install packages apt: pkg={{ item }} update_cache=yes cache_valid_time=3600 with_items: ['apt-transport-https', 'curl', 'lsb-release', 'ca-certificates'] - block: - name: APT | Install DotDeb key apt_key: url='http://www.dotdeb.org/dotdeb.gpg' state=present - name: APT | Add Dotdeb repository for Jessie + PHP7 apt_repository: repo='deb http://packages.dotdeb.org jessie all' state=present when: > ansible_distribution_major_version | version_compare(8, 'eq') and php_version | version_compare('7.0', 'eq') - block: - name: APT | Install Sury key apt_key: url='https://packages.sury.org/php/apt.gpg' state=present - name: APT | Add Dotdeb repository for Jessie + PHP7 apt_repository: repo='deb https://packages.sury.org/php/ jessie main' state=present when: > ansible_distribution_major_version | version_compare(8, 'eq') and php_version | version_compare('7.1', 'eq') - name: APT | Install nginx apt: pkg=nginx state=present update_cache=yes cache_valid_time=3600 - name: SHELL | Get nginx version shell: nginx -V 2>&1 | awk -F '/' '/nginx version/ { print $2 }' register: nginx_version changed_when: false - set_fact: nginx_include="fastcgi_params" when: nginx_version.stdout | version_compare('1.6', '<', true) - set_fact: nginx_include="fastcgi.conf" when: nginx_version.stdout | version_compare('1.6', '>=', true) tasks: - name: COPY | Vhost copy: > dest=/etc/nginx/sites-enabled/{{ vhost }} content='server { server_name {{ vhost }}; root /var/www; location ~ \.php$ { include {{ nginx_include }}; fastcgi_pass unix:{{ php_default_fpm_sock }}; } }' notify: reload nginx handlers: - name: reload nginx service: name=nginx state=reloaded roles: - ../../ post_tasks: - name: SHELL | Test php-cli shell: php -i | grep '^PHP Version' | head -n 1 changed_when: false register: p failed_when: p.stdout == '' - name: FILE | Create /var/www file: dest=/var/www state=directory - name: COPY | Add phpinfo copy: dest=/var/www/phpinfo.php content=' /dev/null | grep h1 | grep -o 'PHP Version [57].*<' | sed -r 's/