finish configure stats

This commit is contained in:
Valentin CZERYBA 2023-02-12 19:15:48 +01:00
parent 87ea635874
commit c54c384178
2 changed files with 43 additions and 108 deletions

View File

@ -1,12 +1,12 @@
- name: Deploy stats script - name: Deploy stats script
import_tasks: stats.yml import_tasks: stats.yml
tags: ["stats"] tags: [ "configure", "stats"]
- name: Configure blacklist script - name: Configure blacklist script
import_tasks: blacklist.yml import_tasks: blacklist.yml
tags: [ "blacklist" ] tags: [ "configure", "blacklist" ]
- name: Configure supervision script - name: Configure supervision script
import_tasks: supervision.yml import_tasks: supervision.yml
tags: ["supervision"] tags: [ "configure", "supervision" ]

View File

@ -3,145 +3,80 @@
- name: Create sentinel directory - name: Create sentinel directory
file: file:
state: directory state: directory
path: /usr/local/bin/sentinel path: "{{ item }}/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"
with_items: with_items:
- "{{ project }}" - /usr/local/bin
- /etc
vars: vars:
ansible_become: yes ansible_become: yes
ansible_become_method: sudo ansible_become_method: sudo
ansible_become_password: "{{ sudo_password }}" ansible_become_password: "{{ sudo_password }}"
- name: Template virtualhost
- name: "all extract repo " template:
unarchive: src: virtualhost.j2
src: "/tmp/{{ item.git_name }}.tar.gz" dest: /etc/sentinel/virtualhost
dest: "/var/www/{{ item.git_name }}" mode: "0755"
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 }}"
vars: vars:
ansible_become: yes ansible_become: yes
ansible_become_method: sudo ansible_become_method: sudo
ansible_become_password: "{{ sudo_password }}" ansible_become_password: "{{ sudo_password }}"
- name: Template getinfo day script
- name: "single git archive" template:
local_action: src: getinfo_day.sh.j2
module: git dest: /usr/local/bin/sentinel/getinfo_day.sh
repo: "https://{{ git_username | urlencode }}:{{ git_password | urlencode }}@git.valczeryba.ovh/v4l3n71n/{{ project_name }}.git" mode: "0755"
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"
vars: vars:
ansible_become: yes ansible_become: yes
ansible_become_method: sudo ansible_become_method: sudo
ansible_become_password: "{{ sudo_password }}" ansible_become_password: "{{ sudo_password }}"
- name: Template getinfo month and week script
- 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"
copy: copy:
src: "nginx.conf" src: "getinfo_{{ item }}.sh.j2"
dest: "/etc/nginx/" dest: "/usr/local/bin/sentinel/getinfo_{{ item }}.sh"
vars: mode: "0755"
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: with_items:
- "{{ project }}" - week
- month
vars: vars:
ansible_become: yes ansible_become: yes
ansible_become_method: sudo ansible_become_method: sudo
ansible_become_password: "{{ sudo_password }}" ansible_become_password: "{{ sudo_password }}"
- name: Crontab get info day
- name: "all create symlink" ansible.builtin.cron:
file: name: "get info day"
src: "/etc/nginx/sites-available/{{ item.conf_name }}" minute: "0"
dest: "/etc/nginx/sites-enabled/{{ item.conf_name }}" hour: "3"
state: link job: "bash /usr/local/bin/sentinel/getinfo_day.sh"
when: "item.conf_name is defined and project_name is not defined and conf_name is not defined"
with_items:
- "{{ project }}"
vars: vars:
ansible_become: yes ansible_become: yes
ansible_become_method: sudo ansible_become_method: sudo
ansible_become_password: "{{ sudo_password }}" ansible_become_password: "{{ sudo_password }}"
- name: Crontab get info week
- name: "single copy configure nginx" ansible.builtin.cron:
copy: name: "get info week"
src: "{{ conf_name }}" minute: "15"
dest: "/etc/nginx/sites-available" hour: "3"
when: "conf_name is defined" weekday: "1"
job: "bash /usr/local/bin/sentinel/getinfo_week.sh"
vars: vars:
ansible_become: yes ansible_become: yes
ansible_become_method: sudo ansible_become_method: sudo
ansible_become_password: "{{ sudo_password }}" ansible_become_password: "{{ sudo_password }}"
- name: Crontab get info month
- name: "single create symlink" ansible.builtin.cron:
file: name: "get info mongth"
src: "/etc/nginx/sites-available/{{ conf_name }}" minute: "30"
dest: "/etc/nginx/sites-enabled/{{ conf_name }}" hour: "3"
state: link day: "1"
when: "conf_name is defined" job: "bash /usr/local/bin/sentinel/getinfo_month.sh"
vars: vars:
ansible_become: yes ansible_become: yes
ansible_become_method: sudo ansible_become_method: sudo
ansible_become_password: "{{ sudo_password }}" 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 }}"