2021-02-15 18:23:03 -06:00

136 lines
3.6 KiB
YAML

---
# Nanominer from nanopool.org
# Good documentation that might help with how to do variables.
# https://docs.ansible.com/ansible/latest/user_guide/playbooks_tests.html
## Installation ##
- name: Miner | Software | Nanominer | Installation | Create Home
shell: "mkdir -p {{ nanominer_home }}"
become_user: mfn
- name: Miner | Software | Nanominer | Installation | Download Tarball
shell: "scp {{ file_server }}:{{ nanominer_tar_remote }} {{ nanominer_tar_local }}; chown mfn {{ nanominer_tar_local }}"
- name: Miner | Software | Nanominer | Installation | Extract Tarball
shell: "tar -xvf {{ nanominer_tar_local }}"
args:
chdir: "{{ nanominer_home }}"
become_user: mfn
## Configuration ##
# Delete Old Config #
- name: Miner | Software | Nanominer | Configuration | Reset
shell: "mv {{ nanominer_config }} ~/TRASH/"
ignore_errors: yes
# CPU #
- name: Miner | Software | Nanominer | Configuration | CPU Header Info
blockinfile:
path: "{{ nanominer_config }}"
block: |
[{{ item.algorithm }}]
wallet = {{ item.wallet }}
watchdog = true
rigName = {{ ansible_hostname }}
logpath = {{ nanominer_logs }}
webPassword = {{ ansible_hostname }}
useSSL = true
marker: '; {mark} MANAGED BY ANSIBLE - CPU Headers'
state: "{{ item.state }}"
create: yes
loop:
- { "algorithm": "RandomX", "wallet": '{{ wallet_xmr }}', "state": "{{ (nanominer_cpu == 'xmr') | ternary('present', 'absent') }}"}
become_user: mfn
when: nanominer_cpu is defined
- name: Miner | Software | Nanominer | Configuration | CPU Pools
lineinfile:
path: "{{ nanominer_config }}"
line: "pool{{item.priority}} = {{ item.name }}"
state: present
create: no
loop: "{{ cpu_pool }}"
become_user: mfn
when: nanominer_cpu is defined
# Add Spacing #
- name: Miner | Software | Nanominer | Configuration | Spacing
blockinfile:
path: "{{ nanominer_config }}"
block: |
;
marker: ';'
state: "{{ item.state }}"
create: no
become_user: mfn
when: nanominer_config is file
# GPU #
- name: Miner | Software | Nanominer | Configuration | GPU Header Info
blockinfile:
path: "{{ nanominer_config }}"
block: |
[{{ item.algorithm }}]
wallet = {{ item.wallet }}
watchdog = true
rigName = {{ ansible_hostname }}
logpath = {{ nanominer_logs }}
webPassword = {{ ansible_hostname }}
devices = {{ nanominer_gpus }}
useSSL = true
marker: '; {mark} MANAGED BY ANSIBLE - GPU Headers'
state: "{{ item.state }}"
create: yes
loop:
- { "algorithm": "Ethash", "wallet": '{{ wallet_eth }}', "state": "{{ (nanominer_gpu == 'eth') | ternary('present', 'absent') }}"}
become_user: mfn
when: nanominer_gpu is defined
- name: Miner | Software | Nanominer | Configuration | Add Pools
lineinfile:
path: "{{ nanominer_config }}"
line: "pool{{item.priority}} = {{ item.name }}"
state: present
create: no
loop: "{{ gpu_pool }}"
become_user: mfn
when: nanominer_gpu is defined
## Executable ##
- name: Miner | Software | Nanominer | Executable | Create
blockinfile:
path: "{{ nanominer_script }}"
block: |
# 2021-02-15 - Automate nanominer script creation.
date
whoami
pwd
time {{ nanominer_exec }} {{ nanominer_config }}
marker: '{mark}'
marker_begin: "#!{{ bash_exec.stdout }}"
marker_end: "exit 0"
state: present
create: yes
become_user: mfn
## Permissions ##
- name: Miner | Software | Nanominer | Permissions
shell: "chmod -R 755 {{ user_mfn.home }}/nanominer*"
become_user: mfn