This repository was archived by the owner on Feb 26, 2024. It is now read-only.
File tree Expand file tree Collapse file tree
roles/stackhead_project/tasks Expand file tree Collapse file tree Original file line number Diff line number Diff line change 77 loop_control :
88 loop_var : project_name
99 with_items : " {{ stackhead.applications }}"
10+ vars :
11+ ensure : ' present'
Original file line number Diff line number Diff line change 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'
Original file line number Diff line number Diff line change 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'
You can’t perform that action at this time.
0 commit comments