Skip to content
This repository was archived by the owner on Feb 26, 2024. It is now read-only.

Commit a9d3a55

Browse files
committed
style: remove application via project
1 parent f1c6019 commit a9d3a55

3 files changed

Lines changed: 20 additions & 14 deletions

File tree

ansible/application-deploy.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,5 @@
77
loop_control:
88
loop_var: project_name
99
with_items: "{{ stackhead.applications }}"
10+
vars:
11+
ensure: 'present'

ansible/application-destroy.yml

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,8 @@
11
---
22
- hosts: all
33
become_user: stackhead
4-
vars:
5-
stackhead__project_folder: "/stackhead/projects/{{ project_name }}" # temporary
6-
stackhead__certificates_project_folder: "/stackhead/certificates/{{ project_name }}" # temporary
74
tasks:
8-
- include_vars: "{{ playbook_dir }}/config.yaml"
9-
- include_tasks: "roles/config_terraform/tasks/remove-project-symlinks.yml"
10-
- import_tasks: "roles/config_terraform/tasks/execute.yml"
11-
- file:
12-
path: "{{ item }}"
13-
state: absent
14-
with_items:
15-
- "{{ stackhead__project_folder }}"
16-
- "{{ stackhead__certificates_project_folder }}"
5+
- include_role:
6+
name: stackhead_project
7+
vars:
8+
ensure: 'absent'

ansible/roles/stackhead_project/tasks/main.yml

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,33 @@
1212
file:
1313
path: "{{ stackhead__tf_project_folder }}"
1414
state: directory
15-
when: project_folder.stat.exists == false
15+
when: project_folder.stat.exists == false and ensure == 'present'
1616

1717
# The following tasks will generate and deploy Terraform configuration files to the remote server
1818
- name: "StackHead::Project || Prepare certificates directory | Project: {{ project_name }}"
1919
import_tasks: "roles/stackhead_project/tasks/ssl/ssl-prepare-certificates.yml"
20+
when: ensure == 'present'
2021

2122
# Setup project by type
2223
- block:
2324
- import_tasks: "roles/stackhead_project/tasks/setup-nativeapp.yml"
2425
when: app_config.type == 'native'
2526
- import_tasks: "roles/stackhead_project/tasks/setup-containerapp.yml"
2627
when: app_config.type == 'container'
28+
when: ensure == 'present'
2729

2830
- import_tasks: "roles/stackhead_project/tasks/ssl/ssl-config.yml"
2931

3032
# Symlink Terraform configurations from project to main folder and execute them
3133
- import_tasks: "roles/config_terraform/tasks/update-project-symlinks.yml"
32-
- import_tasks: "roles/config_terraform/tasks/execute.yml"
34+
when: ensure == 'present'
35+
- include_tasks: "roles/config_terraform/tasks/remove-project-symlinks.yml"
36+
when: ensure == 'absent'
37+
- import_tasks: "roles/config_terraform/tasks/execute.yml"
38+
- file:
39+
path: "{{ item }}"
40+
state: absent
41+
with_items:
42+
- "{{ stackhead__project_folder }}"
43+
- "{{ stackhead__certificates_project_folder }}"
44+
when: ensure == 'absent'

0 commit comments

Comments
 (0)