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
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"]
tags: [ "configure", "supervision" ]

View File

@ -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 }}"