-
Notifications
You must be signed in to change notification settings - Fork 445
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[CE-374] Ansible plays updating/redeploying BNA archive
This patch adds onto the ansible agent plays. Specifically, it adds upgradecomposer.yml, which invokes roles/upgrade_compose/plays.yml, which invokes roles/upgrade_compose/composerupgrade/tasks/apply.yml on the builder node. This uploads the bna in the secrets/networks folder to the builder node then runs 'composer update' with the bna. Change-Id: I7a579d0fa7d9fbde7f25730a4d5b9c3f65dae3b6 Signed-off-by: Jordan Dearsley <[email protected]>
- Loading branch information
Showing
3 changed files
with
75 additions
and
0 deletions.
There are no files selected for viewing
46 changes: 46 additions & 0 deletions
46
src/agent/ansible/roles/upgrade_compose/composerupgrade/tasks/apply.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
--- | ||
- name: Setup and initialize variables | ||
set_fact: | ||
current_host: "{{ hostvars[inventory_hostname].inter_name }}" | ||
peers: "{{ [] }}" | ||
|
||
- name: Get peer container list | ||
set_fact: | ||
peers: | | ||
{{ peers + [{'org':item.split('@')[1].split('.')[-1], | ||
'name':item.split('@')[1] | replace('.', '-'), | ||
'role':item.split('@')[0]}] }} | ||
with_items: "{{ fabric.network[current_host].peers | default([]) }}" | ||
|
||
- name: Setup few variables | ||
set_fact: | ||
fabricworkdir: "/opt/gopath/{{ env }}/fabric" | ||
fabricpath: "/opt/gopath/{{ env }}/src/github.com/hyperledger/fabric" | ||
gopath: "/opt/gopath/{{ env }}" | ||
localhome: "/home/{{ fabric.ssh_user }}/.composer" | ||
alladmin: "" | ||
peerorgs: "{{ peers | map(attribute='org') | list | unique | sort }}" | ||
|
||
- name: Generate all admin options | ||
set_fact: | ||
alladmin: "{{ alladmin + '-A ' + item + 'Admin -C /home/composer/.composer/' + item + 'Admin/admin-pub.pem ' }}" | ||
with_items: "{{ peerorgs }}" | ||
tags: "generatealladmin" | ||
|
||
- name: Upload bna file | ||
copy: | ||
src: "{{ item }}" | ||
dest: "{{ fabricworkdir }}/keyfiles/" | ||
with_fileglob: | ||
- "{{ playbook_dir }}/../../secrets/networks/*.bna" | ||
tags: "uploadbna" | ||
|
||
- name: Update bna on network | ||
command: >- | ||
docker run -v {{ localhome }}:/home/composer/.composer | ||
-v {{ fabricworkdir }}:{{ fabricworkdir }} | ||
hyperledger/composer-cli:next network update | ||
-c {{ peerorgs[0] }}Admin@{{ networkname }} | ||
-a {{ fabricworkdir }}/keyfiles/{{ networkname }}.bna | ||
tags: "updatebna" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
--- | ||
- name: update bna and deploy | ||
hosts: builders | ||
gather_facts: true | ||
user: "{{ fabric.ssh_user }}" | ||
vars_files: | ||
- "./../../vars/{{ env }}.yml" | ||
tasks: | ||
- include_tasks: "composerupgrade/tasks/apply.yml" | ||
tags: "deploybna" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
--- | ||
- name: Get start timestamp | ||
hosts: cloud | ||
connection: local | ||
tasks: | ||
- set_fact: | ||
starttime: "{{ ansible_date_time }}" | ||
|
||
- name: Run the plays | ||
include: "roles/upgrade_compose/plays.yml" | ||
|
||
- name: inform the installer | ||
hosts: cloud | ||
connection: local | ||
tasks: | ||
- debug: | ||
msg: >- | ||
The work load started at {{ hostvars.cloud.starttime.time }}, | ||
ended at {{ ansible_date_time.time }} |