From f0ee952d8fef3c3c0829446ad582d560f771b04b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A2=D1=8E=D1=82=D1=80=D1=8E=D0=BC=D0=BE=D0=B2=20=D0=A1?= =?UTF-8?q?=D0=B5=D1=80=D0=B3=D0=B5=D0=B9=20=D0=9C=D0=B8=D1=85=D0=B0=D0=B9?= =?UTF-8?q?=D0=BB=D0=BE=D0=B2=D0=B8=D1=87?= Date: Mon, 15 Apr 2024 21:58:33 +0300 Subject: [PATCH] testing role --- tsm_labs/handlers/main.yml | 12 +++++++- tsm_labs/meta/main.yml | 8 +++--- tsm_labs/tasks/main.yml | 49 +++++++++++++++++++++++++++++++- tsm_labs/templates/nginx.conf.j2 | 38 +++++++++++++++++++++++++ tsm_labs/tests/inventory | 2 -- tsm_labs/tests/test.yml | 5 ---- tsm_labs/vars/main.yml | 5 +++- 7 files changed, 105 insertions(+), 14 deletions(-) create mode 100644 tsm_labs/templates/nginx.conf.j2 delete mode 100644 tsm_labs/tests/inventory delete mode 100644 tsm_labs/tests/test.yml diff --git a/tsm_labs/handlers/main.yml b/tsm_labs/handlers/main.yml index 713caea..dc4e54a 100644 --- a/tsm_labs/handlers/main.yml +++ b/tsm_labs/handlers/main.yml @@ -1,2 +1,12 @@ --- -# handlers file for tsm_labs +# handlers file for itt_labs +- name: Enable nginx service + ansible.builtin.systemd_service: + name: "nginx.service" + state: restarted + enabled: true + +- name: Reload nginx service + ansible.builtin.systemd_service: + name: "nginx.service" + state: restarted diff --git a/tsm_labs/meta/main.yml b/tsm_labs/meta/main.yml index c572acc..7343d8c 100644 --- a/tsm_labs/meta/main.yml +++ b/tsm_labs/meta/main.yml @@ -1,7 +1,7 @@ galaxy_info: - author: your name - description: your role description - company: your company (optional) + author: Serjio + description: The first try + company: Bonch # If the issue tracker for your role is not on github, uncomment the # next line and provide a value @@ -14,7 +14,7 @@ galaxy_info: # - GPL-3.0-only # - Apache-2.0 # - CC-BY-4.0 - license: license (GPL-2.0-or-later, MIT, etc) + license: BSD-3-Clause min_ansible_version: 2.1 diff --git a/tsm_labs/tasks/main.yml b/tsm_labs/tasks/main.yml index 247aea0..980ae93 100644 --- a/tsm_labs/tasks/main.yml +++ b/tsm_labs/tasks/main.yml @@ -1,2 +1,49 @@ --- -# tasks file for tsm_labs +- name: Update packeges + hosts: node + become: yes + tasks: + - name: Update all packages Ubuntu + when: ansible_os_family == 'Debian' + apt: + update_cache: yes + upgrade: yes + + - name: Update all packages CentOS + when: ansible_os_family == 'RedHat' + yum: + name: '*' + state: latest + + - name: Install nginx 'Ubuntu' + when: ansible_os_family == 'Debian' + ansible.builtin.apt: + package: + - nginx + state: present + update_cache: yes + + - name: Install nginx 'RedHat' + when: ansible_os_family == 'RedHat' + ansible.builtin.yum: + name: + - nginx + state: present + + - name: Copy config nginx + ansible.builtin.template: + src: nginx.conf.j2 + dest: /etc/nginx/nginx.conf + owner: root + group: root + made: '0644' + notify: Reload nginx service + + + + + + + + + diff --git a/tsm_labs/templates/nginx.conf.j2 b/tsm_labs/templates/nginx.conf.j2 new file mode 100644 index 0000000..3a18c90 --- /dev/null +++ b/tsm_labs/templates/nginx.conf.j2 @@ -0,0 +1,38 @@ +user {{ nginx_user }}; +worker_processes 2048; +worker_priority -1; + +error_log /var/log/nginx/error.log warn; +pid /var/run/nginx.pid; + +events { + worker_connections {{worker_connections}}; +} + +http { + include /etc/nginx/mime.types; + default_type application/octet-stream; + log_format main '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; + access_log /var/log/nginx/access.log main; + sendfile on; + tcp_nopush on; + tcp_nodelay on; + keepalive_timeout 65; + reset_timedout_connection on; + client_body_timeout 35; + send_timeout 30; + gzip on; + gzip_min_length {{gzip_min_length}}; + gzip_vary on; + gzip_proxied expired no-cache no-store private auth; + gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript application/javascript; gzip_disable "msie6"; + types_hash_max_size 2048; + client_max_body_size {{client_max_body_size}}; + proxy_buffer_size 64k; + proxy_buffers 4 64k; + proxy_busy_buffers_size 64k; + server_names_hash_bucket_size 64; + include /etc/nginx/modules-enabled/*.conf; + include /etc/nginx/conf.d/*.conf; + include /etc/nginx/sites-enabled/*; +} diff --git a/tsm_labs/tests/inventory b/tsm_labs/tests/inventory deleted file mode 100644 index 878877b..0000000 --- a/tsm_labs/tests/inventory +++ /dev/null @@ -1,2 +0,0 @@ -localhost - diff --git a/tsm_labs/tests/test.yml b/tsm_labs/tests/test.yml deleted file mode 100644 index eb87134..0000000 --- a/tsm_labs/tests/test.yml +++ /dev/null @@ -1,5 +0,0 @@ ---- -- hosts: localhost - remote_user: root - roles: - - tsm_labs diff --git a/tsm_labs/vars/main.yml b/tsm_labs/vars/main.yml index 1720187..796ac5f 100644 --- a/tsm_labs/vars/main.yml +++ b/tsm_labs/vars/main.yml @@ -1,2 +1,5 @@ --- -# vars file for tsm_labs +worker_connections: auto +gzip_min_length: 1000 +client_max_body_size: 512m +