ansible-php/molecule/_shared/prepare.yml

82 lines
2.3 KiB
YAML
Raw Normal View History

---
- name: Prepare
hosts: all
gather_facts: true
vars_files:
- vars/misc.yml
handlers:
- name: Reload nginx
ansible.builtin.service:
name: nginx
state: reloaded
tasks:
- name: INCLUDE_TASKS | Pre tasks related to OS
ansible.builtin.include_tasks: "../../tests/includes/pre_{{ ansible_os_family }}.yml"
- name: USER | Create PHP user
ansible.builtin.user:
name: 'foo'
system: true
create_home: false
shell: '/usr/sbin/nologin'
- name: COMMAND | Fix nginx config
ansible.builtin.command: "cp {{ __nginx_conf | dirname }}/fastcgi_params {{ __nginx_conf | dirname }}/fastcgi.conf"
args:
creates: "{{ __nginx_conf | dirname }}/fastcgi.conf"
notify: Reload nginx
- name: LINEINFILE | Fix nginx config (second step)
ansible.builtin.lineinfile:
regexp: '^fastcgi_param\s+SCRIPT_FILENAME'
line: "fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;"
dest: "{{ __nginx_conf | dirname }}/fastcgi.conf"
notify: Reload nginx
- name: SERVICE | Ensure nginx is started
ansible.builtin.service:
name: nginx
state: started
when: ansible_virtualization_type != 'docker'
- name: Start nginx if testing with Docker
when: ansible_virtualization_type == 'docker'
block:
- name: COMMAND | Docker nginx status
ansible.builtin.command: service nginx status
changed_when: false
failed_when: false
register: ngs
- name: COMMAND | Docker start nginx
ansible.builtin.command: service nginx start
when: ngs.stdout.find('nginx is not running') != -1
- 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