Skip to content
This repository was archived by the owner on Jan 20, 2021. It is now read-only.

Commit 3ecb418

Browse files
author
Simon Stone
authored
Merge pull request #123 from sstone1/issue-120
Delete components in software when state set to absent (resolves #120)
2 parents 6bf22c8 + 1acb120 commit 3ecb418

File tree

4 files changed

+136
-0
lines changed

4 files changed

+136
-0
lines changed

tasks/software/delete-ca.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#
2+
# SPDX-License-Identifier: Apache-2.0
3+
#
4+
---
5+
- name: Get the list of components
6+
uri:
7+
url: "{{ infrastructure.software.api_endpoint }}/ak/api/v1/components"
8+
url_username: "{{ infrastructure.software.api_key }}"
9+
url_password: "{{ infrastructure.software.api_secret }}"
10+
method: GET
11+
return_content: yes
12+
validate_certs: no
13+
register: ibp_components
14+
15+
- name: Check for certificate authority
16+
set_fact:
17+
ibp_ca_count: "{{
18+
ibp_components.json |
19+
selectattr('display_name', 'defined') |
20+
selectattr('display_name', 'eq', ca.ibp.display_name) |
21+
list
22+
}}"
23+
24+
- name: Delete certificate authority
25+
uri:
26+
url: "{{ infrastructure.software.api_endpoint }}/ak/api/v1/components/{{ ibp_ca.id }}"
27+
url_username: "{{ infrastructure.software.api_key }}"
28+
url_password: "{{ infrastructure.software.api_secret }}"
29+
method: DELETE
30+
validate_certs: no
31+
changed_when: True
32+
with_items: "{{ ibp_ca_count }}"
33+
loop_control:
34+
loop_var: ibp_ca

tasks/software/delete-msp.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#
2+
# SPDX-License-Identifier: Apache-2.0
3+
#
4+
---
5+
- name: Get the list of components
6+
uri:
7+
url: "{{ infrastructure.software.api_endpoint }}/ak/api/v1/components"
8+
url_username: "{{ infrastructure.software.api_key }}"
9+
url_password: "{{ infrastructure.software.api_secret }}"
10+
method: GET
11+
return_content: yes
12+
validate_certs: no
13+
register: ibp_components
14+
15+
- name: Check for MSP
16+
set_fact:
17+
ibp_msp_count: "{{
18+
ibp_components.json |
19+
selectattr('display_name', 'defined') |
20+
selectattr('display_name', 'eq', organization.msp.ibp.display_name) |
21+
list
22+
}}"
23+
24+
- name: Delete MSP
25+
uri:
26+
url: "{{ infrastructure.software.api_endpoint }}/ak/api/v1/components/{{ ibp_msp.id }}"
27+
url_username: "{{ infrastructure.software.api_key }}"
28+
url_password: "{{ infrastructure.software.api_secret }}"
29+
method: DELETE
30+
validate_certs: no
31+
changed_when: True
32+
with_items: "{{ ibp_msp_count }}"
33+
loop_control:
34+
loop_var: ibp_msp

tasks/software/delete-orderer.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#
2+
# SPDX-License-Identifier: Apache-2.0
3+
#
4+
---
5+
- name: Get the list of components
6+
uri:
7+
url: "{{ infrastructure.software.api_endpoint }}/ak/api/v1/components"
8+
url_username: "{{ infrastructure.software.api_key }}"
9+
url_password: "{{ infrastructure.software.api_secret }}"
10+
method: GET
11+
return_content: yes
12+
validate_certs: no
13+
register: ibp_components
14+
15+
- name: Check for orderer
16+
set_fact:
17+
ibp_orderer_count: "{{
18+
ibp_components.json |
19+
selectattr('cluster_name', 'defined') |
20+
selectattr('cluster_name', 'eq', orderer.ibp.cluster_name) |
21+
list
22+
}}"
23+
24+
- name: Delete orderer
25+
uri:
26+
url: "{{ infrastructure.software.api_endpoint }}/ak/api/v1/components/{{ ibp_orderer.id }}"
27+
url_username: "{{ infrastructure.software.api_key }}"
28+
url_password: "{{ infrastructure.software.api_secret }}"
29+
method: DELETE
30+
validate_certs: no
31+
changed_when: True
32+
with_items: "{{ ibp_orderer_count }}"
33+
loop_control:
34+
loop_var: ibp_orderer

tasks/software/delete-peer.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#
2+
# SPDX-License-Identifier: Apache-2.0
3+
#
4+
---
5+
- name: Get the list of components
6+
uri:
7+
url: "{{ infrastructure.software.api_endpoint }}/ak/api/v1/components"
8+
url_username: "{{ infrastructure.software.api_key }}"
9+
url_password: "{{ infrastructure.software.api_secret }}"
10+
method: GET
11+
return_content: yes
12+
validate_certs: no
13+
register: ibp_components
14+
15+
- name: Check for peer
16+
set_fact:
17+
ibp_peer_count: "{{
18+
ibp_components.json |
19+
selectattr('display_name', 'defined') |
20+
selectattr('display_name', 'eq', peer.ibp.display_name) |
21+
list
22+
}}"
23+
24+
- name: Delete peer
25+
uri:
26+
url: "{{ infrastructure.software.api_endpoint }}/ak/api/v1/components/{{ ibp_peer.id }}"
27+
url_username: "{{ infrastructure.software.api_key }}"
28+
url_password: "{{ infrastructure.software.api_secret }}"
29+
method: DELETE
30+
validate_certs: no
31+
changed_when: True
32+
with_items: "{{ ibp_peer_count }}"
33+
loop_control:
34+
loop_var: ibp_peer

0 commit comments

Comments
 (0)