From 3d3c16fe9db7a8a0ea5137b3ac0981574ddad470 Mon Sep 17 00:00:00 2001 From: SebClem Date: Fri, 1 Apr 2022 16:28:22 +0200 Subject: [PATCH] First version --- ansible.cfg | 3 +++ defaults/main.yml | 2 ++ tasks/main.yml | 29 +++++++++++++++++++++++++++-- tests/inventory | 2 +- tests/test.yml | 4 ++-- 5 files changed, 35 insertions(+), 5 deletions(-) create mode 100644 ansible.cfg 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