From c54c384178d808e0813d63190cd5eee61e27032f Mon Sep 17 00:00:00 2001 From: Valentin CZERYBA Date: Sun, 12 Feb 2023 19:15:48 +0100 Subject: [PATCH] finish configure stats --- roles/deploy-web/tasks/configure.yml | 6 +- roles/deploy-web/tasks/stats.yml | 145 ++++++++------------------- 2 files changed, 43 insertions(+), 108 deletions(-) diff --git a/roles/deploy-web/tasks/configure.yml b/roles/deploy-web/tasks/configure.yml index 4f1de1d..754855a 100644 --- a/roles/deploy-web/tasks/configure.yml +++ b/roles/deploy-web/tasks/configure.yml @@ -1,12 +1,12 @@ - name: Deploy stats script import_tasks: stats.yml - tags: ["stats"] + tags: [ "configure", "stats"] - name: Configure blacklist script import_tasks: blacklist.yml - tags: [ "blacklist" ] + tags: [ "configure", "blacklist" ] - name: Configure supervision script import_tasks: supervision.yml - tags: ["supervision"] \ No newline at end of file + tags: [ "configure", "supervision" ] \ No newline at end of file diff --git a/roles/deploy-web/tasks/stats.yml b/roles/deploy-web/tasks/stats.yml index edff9af..ae6904f 100644 --- a/roles/deploy-web/tasks/stats.yml +++ b/roles/deploy-web/tasks/stats.yml @@ -3,145 +3,80 @@ - name: Create sentinel directory file: state: directory - path: /usr/local/bin/sentinel - vars: - ansible_become: yes - ansible_become_method: sudo - ansible_become_password: "{{ sudo_password }}" - -- name: "all create directory " - file: - path: "/var/www/{{ item.git_name }}" - state: directory - owner: www-data - group: www-data - mode: '500' - when: "item.git_name is defined and project_name is not defined and conf_name is not defined" + path: "{{ item }}/sentinel" with_items: - - "{{ project }}" + - /usr/local/bin + - /etc vars: ansible_become: yes ansible_become_method: sudo ansible_become_password: "{{ sudo_password }}" - -- name: "all extract repo " - unarchive: - src: "/tmp/{{ item.git_name }}.tar.gz" - dest: "/var/www/{{ item.git_name }}" - owner: www-data - group: www-data - mode: '500' - when: "item.git_name is defined and project_name is not defined and conf_name is not defined" - with_items: - - "{{ project }}" +- name: Template virtualhost + template: + src: virtualhost.j2 + dest: /etc/sentinel/virtualhost + mode: "0755" vars: ansible_become: yes ansible_become_method: sudo ansible_become_password: "{{ sudo_password }}" - -- name: "single git archive" - local_action: - module: git - repo: "https://{{ git_username | urlencode }}:{{ git_password | urlencode }}@git.valczeryba.ovh/v4l3n71n/{{ project_name }}.git" - dest: "/home/valentin/src/" - archive: "/tmp/{{ project_name }}.tar.gz" - force: yes - update: yes - when: "project_name is defined" - - -- name: "single create directory " - file: - path: "/var/www/{{ project_name }}" - state: directory - owner: www-data - group: www-data - mode: '500' - when: "project_name is defined" +- name: Template getinfo day script + template: + src: getinfo_day.sh.j2 + dest: /usr/local/bin/sentinel/getinfo_day.sh + mode: "0755" vars: ansible_become: yes ansible_become_method: sudo ansible_become_password: "{{ sudo_password }}" - -- name: "single extract repo " - unarchive: - src: "/tmp/{{ project_name }}.tar.gz" - dest: "/var/www/{{ project_name }}" - owner: www-data - group: www-data - mode: '500' - when: "project_name is defined" - vars: - ansible_become: yes - ansible_become_method: sudo - ansible_become_password: "{{ sudo_password }}" - -- name: "copy nginx.conf" +- name: Template getinfo month and week script copy: - src: "nginx.conf" - dest: "/etc/nginx/" + src: "getinfo_{{ item }}.sh.j2" + dest: "/usr/local/bin/sentinel/getinfo_{{ item }}.sh" + mode: "0755" + with_items: + - week + - month vars: ansible_become: yes ansible_become_method: sudo ansible_become_password: "{{ sudo_password }}" -- name: "all copy configure nginx" - copy: - src: "{{ item.conf_name }}" - dest: "/etc/nginx/sites-available" - when: "item.conf_name is defined and project_name is not defined and conf_name is not defined" - with_items: - - "{{ project }}" +- name: Crontab get info day + ansible.builtin.cron: + name: "get info day" + minute: "0" + hour: "3" + job: "bash /usr/local/bin/sentinel/getinfo_day.sh" vars: ansible_become: yes ansible_become_method: sudo ansible_become_password: "{{ sudo_password }}" - -- name: "all create symlink" - file: - src: "/etc/nginx/sites-available/{{ item.conf_name }}" - dest: "/etc/nginx/sites-enabled/{{ item.conf_name }}" - state: link - when: "item.conf_name is defined and project_name is not defined and conf_name is not defined" - with_items: - - "{{ project }}" +- name: Crontab get info week + ansible.builtin.cron: + name: "get info week" + minute: "15" + hour: "3" + weekday: "1" + job: "bash /usr/local/bin/sentinel/getinfo_week.sh" vars: ansible_become: yes ansible_become_method: sudo ansible_become_password: "{{ sudo_password }}" - -- name: "single copy configure nginx" - copy: - src: "{{ conf_name }}" - dest: "/etc/nginx/sites-available" - when: "conf_name is defined" +- name: Crontab get info month + ansible.builtin.cron: + name: "get info mongth" + minute: "30" + hour: "3" + day: "1" + job: "bash /usr/local/bin/sentinel/getinfo_month.sh" vars: ansible_become: yes ansible_become_method: sudo ansible_become_password: "{{ sudo_password }}" - -- name: "single create symlink" - file: - src: "/etc/nginx/sites-available/{{ conf_name }}" - dest: "/etc/nginx/sites-enabled/{{ conf_name }}" - state: link - when: "conf_name is defined" - vars: - ansible_become: yes - ansible_become_method: sudo - ansible_become_password: "{{ sudo_password }}" - -- name: restart nginx - service: - name: nginx - state: restarted - vars: - ansible_become: yes - ansible_become_method: sudo - ansible_become_password: "{{ sudo_password }}" \ No newline at end of file