Here is my ansible code
name: Create Nginx WAF Package for Red Hat 8.7 hosts: localhost gather_facts: false become: true
tasks:
name: Install required system packages for compilation yum: name: - gcc - make - openssl-devel - pcre-devel - zlib-devel - libxml2-devel - libxslt-devel - libcurl-devel - yajl-devel - lmdb-devel - ssdeep-devel state: latest
name: Install Epel repository yum: name: epel-release state: latest
name: Install additional packages yum: name: - git - automake - autoconf - libtool state: latest
name: Download ModSecurity source code get_url: url: "https://github.com/SpiderLabs/ModSecurity/archive/v3.0.4.tar.gz" dest: "/tmp/modsecurity.tar.gz"
name: Extract ModSecurity source code unarchive: src: "/tmp/modsecurity.tar.gz" dest: "/tmp" remote_src: true
name: Compile and install ModSecurity shell: | cd /tmp/ModSecurity-3.0.4 git submodule init git submodule update ./build.sh ./configure make make install args: executable: /bin/bash
name: Download Nginx source code get_url: url: "http://nginx.org/download/nginx-1.21.0.tar.gz" dest: "/tmp/nginx-1.21.0.tar.gz"
name: Extract Nginx source code unarchive: src: "/tmp/nginx-1.21.0.tar.gz" dest: "/tmp" remote_src: true
name: Download ModSecurity Nginx Connector get_url: url: "https://github.com/SpiderLabs/ModSecurity-nginx/archive/v1.0.2.tar.gz" dest: "/tmp/modsecurity-nginx.tar.gz"
name: Extract ModSecurity Nginx Connector unarchive: src: "/tmp/modsecurity-nginx.tar.gz" dest: "/tmp" remote_src: true
name: Compile Nginx with ModSecurity shell: | cd /tmp/nginx-1.21.0 ./configure
--with-compat
--add-dynamic-module=/tmp/ModSecurity-nginx-1.0.2 make modules args: executable: /bin/bashname: Create Nginx WAF package shell: tar -czvf /tmp/nginx_waf.tar.gz -C /tmp/nginx-1.21.0/objs/ ngx_http_modsecurity_module.so
It to create a package but failing with error
Configure: error: no ModSecurity/config was found