From 39d511917c996aec517ba59917df59a9ec6412d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Soko=C5=82owski?= Date: Tue, 17 Mar 2020 01:08:23 +0100 Subject: [PATCH] fix account generation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jakub SokoĊ‚owski --- defaults/main.yml | 6 +++--- tasks/generate.yml | 28 ++++++++++++++++++---------- 2 files changed, 21 insertions(+), 13 deletions(-) diff --git a/defaults/main.yml b/defaults/main.yml index b204efa..2b9a8c7 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -1,8 +1,8 @@ --- # Security, json is optional -geth_account_addr: ~ -geth_account_pass: ~ -geth_account_json: ~ +#geth_account_addr: ~ +#geth_account_pass: ~ +#geth_account_json: ~ # Geth miner extra data geth_extra_data: '{{ hostname }}' diff --git a/tasks/generate.yml b/tasks/generate.yml index c5a2760..c0a8826 100644 --- a/tasks/generate.yml +++ b/tasks/generate.yml @@ -32,11 +32,14 @@ group: docker mode: 0640 when: > - geth_account_addr is defined and geth_account_json is defined and geth_account_json != "" - name: Geth | Generate account + when: > + geth_account_json is not defined and + geth_account_addr is not defined and + not account_file.stat.exists block: - name: Geth | Generate account JSON docker_container: @@ -58,21 +61,26 @@ file_type: file register: found_account_files - - name: Geth | Rename generated account file - command: 'mv {{ found_account_files.files[0].path }} {{ geth_account_json_file }}' + - name: Geth | Symlink generated account file + file: + src: '{{ found_account_files.files[0].path }}' + dest: '{{ geth_account_json_file }}' + owner: dockremap + group: docker + state: link - name: Geth | Save account address slurp: src: '{{ geth_account_json_file }}' register: geth_account - - - name: Geth | Extract account address + + - name: Geth | Extract account JSON set_fact: - geth_account_addr: '{{ (geth_account.content | b64decode | from_json)["address"] }}' - when: > - geth_account_json is not defined and - geth_account_addr is not defined and - account_file.stat.exists == False + geth_account_json: '{{ (geth_account.content | b64decode | from_json) }}' + +- name: Geth | Extract account address + set_fact: + geth_account_addr: '{{ geth_account_json["address"] }}' - name: Geth | Verify account data is available assert: