diff --git a/ansible.cfg b/ansible.cfg new file mode 100644 index 0000000..ea6634d --- /dev/null +++ b/ansible.cfg @@ -0,0 +1,3 @@ +[defaults] +roles_path = ../ +stdout_callback = yaml \ No newline at end of file diff --git a/defaults/main.yml b/defaults/main.yml index 07ef544..a23c8bb 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -4,3 +4,5 @@ nginx_source_version: 1.21.6 vts_repot_url: https://github.com/vozlt/nginx-module-vts.git + +nginx_module_install_path: "/usr/lib/nginx/modules" diff --git a/tasks/main.yml b/tasks/main.yml index 5184284..d756561 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -3,7 +3,7 @@ - name: Download NGINX get_url: - url: "https://nginx.org/download/{{ nginx_source_version }}.tar.gz" + url: "https://nginx.org/download/nginx-{{ nginx_source_version }}.tar.gz" dest: "/tmp/{{ nginx_source_version }}.tar.gz" mode: 0600 register: nginx_source @@ -12,10 +12,35 @@ unarchive: copy: false dest: /tmp/ - src: "{{ nginx_source_version.dest }}" + src: "{{ nginx_source.dest }}" mode: 0755 - name: Get vts ansible.builtin.git: repo: "{{ vts_repot_url }}" dest: "/tmp/vts" + +- name: Get build flags + ansible.builtin.command: "nginx -V" + register: command_result + +- name: Clean flags + ansible.builtin.set_fact: + build_flags: "{{ command_result.stderr_lines | last | replace('configure arguments: ' ,'')}}" + +- name: Configure build + args: + chdir: "/tmp/nginx-{{ nginx_source_version }}" + ansible.builtin.command: "./configure --add-dynamic-module=../vts {{ build_flags }}" + +- name: Build module + community.general.make: + chdir: "/tmp/nginx-{{ nginx_source_version }}" + target: modules + +- name: Copy VTS module + ansible.builtin.copy: + remote_src: True + src: "/tmp/nginx-{{ nginx_source_version }}/objs/ngx_http_vhost_traffic_status_module.so" + dest: "{{ nginx_module_install_path }}/ngx_http_vhost_traffic_status_module.so" + mode: "0644" diff --git a/tests/inventory b/tests/inventory index 878877b..48c7601 100644 --- a/tests/inventory +++ b/tests/inventory @@ -1,2 +1,2 @@ -localhost +nginx.home diff --git a/tests/test.yml b/tests/test.yml index c9a8a97..f1b3dd4 100644 --- a/tests/test.yml +++ b/tests/test.yml @@ -1,5 +1,5 @@ --- -- hosts: localhost +- hosts: nginx.home remote_user: root roles: - - Ansible-Nginx-Vts-Role + - ansible-nginx-vts-role