Skip to content

Instantly share code, notes, and snippets.

@bunchc
Created March 12, 2018 21:01
Show Gist options
  • Save bunchc/940d0621ccf7c183dbfb5315d4665261 to your computer and use it in GitHub Desktop.
Save bunchc/940d0621ccf7c183dbfb5315d4665261 to your computer and use it in GitHub Desktop.
---
# Install cgminer
- name: Installing cgminer with 2PAC support
hosts: miners
become: true
gather_facts: true
become_method: sudo
vars_files:
- vars/provision.yaml
tasks:
- name: Install packages
apt:
cache_valid_time: 86400
state: present
name: "{{ item }}"
with_items: "{{ cgminer_packages }}"
- name: Create cgminer git directory
file:
path: "{{ cgminer_build_dir }}"
state: directory
mode: 0755
- stat: path={{ cgminer_build_dir }}
register: build_dir_present
- stat: path={{ cgminer_executable }}
register: build
- name: Clone cgminer repo with 2PAC support
git:
repo: "{{ cgminer_git_repo }}"
dest: "{{ cgminer_build_dir }}"
register: git_clone
when: >
build_dir_present is defined and
build_dir_present.stat.exists and
not build.stat.exists
- name: Run cgminer prebuild
shell: CFLAGS="-O2" ./autogen.sh --enable-gekko
args:
chdir: "{{ cgminer_build_dir }}"
when: >
git_clone is defined and
git_clone and
not build.stat.exists
register: prebuild
- name: Build cgminer
make:
chdir: "{{ cgminer_build_dir }}"
params:
MAKEFLAGS: "-j 4"
when: >
prebuild is defined and
prebuild and
not build.stat.exists
- name: Copy cgminer config
copy:
src: files/cgminer.conf
dest: '{{ cgminer_config_file }}'
mode: 0644
- stat: path={{ cgminer_config_file }}
register: config_file_present
- name: Copy cgminer startup script
copy:
src: files/cgminer.sh
dest: '{{ cgminer_startup_script }}'
mode: 0755
when: >
config_file_present is defined and
config_file_present.stat.exists
- stat: path={{ cgminer_startup_script }}
register: config_startup_present
- name: Create systemd service
copy:
src: files/cgminer.service
dest: "/etc/systemd/system/cgminer.service"
when: >
config_startup_present is defined and
config_startup_present.stat.exists
- name: Start cgminer service
systemd:
name: cgminer
enabled: yes
state: started
daemon_reload: yes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment