-
Notifications
You must be signed in to change notification settings - Fork 8
/
site-teardown.yml
107 lines (88 loc) · 3.94 KB
/
site-teardown.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
################################################################################
# Copyright (c) IBM Corporation 2020
#
# Description:
# This playbook will tear down all submodules including cached and meta-data.
# This should be run for a clean checkin to github
#
# Usage:
# ansible-playbook -i inventory site-teardown.yml
################################################################################
---
- hosts: all
gather_facts: no
connection: local
vars:
make_clean: "{{ set_make_clean | default(true) }}"
# ##############################################################################
# # Parse 'registry.yml' for certified contributors (key:value)
# ##############################################################################
tasks:
- name: Parse the registry for collection entries
include_vars: registry.yml
- name: Display the registered collections and properites in `registry.yml`.
debug:
var: collections[item]
with_items: "{{collections}}"
############################################################################
# Evaluate the state of all collections currently in the repo and compare
# them to the registry.yml
#############################################################################
- name: Evaluate which collections are in directory `source/<collection>`
stat:
path: source/{{ item }}
register: git_submodule
with_items: "{{collections}}"
# ############################################################################
# Perform teardown of all submodules to avoid conflicts
#
# NOTE: This only manages the submodules in the `registry.yml` not any
# submodules excluded from the registry.yml
# ############################################################################
- name: 1 - Remove cached submodules according to `registry.yml`.
shell: |
git rm -f --cached source/{{ item }}
with_items: "{{collections}}"
register: git_add_submodules_1
ignore_errors: yes
- name: 1 - Display Remove cached submodules according to `registry.yml`.
debug: msg="{{ git_add_submodules_1 }}"
when: git_add_submodules_1
- name: 2 - Remove local files according to `registry.yml`.
shell: |
rm -rf source/{{ item }}
with_items: "{{collections}}"
register: git_add_submodules_2
- name: 2 - Display remove local files according to `registry.yml`.
debug: msg="{{ git_add_submodules_2 }}"
when: git_add_submodules_2
- name: 3 - Remove all git managed submodule content according to `registry.yml`.
shell: |
rm -rf .git/modules/source/{{ item }}
with_items: "{{collections}}"
register: git_add_submodules_3
- name: 3 - Display remove all git managed submodule content according to `registry.yml`.
debug: msg="{{ git_add_submodules_3 }}"
when: git_add_submodules_3
- name: 4 - Remove .gitmodules references for all submodules according to `registry.yml`.
shell: |
git config -f .gitmodules --remove-section submodule.source/{{ item }}
with_items: "{{collections}}"
register: git_add_submodules_4
ignore_errors: yes
- name: 4 - Display remove .gitmodules references for all submodules according to `registry.yml`.
debug: msg="{{ git_add_submodules_4 }}"
when: git_add_submodules_4
- name: 5 - Temporarily force a `git reset` because site-builder.yaml leaves this in changed state.
shell: |
git reset HEAD .gitmodules
register: git_add_submodules_5
- name: 5 - Display git reset HEAD .gitmodules.
debug: msg="{{ git_add_submodules_4 }}"
when: git_add_submodules_5
############################################################################
# Generate and view HTML
############################################################################
- name: Clean up generted HTML
raw: make clean;
when: make_clean