Help/Ansible/install_php-fpm_zabbix.yaml
2025-05-29 21:55:04 +02:00

92 lines
2.5 KiB
YAML
Executable File

- name: PHP
hosts: all
become: true
gather_facts: yes
tasks:
- name: Install PHP
apt:
name: php-fpm
state: present
- name: Copy config file status
copy:
src: status_nginx_php
dest: /etc/nginx/sites-available/status
owner: root
group: root
mode: 0644
- name: Copy config file index.php
copy:
src: index.php
dest: /var/www/html/
owner: www-data
group: www-data
mode: 0644
- name: Copy config file default
copy:
src: default_php_nginx
dest: /etc/nginx/sites-available/default
owner: root
group: root
mode: 0644
- name: Copy php enabled status
copy:
src: php_enabled_status
dest: /tmp/php_enabled_status
owner: root
group: root
mode: 0755
- name: Run php enabled status
shell:
"/tmp/php_enabled_status"
- name: Create a new host or update an existing host's info
local_action:
module: zabbix_host
server_url: https://zabbix.czech-tv.cz
login_user: ansict
login_password: Sojka123456
host_name: '{{inventory_hostname}}'
host_groups:
- Linux servers
link_templates:
- PHP-FPM by Zabbix agent
- Linux by Zabbix agent
- SSH Service
- Nginx by Zabbix agent
interfaces:
- type: 1
main: 1
useip: 1
ip: "{{hostvars[inventory_hostname]['ansible_default_ipv4']['address']}}"
dns: "{{inventory_hostname}}"
port: 10050
- name: Add value for PHP
local_action:
module: zabbix_hostmacro
server_url: https://zabbix.czech-tv.cz
login_user: ansict
login_password: Sojka123456
host_name: "{{inventory_hostname}}"
macro_name: "{$PHP_FPM.PORT}"
macro_value: 8080
state: present
- name: Add value for PHP
local_action:
module: zabbix_hostmacro
server_url: https://zabbix.czech-tv.cz
login_user: ansict
login_password: Sojka123456
host_name: "{{inventory_hostname}}"
macro_name: "{$PHP_FPM.PROCESS_NAME}"
macro_value: php-fpm7.4
state: present
- name: PHP-FPM restart
ansible.builtin.service:
name: php7.4-fpm
state: restarted
enabled: true
- name: NGINX restart
ansible.builtin.service:
name: nginx
c state: restarted
enabled: true