forked from hyperledger/bevel
-
Notifications
You must be signed in to change notification settings - Fork 0
/
deploy-only-peers.yaml
154 lines (142 loc) · 6.88 KB
/
deploy-only-peers.yaml
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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
# This playbook deploys Peer nodes for an organization on existing Kubernetes clusters
# The Kubernetes clusters should already be created and the infomation to connect to the
# clusters be updated in the network.yaml file that is used as an input to this playbook
###########################################################################################
# To Run this playbook from this directory, use the following command (network.yaml also in this directory)
# ansible-playbook platforms/shared/configuration/site.yaml --extra-vars "@path-to-network.yaml" --extra-vars "peers_only=true"
############################################################################################
# Please ensure that you follow the sample network-fabricv2-only-peers.yaml
# and Orderer's TLS certificates at
# blockchain-automation-framework/platforms/hyperledger-fabric/configuration/build/crypto-config/ordererOrganizations/acn-ord-net/orderers/orderer1.acn-ord-net/tls/ca.crt
# blockchain-automation-framework/platforms/hyperledger-fabric/configuration/build/crypto-config/ordererOrganizations/acn-ord-net/orderers/orderer2.acn-ord-net/tls/ca.crt
---
# This will apply to ansible_provisioners. /etc/ansible/hosts should be configured with this group
- hosts: ansible_provisioners
gather_facts: no
tasks:
# Create Namespaces and Vault-rbac kubernetes-value files
- name: Create namespace and Vault auth for each organization
include_role:
name: "create/namespace_vaultauth"
vars:
component_name: "{{ item.name | lower }}-net"
component_type_name: "{{ item.type | lower }}"
kubernetes: "{{ item.k8s }}"
release_dir: "{{playbook_dir}}/../../../{{item.gitops.release_dir}}/{{ item.name | lower }}"
loop: "{{ network['organizations'] }}"
#Setup Vault-Kubernetes accesses and Regcred for docker registry
- name: Setup Vault Kubernetes for each organization
include_role:
name: "setup/vault_kubernetes"
vars:
component_name: "{{ item.name | lower }}-net"
kubernetes: "{{ item.k8s }}"
vault: "{{ item.vault }}"
component_type: "{{ item.type | lower }}"
auth_path: "{{ item.name | lower }}-net-auth"
loop: "{{ network['organizations'] }}"
# Create Storageclass
- name: Create storageclass for each organization
include_role:
name: "create/storageclass"
vars:
sc_name: "{{ item.name | lower}}sc"
component_type: "{{ item.type | lower}}"
kubernetes: "{{ item.k8s }}"
release_dir: "{{playbook_dir}}/../../../{{item.gitops.release_dir}}/{{ item.name | lower }}"
loop: "{{ network['organizations'] }}"
# Create CA Server helm-value files and check-in
- name: Create CA server for each organization
include_role:
name: "create/ca-server"
vars:
component_name: "{{ item.name | lower}}-net"
component: "{{ item.name | lower}}"
component_type: "{{ item.type | lower}}"
component_services: "{{ item.services }}"
kubernetes: "{{ item.k8s }}"
vault: "{{ item.vault }}"
ca: "{{ item.services.ca }}"
docker_url: "{{ network.docker.url }}"
gitops: "{{ item.gitops }}"
values_dir: "{{playbook_dir}}/../../../{{item.gitops.release_dir}}/{{ item.name | lower }}"
loop: "{{ network['organizations'] }}"
when: item.services.ca is defined
# Create CA Tools helm-value files and check-in
- name: Create CA tools for each organization
include_role:
name: "create/ca-tools"
vars:
component_name: "{{ item.name | lower}}-net"
component: "{{ item.name | lower}}"
component_type: "{{ item.type | lower}}"
component_services: "{{ item.services }}"
kubernetes: "{{ item.k8s }}"
vault: "{{ item.vault }}"
ca: "{{ item.services.ca }}"
gitops: "{{ item.gitops }}"
values_dir: "{{playbook_dir}}/../../../{{item.gitops.release_dir}}/{{ item.name | lower }}"
loop: "{{ network['organizations'] }}"
# Create generate_crypto script for each organization
- name: Create generate_crypto.sh for each organization
include_role:
name: "create/crypto_script"
vars:
component_type: "{{ item.type | lower}}"
orderers: "{{ item.services.orderers }}"
loop: "{{ network['organizations'] }}"
#Creating a pause so that the client certificates are valid
# You can continue if the CA-server pods are running for more than 5 minutes
- pause:
prompt: "Sleeping... so that the client certificates are valid"
minutes: 6
# Create Organization crypto materials
- name: Create crypto materials for each peer
include_role:
name: "create/crypto/peer"
vars:
component_name: "{{ item.name | lower}}-net"
component_type: "{{ item.type | lower}}"
org_name: "{{ item.name }}"
services: "{{ item.services }}"
subject: "{{ item.subject }}"
cert_subject: "{{ item.subject | regex_replace('/', ';') | regex_replace(',', '/') | regex_replace(';', ',') }}" # replace , to / and / to , for certpath
kubernetes: "{{ item.k8s }}"
vault: "{{ item.vault }}"
loop: "{{ network['organizations'] }}"
when: item.type == 'peer'
# This role creates the value file for peers of organisations and write couch db credentials
# to the vault.
- name: Create all peers
include_role:
name: "create/peers"
vars:
build_path: "./build"
namespace: "{{ item.name | lower}}-net"
component_type: "{{ item.type | lower}}"
component_services: "{{ item.services }}"
vault: "{{ item.vault }}"
git_url: "{{ item.gitops.git_url }}"
git_branch: "{{ item.gitops.branch }}"
docker_url: "{{ network.docker.url }}"
charts_dir: "{{ item.gitops.chart_source }}"
values_dir: "{{playbook_dir}}/../../../{{item.gitops.release_dir}}/{{ item.name | lower }}"
loop: "{{ network['organizations'] }}"
when: item.type == 'peer'
# Create CLI pod for peers with cli option enabled
- name: Create CLI pod for each peer with it enabled
include_role:
name: "create/cli_pod"
vars:
peers: "{{ org.services.peers }}"
docker_url: "{{ network.docker.url }}"
loop: "{{ network.organizations }}"
loop_control:
loop_var: org
when: org.type == "peer" and org.org_status == "new"
vars: #These variables can be overriden from the command line
privilege_escalate: false #Default to NOT escalate to root privledges
install_os: "linux" #Default to linux OS
install_arch: "amd64" #Default to amd64 architecture
bin_install_dir: "~/bin" #Default to /bin install directory for binaries
add_new_org: 'false' # Default to false as this is for main network creation