HEX
Server: LiteSpeed
System: Linux kapuas.iixcp.rumahweb.net 5.14.0-427.42.1.el9_4.x86_64 #1 SMP PREEMPT_DYNAMIC Fri Nov 1 14:58:02 EDT 2024 x86_64
User: mirz4654 (1666)
PHP: 8.1.33
Disabled: system,exec,escapeshellarg,escapeshellcmd,passthru,proc_close,proc_get_status,proc_nice,proc_open,proc_terminate,shell_exec,popen,pclose,dl,pfsockopen,leak,apache_child_terminate,posix_kill,posix_mkfifo,posix_setsid,posix_setuid,posix_setpgid,ini_alter,show_source,define_syslog_variables,symlink,syslog,openlog,openlog,closelog,ocinumcols,listen,chgrp,apache_note,apache_setenv,debugger_on,debugger_off,ftp_exec,dll,ftp,myshellexec,socket_bind,mail,posix_getwpuid
Upload Files
File: //lib/python3.9/site-packages/ansible_collections/community/zabbix/molecule/zabbix_web/prepare.yml
---
- name: Prepare
  hosts: localhost
  connection: local
  pre_tasks:
    - name: "Create MySQL Container"
      docker_container:
        name: mysql-host
        image: mysql:8.0
        state: started
        recreate: true
        networks:
          - name: zabbix
        env:
          MYSQL_ROOT_PASSWORD: changeme
      no_log: true
      with_items: "{{ molecule_yml.platforms }}"
      when:
        - '"mysql" in item.groups'

    - name: "Create postgresql Container"
      docker_container:
        name: postgresql-host
        image: postgres:13
        state: started
        recreate: true
        networks:
          - name: zabbix
        env:
          POSTGRES_PASSWORD: changeme
      no_log: true
      with_items: "{{ molecule_yml.platforms }}"
      when:
        - '"postgresql" in item.groups'

- name: Prepare
  hosts: all
  pre_tasks:
    - name: "Create group for imaginary host"
      add_host:
        name: imaginary-host
        groups:
          - mysql
          - postgresql
      changed_when: false

    - name: "Installing packages on CentOS"
      yum:
        name:
          - net-tools
          - which
          - curl
          - sudo
          - "{{ 'python3-pip' if ansible_distribution_major_version == '8' else 'python-pip' }}"
          - "{{ 'python3-libselinux' if ansible_distribution_major_version == '8' else 'libselinux-python' }}"
        state: present
      register: installation_dependencies
      until: installation_dependencies is succeeded
      when:
        - ansible_os_family == 'RedHat'

    - name: "Installing packages (CentOS7)"
      yum:
        name:
          - centos-release-scl
        state: present
      register: installation_dependencies
      when:
        - ansible_os_family == 'RedHat'
        - ansible_distribution_major_version == '7'

    - name: "Installing MySQL on CentOS"
      yum:
        name:
          - mysql
        state: present
      register: installation_dependencies
      until: installation_dependencies is succeeded
      when:
        - ansible_os_family == 'RedHat'
        - inventory_hostname in groups['mysql']

    - name: "Installing packages on NON-CentOS"
      apt:
        name:
          - net-tools
          - curl
          - apt-utils
          - apt-transport-https
          - ca-certificates
          - gnupg2
          - gpg-agent
          - sudo
          - vim
          - "{{ 'python3-apt' if ansible_distribution_major_version in ['10', '11', '18', '20'] else 'python-apt' }}"
          - "{{ 'python3-pip' if ansible_distribution_major_version in ['10', '11', '18', '20'] else 'python-pip' }}"
        update_cache: true
        state: present
      register: installation_dependencies
      until: installation_dependencies is succeeded
      when:
        - ansible_os_family != 'RedHat'

    - name: "Configure SUDO."
      lineinfile:
        dest: /etc/sudoers
        line: "Defaults    !requiretty"
        state: present

    - name: "Make sure the docs are installed."
      lineinfile:
        dest: /etc/yum.conf
        line: "tsflags=nodocs"
        state: absent
      when:
        - ansible_os_family == 'RedHat'

    - name: PyMySQL
      pip:
        name: PyMySQL
      register: installation_dependencies
      until: installation_dependencies is succeeded
      when:
        - inventory_hostname in groups['mysql']

    - name: Enabeling PHP 7.4
      command: dnf module enable php:7.4 -y
      when:
        - ansible_os_family == 'RedHat'
        - ansible_distribution_major_version == "8"

  roles:
    - role: geerlingguy.apache
      when:
        - zabbix_websrv == "apache"
    - role: geerlingguy.nginx
      when:
        - zabbix_websrv == "nginx"
    - role: geerlingguy.php
      when:
        - ansible_os_family != 'RedHat' or (ansible_os_family == 'RedHat' and ansible_distribution_major_version == "8")
    - role: zabbix_server

  post_tasks:
    - name: "Remove file"
      file:
        path: "{{ item }}"
        state: absent
      with_items:
        - /var/www/html/index.html