53 lines
1.3 KiB
YAML
53 lines
1.3 KiB
YAML
---
|
|
- name: Geth | Create keys directory
|
|
file:
|
|
path: '{{ geth_keys_path }}'
|
|
state: directory
|
|
|
|
- name: Geth | Find all account files
|
|
find:
|
|
paths: '{{ geth_keys_path }}'
|
|
patterns: 'UTC--*'
|
|
file_type: file
|
|
register: account_files
|
|
|
|
- name: Geth | Set password to be empty
|
|
copy:
|
|
dest: '{{ geth_keys_path }}/password'
|
|
content: '{{ geth_account_password | mandatory }}'
|
|
|
|
- name: Geth | Generate account
|
|
docker_container:
|
|
name: '{{ geth_cont_name }}'
|
|
image: '{{ geth_cont_image }}'
|
|
pull: true
|
|
auto_remove: yes
|
|
command: |
|
|
account new
|
|
--keystore=/keys
|
|
--password=/keys/password
|
|
volumes:
|
|
- '{{ 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
|
|
slurp:
|
|
src: '{{ account_files.files[0].path }}'
|
|
register: geth_account
|
|
|
|
- name: Geth | Extract account address
|
|
set_fact:
|
|
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 }}'
|