Created
April 4, 2024 20:24
-
-
Save p4cpenhale/dc7b5693e56d1c7f3800e97e6d16f772 to your computer and use it in GitHub Desktop.
How to Install and Configure Ansible to Deploy a PHP Application -- Zend by Perforce
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
- name: configure zendphp repo credentials | |
template: | |
src: templates/zendphp.conf.j2 | |
dest: /etc/apt/auth.conf.d/zendphp.conf | |
owner: root | |
group: root | |
mode: '0644' | |
- name: Configure zend repo | |
block: | |
- name: zend |no apt key | |
ansible.builtin.get_url: | |
url: https://repos.zend.com/zend.key | |
dest: /etc/apt/keyrings/zend.asc | |
- name: zend |apt source | |
ansible.builtin.apt_repository: | |
repo: "deb [signed-by=/etc/apt/keyrings/zend.asc] https://repos.zend.com/zendphp/deb_{{ ansible_distribution | lower }}{{ ansible_distribution_version | regex_replace('\\.', '') }}/ zendphp non-free" | |
state: present | |
update_cache: true | |
- name: Install zendphp | |
ansible.builtin.apt: | |
pkg: | |
- "php{{ php_version }}-zend" | |
- "php{{ php_version }}-zend-fpm" | |
- "php{{ php_version }}-zend-dev" | |
- "php{{ php_version }}-zend-xml" | |
register: zend_install | |
- name: Install extensions for project | |
ansible.builtin.apt: | |
pkg: | |
- "php{{ php_version }}-zend-{{ item }}" | |
state: present | |
with_items: "{{ extensions }}" | |
- name: configure nginx for php-fpm | |
template: | |
src: templates/nginx.conf.j2 | |
dest: /etc/nginx/sites-available/default | |
owner: root | |
group: root | |
mode: '0644' | |
- name: upload website | |
ansible.builtin.copy: | |
src: zend-se-zendhq-demo/worker/ | |
dest: /var/www/worker/ | |
owner: www-data | |
group: www-data | |
- name: start php fpm if not started | |
ansible.builtin.service: | |
name: "php{{ php_version }}-zend-fpm" | |
state: started | |
- name: start nginx if not started | |
ansible.builtin.service: | |
name: nginx | |
state: started | |
- name: restart php fpm if zend install has changed | |
ansible.builtin.service: | |
name: "php{{ php_version }}-zend-fpm" | |
state: restarted | |
when: zend_install is changed | |
register: fpm_restart | |
- name: restart nginx if fpm has been restarted | |
ansible.builtin.service: | |
name: nginx | |
state: restarted | |
when: fpm_restart is changed | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Source: https://www.zend.com/blog/ansible-php-application