---
# Mine Ethereum with GPU!

- name: Ethminer | Install Dependencies
  package: 
    name: 
      - build-essential 
      - dkms 
      - cmake 
      - perl 
      - libdbus-1-dev 
      - mesa-common-dev
    state: present
  become: true

- name: Ethminer | Add PPA
  shell: 'add-apt-repository ppa:ethereum/ethereum; apt update'
  become: true

- name: Ethminer | Install Ethereum
  package: 
    name: ethereum
    state: present
  become: true

- name: Ethminer | Clone Git Repo
  shell: 'git clone https://github.com/ethereum-mining/ethminer.git'

- name: Ethminer | Update Repo's Repos
  shell: 'cd ethminer; git submodule update --init --recursive'

- name: Ethminer | Create Build Folder
  shell: 'cd ethminer; mkdir -p build'

- name: Ethminer | cmake Flags
  shell: 'cd ethminer/build; cmake .. -DETHASHCL=ON -DETHASHCUDA=OFF -DAPICORE=ON -DBINKERN=ON -DETHDBUS=ON -DUSE_SYS_OPENCL=ON -ETHASHCPU=ON -DEVBUILD=ON'

- name: Ethminer | cmake Build
  shell: 'cd ethminer/build; cmake --build .'

- name: Ethminer | make install
  shell: 'cd /home/mfn/ethminer/build; make install'
  become: true

- name: Ethminer | Download Script
  shell: 'scp ling@leet:InstallFiles/Miners/ETH/ethminer.sh /home/mfn/; chmod 755 /home/mfn/ethminer.sh'
  become: true

- name: Ethminer | Kill Current Jobs
  shell: 'killall ethminer.sh'
  become: true

- name: Ethminer | Start Mining
  shell: 'time ethminer.sh'