Skip to content

Commit ddc812a

Browse files
committed
Re-ordered teardown scrip
1 parent 4bfe275 commit ddc812a

File tree

1 file changed

+93
-0
lines changed

1 file changed

+93
-0
lines changed

teardown-three-tier-app.yml

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,99 @@
3737
name: postgres
3838
state: absent
3939

40+
- name: Teardown app_servers flask configuration
41+
hosts: app_servers
42+
become: true
43+
gather_facts: false
44+
tags:
45+
- application_servers
46+
vars:
47+
flask_app_name: resource_hub
48+
flask_user: flask
49+
flask_home: /opt/
50+
flask_repo: https://github.com/tonykay/resource_hub.git
51+
flask_scm_ref: main
52+
flask_app_lauch_script: /usr/local/bin/launch_resource_hub
53+
virtualenv_name: "venv-{{ flask_app_name }}"
54+
virtualenv_home: /opt/virtual_envs
55+
virtualenv_python: /usr/bin/python3
56+
57+
app_yum_packages:
58+
- autoconf
59+
- automake
60+
- git
61+
- gcc
62+
- libtool
63+
- python3
64+
- python3-devel
65+
- python3-pip
66+
67+
pip_dependencies: []
68+
# - virtualenv
69+
# - pip
70+
# - psycopg2-binary
71+
72+
tasks:
73+
74+
- name: Clean up service when it exists
75+
block:
76+
77+
- name: Check if systemd flask app service file exists
78+
stat:
79+
path: "/etc/systemd/system/{{ flask_app_name }}.service"
80+
register: r_flask_service
81+
82+
- when: r_flask_service.stat.exists
83+
name: Systemd configuration needs stopped and removed
84+
block:
85+
86+
- name: Stop systemd flask app service
87+
service:
88+
name: "{{ flask_app_name }}.service"
89+
state: stopped
90+
enabled: no
91+
# ignore_errors: yes
92+
93+
- name: Remove systemd flask app service file
94+
file:
95+
path: "{{ __path }}"
96+
state: absent
97+
loop:
98+
- "/etc/systemd/system/{{ flask_app_name }}.service"
99+
- /usr/local/bin/launch_resource_hub
100+
loop_control:
101+
loop_var: __path
102+
103+
- name: Remove pre-requisite pip3 packages
104+
pip:
105+
name: "{{ pip_dependencies }}"
106+
state: absent
107+
executable: /usr/bin/pip
108+
# ignore_errors: yes
109+
110+
- name: Remove flask user
111+
user:
112+
name: "{{ flask_user }}"
113+
state: absent
114+
115+
- name: Remove app yum packages
116+
package:
117+
name: "{{ __package }}"
118+
state: absent
119+
loop: "{{ app_yum_packages }}"
120+
loop_control:
121+
loop_var: __package
122+
123+
- name: Remove flask repo and virtualenv
124+
file:
125+
path: "{{ __path }}"
126+
state: absent
127+
loop:
128+
- "{{ flask_home }}/{{ flask_app_name }}"
129+
- "{{ virtualenv_home }}/{{ flask_app_name }}"
130+
loop_control:
131+
loop_var: __path
132+
40133
- name: Teardown haproxy load balancer
41134
hosts: load_balancers
42135
gather_facts: false

0 commit comments

Comments
 (0)