infra-role-geth/tasks/container.yml

72 lines
2.3 KiB
YAML

---
- name: Geth | Create the container
docker_container:
name: '{{ geth_cont_name }}'
image: '{{ geth_cont_image }}'
user: root
pull: true
restart_policy: '{{ cont_restart_policy }}'
state: '{{ cont_state }}'
recreate: '{{ cont_recreate }}'
restart: '{{ cont_restart }}'
# some limits due to statusd hogging resources
memory: '{{ geth_cont_mem_limit }}m'
memory_swap: '{{ geth_cont_swap_limit }}m'
ports:
- '{{ geth_port }}:{{ geth_port }}/tcp'
- '{{ geth_port }}:{{ geth_port }}/udp'
- '{{ geth_rpc_addr }}:{{ geth_rpc_port }}:{{ geth_rpc_port }}'
labels:
# These are just for documentation
org.ethereum.geth.network_name: '{{ geth_network_name }}'
command: |
{% if geth_network_name != "mainnet" %}
--{{ geth_network_name }}
{% endif %}
{% if geth_v5disc_enabled %}
--v5disc
{% endif %}
--syncmode={{ geth_sync_mode }}
{% if geth_sync_mode != 'light' %}
--light.serve={{ geth_light_serv }}
{% endif %}
{% if geth_miner_enabled %}
--mine
--miner.threads="{{ geth_miner_threads }}"
--miner.etherbase="{{ geth_miner_account | mandatory }}"
{% endif %}
{% if geth_whisper_enabled %}
--shh
--shh.pow={{ geth_whisper_pow }}
{% endif %}
{% if geth_metrics_enabled %}
--metrics
{% endif %}
{% if geth_cache_size %}
--cache={{ geth_cache_size }}
{% endif %}
--nousb
--extradata={{ geth_extra_data }}
--verbosity={{ geth_log_level_id }}
--maxpeers={{ geth_max_peers }}
--maxpendpeers="{{ geth_max_pend_peers }}"
--port={{ geth_port }}
--nat=extip:{{ geth_public_addr }}
--unlock={{ geth_account_addr }}
--allow-insecure-unlock
--datadir=/data
--password=/keys/account.pass
--keystore=/keys
{% if geth_rpc_enabled %}
--http
--http.addr=0.0.0.0
--http.port={{ geth_rpc_port }}
--http.vhosts={{ geth_aliases | join(",") }}
--http.api={{ geth_rcp_api }}
--ipcpath={{ geth_ipc_path }}
{% endif %}
volumes:
- '{{ geth_cont_vol }}/keys:/keys:rw'
# WARNING: This assumes /data is mounted, see bootstrap role
- '{{ geth_data_path }}:/data:rw'