forked from rmeleromira/ansible-zencash-nodes
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathget-addresses.yml
51 lines (50 loc) · 2.2 KB
/
get-addresses.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
---
- hosts: securenodes,supernodes
vars:
addresses: []
gather_facts: false
tasks:
- name: Check for existing z address
shell: zen-cli z_listaddresses
register: existing_z_address
- debug: msg="{{ ansible_fqdn }} - {{existing_z_address.stdout | regex_replace('\[\n \"') | regex_replace('\"\n\]') | regex_replace('')}}"
when: existing_z_address.stdout | from_json | length == 2
# - set_fact:
# address: "{{existing_z_address.stdout | from_json}}"
# when: existing_z_address.stdout | from_json | length > 0
# - set_fact:
# addresses: "{{addresses | union([{'{{ansible_fqdn}}':'{{address[0]}}'}])}}"
# when: existing_z_address.stdout | from_json | length > 0
# - debug: var=addresses
- name: Generate first address
shell: zen-cli z_getnewaddress
when: existing_z_address.stdout | from_json | length == 0
register: first_new_z_address
- name: Generate second address
shell: zen-cli z_getnewaddress
when: existing_z_address.stdout | from_json | length == 0 or existing_z_address.stdout | from_json | length == 1
register: second_new_z_address
- debug: msg="{{ ansible_fqdn }} - {{first_new_z_address.stdout}} - {{second_new_z_address.stdout}}"
when: existing_z_address.stdout | from_json | length == 0
# - set_fact:
# address: "{{new_z_addresses.stdout | from_json}}"
# when: new_z_address is defined and new_z_address.stdout | from_json | length == 0
# - set_fact:
# addresses: "{{addresses}} + ['{{ansible_fqdn}}':'{{address[0]}}']}}"
# when: new_z_address is defined and new_z_address.stdout | from_json | length == 0
# - debug: var=addresses
# - hosts: master
# gather_facts: false
# tasks:
# - name: Generate addresses report
# lineinfile:
# line: "{{ansible_host}} : {{new_z_addresses.stdout | from_json}}"
# path: /root/addresses.txt
# create: true
# when: new_z_addresses is defined
# - name: Generate addresses report
# lineinfile:
# line: "{{ansible_host}} : {{existing_z_addresses.stdout | from_json}}"
# path: /root/addresses.txt
# create: true
# when: existing_z_addresses is defined