From 88772e38b14d523a3d8570b34a20f422bb42060c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Soko=C5=82owski?= Date: Fri, 26 Apr 2019 12:33:57 +0200 Subject: [PATCH] fix saving of account address MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jakub SokoĊ‚owski --- defaults/main.yml | 11 ++++++----- tasks/generate.yml | 24 ++++++++++++++++-------- 2 files changed, 22 insertions(+), 13 deletions(-) diff --git a/defaults/main.yml b/defaults/main.yml index 10f73da..cde45e5 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -1,5 +1,9 @@ --- -# map of network IDs +# Security +geth_account_address: ~ +geth_account_password: ~ + +# Map of network IDs miner_network_ids: mainnet: 1 frontier: 1 @@ -8,6 +12,7 @@ miner_network_ids: ropsten: 3 rinkeby: 4 +# Container config geth_cont_image: 'ethereum/client-go:v1.8.27' geth_cont_name: 'geth' @@ -49,10 +54,6 @@ geth_cache: 1536 # Address to advertise geth_public_addr: '{{ ansible_host }}' -# security -geth_account_address: ~ -geth_account_password: ~ - # Consul config geth_consul_default_tags: - geth diff --git a/tasks/generate.yml b/tasks/generate.yml index 98a5deb..c4dc949 100644 --- a/tasks/generate.yml +++ b/tasks/generate.yml @@ -30,15 +30,23 @@ - '{{ geth_cont_vol }}/keys:/keys:rw' when: account_files.files | length == 0 +- name: Geth | Find all account files + find: + paths: '{{ geth_keys_path }}' + patterns: 'UTC--*' + file_type: file + register: account_files + - name: Geth | Save account address - uri: - url: http://localhost:{{ geth_rpc_port }}/ - method: POST - body: '{"id": 1, "method": "eth_accounts"}' - body_format: json - return_content: yes - register: geth_accounts + slurp: + src: '{{ account_files.files[0].path }}' + register: geth_account - name: Geth | Extract account address set_fact: - geth_account_address: '{{ node_info.json.result | first }}' + geth_account_address: '{{ (geth_account.content | b64decode | from_json)["address"] }}' + +- name: Geth | Save account address to file + copy: + dest: '{{ geth_keys_path }}/address' + content: '{{ geth_account_address | mandatory }}'