add destroy web project

This commit is contained in:
Valentin CZERYBA 2022-11-12 20:45:00 +01:00
parent a647946652
commit 1996945eb4
3 changed files with 37 additions and 9 deletions

View File

@ -1,7 +1,6 @@
---
# tasks file for deploy-web
- name: git archive {{ item }}
- name: "git archive {{ item }}"
local_action:
module: git
repo: "https://{{ git_username | urlencode }}:{{ git_password | urlencode }}@git.valczeryba.ovh/v4l3n71n/{{ item }}.git"
@ -9,18 +8,20 @@
archive: "/tmp/{{ item }}.tar.gz"
force: yes
update: yes
with_items: "{{ project_name }}"
with_items:
- "{{ project_name }}"
when: "project_name is defined"
- name: Create directory {{ item }}
- name: "Create directory {{ item }}"
file:
path: "/var/www/{{ item }}"
state: directory
owner: www-data
group: www-data
mode: '500'
with_items: "{{ project_name }}"
with_items:
- "{{ project_name }}"
when: "project_name is defined"
vars:
ansible_become: yes
@ -28,14 +29,15 @@
ansible_become_password: "{{ sudo_password }}"
- name: Extract repo {{ item }}
- name: "Extract repo {{ item }}"
unarchive:
src: "/tmp/{{ item }}.tar.gz"
dest: "/var/www/{{ item }}"
owner: www-data
group: www-data
mode: '500'
with_items: "{{ project_name }}"
with_items:
- "{{ project_name }}"
when: "project_name is defined"
vars:
ansible_become: yes

View File

@ -0,0 +1,21 @@
- name: "Remove all directories"
file:
path: "/var/www/{{ item }}"
state: absent
with_items:
- "{{ project_name }}"
when: "project_name is defined and project is not defined"
vars:
ansible_become: yes
ansible_become_method: sudo
ansible_become_password: "{{ sudo_password }}"
- name: "Remove single directory"
file:
path: "/var/www/{{ project }}"
state: absent
when: "project is defined"
vars:
ansible_become: yes
ansible_become_method: sudo
ansible_become_password: "{{ sudo_password }}"

View File

@ -1,3 +1,8 @@
- name: Deploy project_name
- name: Deploy project web
import_tasks: deploy.yml
tags: ["deploy"]
tags: ["deploy"]
- name: Destrpy project web
import_tasks: destroy.yml
tags: ["destroy"]