77 lines
2.4 KiB
YAML
77 lines
2.4 KiB
YAML
---
|
|
|
|
- name: Verify
|
|
hosts: all
|
|
gather_facts: true
|
|
vars:
|
|
nginx_root: "/srv/www"
|
|
tasks:
|
|
- name: SHELL | Test php-cli
|
|
ansible.builtin.shell: set -o pipefail && php -i | grep '^PHP Version => {{ ansible_local.hanxhx_php.php_version }}' | head -n 1
|
|
changed_when: false
|
|
register: p
|
|
failed_when: p.stdout == ''
|
|
args:
|
|
executable: /bin/bash
|
|
|
|
- name: FILE | Create /var/www
|
|
ansible.builtin.file:
|
|
dest: /var/www
|
|
state: directory
|
|
owner: root
|
|
group: root
|
|
mode: 0755
|
|
|
|
- name: COPY | Add phpinfo
|
|
ansible.builtin.copy:
|
|
dest: /var/www/phpinfo.php
|
|
content: '<?php phpinfo();'
|
|
owner: root
|
|
group: root
|
|
mode: 0644
|
|
|
|
- name: COPY | Add ini test file
|
|
ansible.builtin.copy:
|
|
dest: /var/www/ini.php
|
|
content: '<?php echo ini_get("memory_limit") . "\n";'
|
|
owner: root
|
|
group: root
|
|
mode: 0644
|
|
|
|
- name: SHELL | Check vhost
|
|
ansible.builtin.shell: "set -o pipefail && curl -v -H 'Host: {{ vhost }}' http://127.0.0.1/phpinfo.php 2> /dev/null | grep h1 | grep -o 'PHP Version {{ ansible_local.hanxhx_php.php_version }}' | sed -r 's/<//g'"
|
|
args:
|
|
executable: /bin/bash
|
|
changed_when: false
|
|
register: c
|
|
failed_when: c.stdout == ''
|
|
|
|
- name: SHELL | Check custom php value # noqa: command-instead-of-module
|
|
ansible.builtin.shell: "curl -H 'Host: {{ vhost }}' http://127.0.0.1/ini.php 2> /dev/null"
|
|
changed_when: false
|
|
register: c
|
|
failed_when: 'php_fpm_poold.1.php_admin_value.memory_limit not in c.stdout'
|
|
|
|
- name: URI | Check ping
|
|
ansible.builtin.uri:
|
|
url: "http://localhost{{ php_fpm_poold.0.ping_path }}"
|
|
when: php_fpm_poold.0.ping_path is defined
|
|
|
|
- name: URI | Check status
|
|
ansible.builtin.uri:
|
|
url: "http://localhost{{ php_fpm_poold.0.status_path }}"
|
|
when: php_fpm_poold.0.status_path is defined
|
|
|
|
- name: SHELL | Check if we installed multiple PHP versions
|
|
ansible.builtin.shell: set -o pipefail && (dpkg -l | grep 'php[[:digit:]].*common' | wc -l)
|
|
args:
|
|
executable: /bin/bash
|
|
failed_when: false
|
|
changed_when: false
|
|
register: check_multiple_php
|
|
|
|
- name: FAIL | If we have multiple PHP version
|
|
ansible.builtin.fail:
|
|
msg: "Multiple PHP versions detected"
|
|
when: check_multiple_php.stdout != '1'
|