2019-04-26 09:54:14 +00:00
|
|
|
---
|
2019-05-27 14:06:01 +00:00
|
|
|
- name: Geth | Create container directories
|
2019-04-26 09:54:14 +00:00
|
|
|
file:
|
2019-05-27 13:47:53 +00:00
|
|
|
path: '{{ item }}'
|
|
|
|
owner: dockremap
|
|
|
|
group: docker
|
2019-04-26 09:54:14 +00:00
|
|
|
state: directory
|
2019-05-27 13:50:51 +00:00
|
|
|
recurse: true
|
2019-05-27 13:47:53 +00:00
|
|
|
with_items:
|
|
|
|
- '{{ geth_data_path }}'
|
|
|
|
- '{{ geth_keys_path }}'
|
2019-04-26 09:54:14 +00:00
|
|
|
|
2019-04-26 13:24:37 +00:00
|
|
|
- name: Geth | Check if account file exists
|
|
|
|
stat:
|
|
|
|
path: '{{ geth_account_json_file }}'
|
|
|
|
register: account_file
|
|
|
|
when: geth_account_json is not defined
|
2019-04-26 09:54:14 +00:00
|
|
|
|
2019-04-26 13:24:37 +00:00
|
|
|
- name: Geth | Create password file
|
2019-04-26 09:54:14 +00:00
|
|
|
copy:
|
2019-04-26 13:24:37 +00:00
|
|
|
dest: '{{ geth_account_pass_file }}'
|
|
|
|
content: '{{ geth_account_pass | mandatory }}'
|
|
|
|
owner: dockremap
|
|
|
|
group: docker
|
2019-04-26 10:45:42 +00:00
|
|
|
mode: 0600
|
2019-04-26 09:54:14 +00:00
|
|
|
|
2019-04-26 13:24:37 +00:00
|
|
|
- name: Geth | Write account JSON
|
|
|
|
copy:
|
|
|
|
dest: '{{ geth_account_json_file }}'
|
2019-04-26 13:45:33 +00:00
|
|
|
content: '{{ geth_account_json | mandatory }}'
|
2019-04-26 13:24:37 +00:00
|
|
|
owner: dockremap
|
|
|
|
group: docker
|
|
|
|
mode: 0640
|
|
|
|
when: >
|
2019-04-26 13:45:33 +00:00
|
|
|
geth_account_addr is defined and
|
2019-04-26 13:24:37 +00:00
|
|
|
geth_account_json is defined and
|
2019-04-26 13:45:33 +00:00
|
|
|
geth_account_json != ""
|
2019-04-26 09:54:14 +00:00
|
|
|
|
2019-04-26 13:24:37 +00:00
|
|
|
- name: Geth | Generate account
|
|
|
|
block:
|
|
|
|
- name: Geth | Generate account JSON
|
|
|
|
docker_container:
|
|
|
|
name: '{{ geth_cont_name }}'
|
|
|
|
image: '{{ geth_cont_image }}'
|
|
|
|
pull: true
|
|
|
|
auto_remove: yes
|
|
|
|
command: |
|
|
|
|
account new
|
|
|
|
--keystore=/keys
|
|
|
|
--password=/keys/account.pass
|
|
|
|
volumes:
|
|
|
|
- '{{ geth_cont_vol }}/keys:/keys:rw'
|
|
|
|
|
|
|
|
- name: Geth | Find newly generate account file
|
|
|
|
find:
|
|
|
|
paths: '{{ geth_keys_path }}'
|
|
|
|
patterns: 'UTC--*'
|
|
|
|
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 }}'
|
2019-04-26 10:33:57 +00:00
|
|
|
|
2019-04-26 13:24:37 +00:00
|
|
|
- name: Geth | Save account address
|
|
|
|
slurp:
|
|
|
|
src: '{{ geth_account_json_file }}'
|
|
|
|
register: geth_account
|
|
|
|
|
|
|
|
- name: Geth | Extract account address
|
|
|
|
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
|
2019-04-26 09:54:14 +00:00
|
|
|
|
2019-04-26 13:24:37 +00:00
|
|
|
- name: Geth | Verify account data is available
|
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- geth_account_json is defined
|
|
|
|
- geth_account_addr is defined
|
2019-04-26 10:33:57 +00:00
|
|
|
|
|
|
|
- name: Geth | Save account address to file
|
|
|
|
copy:
|
2019-04-26 13:24:37 +00:00
|
|
|
dest: '{{ geth_account_addr_file }}'
|
|
|
|
content: '{{ geth_account_addr | mandatory }}'
|
|
|
|
owner: dockremap
|
|
|
|
group: docker
|