env-ansible/tasks/general/acct_mgmt/provision_config.yml
Hyperling 98f24fbbef
General Fixes (#20)
* Remove redundant calls to facts.

* Must have accidentally removed miner/system thinking it was general/system.

* Add missing variable xmr_stak_cpu.

* Ignore when connection to GitHub fails.

* Telegraf agents have been hoarding resources on Debian servers. Reset job will killall should work properly now.

* Once the function sets accept, it is staying for the session. Need to unset in case `update -y` is run, cancelled, and then `update` is run.
2021-12-17 17:34:21 -06:00

270 lines
11 KiB
YAML

---
# Set up directory and files for specifying software needs rather than using hosts file.
- name: General | Account Management | Provisioning Configuration | Variables 1
set_fact:
prov_dir: "/usr/local/etc/hyperling-scm"
- name: General | Account Management | Provisioning Configuration | Variables 2
set_fact:
gen_file: "{{ prov_dir }}/general.ini"
wrk_file: "{{ prov_dir }}/workstation.ini"
mnr_file: "{{ prov_dir }}/miner.ini"
srv_file: "{{ prov_dir }}/server.ini"
- name: General | Account Management | Provisioning Configuration | Create Directory
file:
path: "{{ prov_dir }}"
state: directory
mode: '0755'
## General ##
- name: General | Account Management | Provisioning Configuration | General | Create
blockinfile:
path: "{{ gen_file }}"
block: |
;;;;;;; Available options - all require lowercase values ;;;;;;
;
; enable : Provide true for the provision to occur.
;
; user : Provide the name of the user account.
; Example: tom, jerry, kim, sarah
;
; user_desc : Provide the description of the user account.
; Example: Thomas, Jerry, Kimberly, Sarah
;
; branch : Provide the Github branch that the machine should poll.
; Example: main, dev
;
; pentesting : Set to true to install tools such as metasploit (nmap is already provided for reporting)
;
[global]
marker: '; {mark} MANAGED BY ANSIBLE | Generic Config'
state: present
create: yes
backup: yes
- name: General | Account Management | Provisioning Configuration | General | Load
set_fact:
provision: "{{ lookup('ini', 'enable file={{gen_file}} default=false') }}"
user: "{{ lookup('ini', 'user file={{gen_file}} default=ling') }}"
user_desc: "{{ lookup('ini', 'user_desc file={{gen_file}} default=Hyperling') }}"
branch: "{{ lookup('ini', 'branch file={{gen_file}} default=main') }}"
pentesting: "{{ lookup('ini', 'pentesting file={{gen_file}} default=false') }}"
- name: General | Account Management | Provisioning Configuration | General | Print
debug:
var: "{{ item }}"
loop:
- provision
- user
- user_desc
- branch
- pentesting
## Workstation ##
- name: General | Account Management | Provisioning Configuration | Workstation | Create
blockinfile:
path: "{{ wrk_file }}"
block: |
;;;;;;; Available options - all require lowercase values ;;;;;;
;
; enable : Set to true for system to be considered a workstation.
;
; coding : Set to true for installation of code editors (VSCode, PyCharm, Android Studio)
;
; editing : Set to true for installation of Audio/Video editors (Shotcut, Audacity, OBS Stdio, GIMP)
;
; gaming : Set to true for installation of gaming software (Steam, Lutris)
;
; rdp : Set to true for installation of RDP protocol
; CURRENTLY FREEBSD-ONLY
;
; vnc : Set to true for installation of VNC protocol
; UNFINISHED/UNTESTED
;
[global]
marker: '; {mark} MANAGED BY ANSIBLE | Workstation Config'
state: present
create: yes
backup: yes
- name: General | Account Management | Provisioning Configuration | Workstation | Load
set_fact:
workstation: "{{ lookup('ini', 'enable file={{wrk_file}} default=false') }}"
coding: "{{ lookup('ini', 'coding file={{wrk_file}} default=false') }}"
editing: "{{ lookup('ini', 'editing file={{wrk_file}} default=false') }}"
gaming: "{{ lookup('ini', 'gaming file={{wrk_file}} default=false') }}"
rdp: "{{ lookup('ini', 'rdp file={{wrk_file}} default=false') }}"
vnc: "{{ lookup('ini', 'vnc file={{wrk_file}} default=false') }}"
- name: General | Account Management | Provisioning Configuration | Workstation | Print
debug:
var: "{{ item }}"
loop:
- workstation
- coding
- editing
- gaming
- rdp
- vnc
## Miner ##
- name: General | Account Management | Provisioning Configuration | Miner | Create
blockinfile:
path: "{{ mnr_file }}"
block: |
;;;;;;; Available options - all require lowercase values ;;;;;;
;
; enable : Set to true for system to be considered a miner.
;
; amdgpu : Set to true for installation of AMDGPU-Pro drivers on Ubuntu (20.04 preferred)
;
; nanominer : Set to true for installation of nanominer
;
; nanominer_cpu : Set to coin code that you'd like the CPU to work on
; Valid values: xmr
;
; nanominer_cpu_pool : Set to pool organization to use for CPU mining
; Valid values: nanopool
;
; nanominer_gpu : Set to coin code that you'd like the GPU to work on
; Valid values: eth
;
; nanominer_gpus : Set to comma list of GPU devices that should be used for nanominer
; Example: 0,2,3
;
; nanominer_gpu_pool : Set to pool organization to use for GPU mining
; Valid values: nanopool etherpool f2pool
;
; eth_minhashrate : Set to minimum hashrate over 10 minutes before restarting. Can accept M for Million and K for thousand.
; Example: 100K
;
; ethminer : Set to true for installation of ethminer
; UNFINISHED/UNTESTED
;
; nvidia : Set to true for NVidia support in ethminer.
; UNFINISHED/UNTESTED
;
; xmr_stak_cpu : Set to true for istallation
; UNFINISHED/UNTESTED
;
[global]
marker: '; {mark} MANAGED BY ANSIBLE | Miner Config'
state: present
create: yes
backup: yes
- name: General | Account Management | Provisioning Configuration | Miner | Load
set_fact:
miner: "{{ lookup('ini', 'enable file={{mnr_file}} default=false') }}"
amdgpu: "{{ lookup('ini', 'amdgpu file={{mnr_file}} default=false') }}"
nanominer: "{{ lookup('ini', 'nanominer file={{mnr_file}} default=false') }}"
nanominer_cpu: "{{ lookup('ini', 'nanominer_cpu file={{mnr_file}} default=false') }}"
nanominer_cpu_pool: "{{ lookup('ini', 'nanominer_cpu_pool file={{mnr_file}} default=false') }}"
nanominer_gpu: "{{ lookup('ini', 'nanominer_gpu file={{mnr_file}} default=false') }}"
nanominer_gpus: "{{ lookup('ini', 'nanominer_gpus file={{mnr_file}} default=false') }}"
nanominer_gpu_pool: "{{ lookup('ini', 'nanominer_gpu_pool file={{mnr_file}} default=false') }}"
eth_minhashrate: "{{ lookup('ini', 'eth_minhashrate file={{mnr_file}} default=false') }}"
ethminer: "{{ lookup('ini', 'ethminer file={{mnr_file}} default=false') }}"
nvidia: "{{ lookup('ini', 'nvidia file={{mnr_file}} default=false') }}"
xmr_stak_cpu: "{{ lookup('ini', 'xmr_stak_cpu file={{mnr_file}} default=false') }}"
- name: General | Account Management | Provisioning Configuration | Miner | Print
debug:
var: "{{ item }}"
loop:
- miner
- amdgpu
- nanominer
- nanominer_cpu
- nanominer_cpu_pool
- nanominer_gpu
- nanominer_gpus
- nanominer_gpu_pool
- eth_minhashrate
- ethminer
- nvidia
- xmr_stak_cpu
## Server ##
- name: General | Account Management | Provisioning Configuration | Server | Create
blockinfile:
path: "{{ srv_file }}"
block: |
;;;;;;; Parameters ;;;;;;
;
; enable : Set to true for system to be considered a server.
;
; domain : Set to the domain which gives the server its FQDN.
; Example: hyperling.com
;
; onlyoffice : Set to true for this server to be configured as an OnlyOffice server.
;
; grafana : Set to true for this server to be configured as an Grafana web server.
;
; influxdb1 : Set to true for this server to be configured as an Influx 1 DB server.
;
; influxdb2 : Set to true for this server to be configured as an Influx 2 DB + web server.
;
; certbot : Set to true to add cron job for `certbot renew`.
;
; hugo : Set to true to install HUGO static website generator.
;
; gitlab : ee - Installs Enterprise Edition Free Tier. Basically CE with an easier upgrade path for Paid Features.
; ce - Installs Community Edition. Excludes paid features if you'll never use them. Supposedly difficult to move to EE.
; Example: ce
;
; gitlab_url : The URL prefix for the server. Using 'http://mygitlabserver' would result in "http://mygitlabserver.((domain))".
; Regardless of whether you choose http or https, the Certbot config will be skipped since the maintainer uses a reverse proxy.
; Example: https://gitlab
;
[global]
marker: '; {mark} MANAGED BY ANSIBLE | Server Config'
state: present
create: yes
backup: yes
- name: General | Account Management | Provisioning Configuration | Server | Load
set_fact:
server: "{{ lookup('ini', 'enable file={{srv_file}} default=false') }}"
domain: "{{ lookup('ini', 'domain file={{srv_file}} default=hyperling.com') }}"
onlyoffice: "{{ lookup('ini', 'onlyoffice file={{srv_file}} default=false') }}"
grafana: "{{ lookup('ini', 'grafana file={{srv_file}} default=false') }}"
influxdb1: "{{ lookup('ini', 'influxdb1 file={{srv_file}} default=false') }}"
influxdb2: "{{ lookup('ini', 'influxdb2 file={{srv_file}} default=false') }}"
certbot: "{{ lookup('ini', 'certbot file={{srv_file}} default=false') }}"
hugo: "{{ lookup('ini', 'hugo file={{srv_file}} default=false') }}"
gitlab: "{{ lookup('ini', 'gitlab file={{srv_file}} default=false') }}"
gitlab_url: "{{ lookup('ini', 'gitlab_url file={{srv_file}} default=false') }}"
- name: General | Account Management | Provisioning Configuration | Server | Print
debug:
var: "{{ item }}"
loop:
- server
- domain
- onlyoffice
- grafana
- influxdb1
- influxdb2
- certbot
- hugo
- gitlab
- gitlab_url
## Exit if not turned on yet ##
- name: General | Account Management | Provisioning Configuration | Exit Check
shell: echo "Please configure the config files in {{ prov_dir }} then try again." && exit 1
when: provision != true