Hosts Variable Refactor, User Name Refactor, Metasploit, Brave on Fedora, Aliases (#19)

* Add Brave to Fedora (DNF).

* First attempt to add metasploit installer.

* Fix check for Linux and macOS to use System, not Distro.

* Add more memorable aliases for msfconsole.

* Telegraf is attemping to install doube-time since hosts match both localhost and hostname.

* Add missing pipe.

* Attempt to fix flatpak play no longer being able to find user_ling var. Don't see anything in the dev branch which would have changed this behavior though.

* Add note for future removal.

* Use general gather for all groups. Move user variables to it.

* Feodra Workstation succeeds now! Add newline to end of file.

* First attempt at doing host variables via local files.

* Try using ini as lookup.

* Remove "-" typo.

* Add an initial gather even though it may not have all values properly populated on a machine's first run.

* Fix typo in ignore.

* Try default values.

* Try defaults without quotes.

* Add a section header. Add a default back.

* Rename section to global.

* Add workstation provision file. Change variables to require true. Only load config file if hosts is not being used.

* Put flags back on Dell so that programs are not removed while configuring files.

* Add provision config read to workstation.

* Go ahead and force config files for hosts. Only affects dev branch until PR. Start making miner and server files.

* Change {{}} to (()) in comments to avoid undefined variable error.

* Attempt to modify existing task groups instead of moving all tasks to one large group.

* Try to use blocks.

* Name blocks and remove redundant calls.

* Do the bare minimum for miner and server so the variables are at least defined.

* Ensure Server and Miner look at their own files.

* Test how block variables are handled.

* Are the variables true Booleans, not strings??

* Change exits to tests so we can see which ones work.

* Add more tests.

* Add the test results.

* Add config_dir for plays to use when making any config files.

* Move provision config dir.

* Add results of test.

* Remove the exit. Fix the blocks' whens.

* Do provision after starting, that way all facts exist.

* Fix all "true"'s.

* Adjust variable checks for provision_config changes.

* Change gui to wrk. Add aliases to cat files.

* Comment entire hosts file.

* Add localhost,

* Try localhost rather than host file group.

* Fix typo in "prov_dir".

* Add newline to end of file.

* Add newline to end of file.

* Add newline to end of file.

* Debug variable. Should be getting set but receiving errors on Fedora.

* Add newline to end of file.

* Fix debug property, var not name.

* Fix show-config. Change show-config-all to only hit active files, not backups.

* Uncomment commented workstation.

* Add commands to edit files.

* Attempt to fix gitlab installer variables.

* Attempt to fix gitlab play variable.

* Replacing `ling` for `{{ user }}`.

* Remove TODO.

* Remove `config_dir` and move provision config back near top.

* `user_root` is not needed, already moved to /usr/local/etc/.

* Add value for running anything at all. This allows user to set up files before first run.

* Reduce the check frequency,

* Ensure files are printed in correct order. Also add a newline between each.

* Only send file if it exists, and then remove it if it sends successfully.

* Always set the destination variables.

* Only run the scp for systems without sshfs. Forgot that system variables were shared between the two, and do not want to scp the files to themselves then delete the files from the mount.
This commit is contained in:
2021-12-05 18:08:51 -06:00
committed by GitHub
parent b3b2874ad3
commit 8e4247fd58
49 changed files with 735 additions and 361 deletions

View File

@ -9,4 +9,4 @@
loop:
- sudo
- video
- render
- render

View File

@ -13,4 +13,4 @@
ignore_errors: yes
- name: General | Account Management | Keys | Root | Copy SSH to 1337
shell: ssh-copy-id -i /root/.ssh/id_rsa {{ leet_ssh }}
shell: ssh-copy-id -i /root/.ssh/id_rsa {{ leet_ssh }}

View File

@ -66,4 +66,4 @@
- name: General | Account Management | Mounts | Refresh Variable leet_drive_details
stat:
path: "{{ leet_drive }}/Temp/ansible"
register: leet_drive_details
register: leet_drive_details

View File

@ -0,0 +1,262 @@
---
# 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
; NOT IMPLEMENTED YET
;
[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
;
; nvidia : Set to true for NVidia support in ethminer.
;
[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') }}"
- 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
## 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

View File

@ -15,4 +15,4 @@
dest: "{{ sudoers_install_dir }}"
owner: root
group: "{{ root_group }}"
mode: 0440
mode: 0440

View File

@ -5,11 +5,11 @@
- name: General | Account Management | Users | Use BASH (Default)
set_fact:
ling_shell: "{{ bash_exec.stdout }}"
user_shell: "{{ bash_exec.stdout }}"
- name: General | Account Management | Users | Use ZSH (Arch+Manjaro)
set_fact:
ling_shell: "{{ zsh_exec.stdout }}"
user_shell: "{{ zsh_exec.stdout }}"
when: ansible_distribution == "Archlinux"
@ -38,23 +38,23 @@
- name: General | Account Management | Users | Hyperling
user:
name: ling
comment: Hyperling
name: "{{ user }}"
comment: "{{ user_desc }}"
groups:
- sudo
- video
- render
append: yes
shell: "{{ ling_shell }}"
shell: "{{ user_shell }}"
create_home: yes
generate_ssh_key: yes
register: user_ling
register: user_user
- name: General | Account Management | Users | Hyperling | Test Logging In
shell: "echo SUCCESS"
args:
executable: "{{ ling_shell }}"
become_user: ling
executable: "{{ user_shell }}"
become_user: "{{ user }}"
## Folders ##
@ -76,14 +76,14 @@
state: directory
mode: '0755'
loop:
- "{{ user_ling.home }}/bin"
- "{{ user_ling.home }}/LBRY"
- "{{ user_ling.home }}/TRASH"
become_user: ling
when: user_ling.home != ""
- "{{ user_user.home }}/bin"
- "{{ user_user.home }}/LBRY"
- "{{ user_user.home }}/TRASH"
become_user: "{{ user }}"
when: user_user.home != ""
- name: General | Account Management | Users | Folders | Home Directories 700
shell: "chmod 700 {{ user_ling.home }}/../*"
shell: "chmod 700 {{ user_user.home }}/../*"
## Files ##
@ -153,6 +153,21 @@
bye: |
alias bye="{{ shutdown_command }}"
alias goodbye="update -y && bye"
metasploit: |
alias metasploit="msfconsole"
alias hax="metasploit"
show_config: |
alias show-config-gen="cat {{ gen_file }}"
alias show-config-wrk="cat {{ wrk_file }}"
alias show-config-mnr="cat {{ mnr_file }}"
alias show-config-srv="cat {{ srv_file }}"
alias show-config-all="show-config-gen && echo '' && show-config-wrk && echo '' && show-config-mnr && echo '' && show-config-srv"
alias show-config="show-config-all"
edit_config: |
alias edit-config-gen="sudo $EDITOR {{ gen_file }}"
alias edit-config-wrk="sudo $EDITOR {{ wrk_file }}"
alias edit-config-mnr="sudo $EDITOR {{ mnr_file }}"
alias edit-config-srv="sudo $EDITOR {{ srv_file }}"
- name: General | Account Management | Users | Files | Common Variable
set_fact:
@ -171,6 +186,9 @@
{{ editor }}
{{ init_aliases }}
{{ bye }}
{{ metasploit }}
{{ show_config }}
{{ edit_config }}
- name: General | Account Management | Users | Files | .bashrc
blockinfile:
@ -184,9 +202,9 @@
backup: yes
loop:
- "{{ user_root.home }}"
- "{{ user_ling.home }}"
- "{{ user_user.home }}"
ignore_errors: yes
when: user_root.home != "" and user_ling.home != ""
when: user_root.home != "" and user_user.home != ""
- name: General | Account Management | Users | Files | .zshrc
blockinfile:
@ -200,6 +218,6 @@
backup: yes
loop:
- "{{ user_root.home }}"
- "{{ user_ling.home }}"
- "{{ user_user.home }}"
ignore_errors: yes
when: user_root.home != "" and user_ling.home != ""
when: user_root.home != "" and user_user.home != ""

View File

@ -5,7 +5,7 @@
cron:
user: ansible
name: "Ansible Sync"
minute: "*/15"
minute: "*/30"
job: "sudo {{ ansible_pull_exec.stdout }} -o -U https://github.com/Hyperling/ansible.git --checkout {{ branch }}"
state: present
disabled: no
@ -33,7 +33,7 @@
user: ansible
name: "{{ item.name }}"
minute: "05,20,35,50"
job: "sudo scp {{ item.src }} {{ item.dest }}"
job: "ls {{ item.src }} 2>/dev/null 1>&2 && sudo scp {{ item.src }} {{ item.dest }} && sudo sh -c 'rm -rfv {{ item.src }}'"
state: present
disabled: no
loop:
@ -55,4 +55,4 @@
- { name: 'Heartbeat Report' }
- { name: 'Lynis Report' }
- { name: 'NMap Report' }
when: leet_drive_details.stat.exists
when: leet_drive_details.stat.exists

View File

@ -28,4 +28,4 @@
job: "As a wise man once said, I'm disabled."
state: absent
disabled: yes
when: leet_drive_details.stat.exists
when: leet_drive_details.stat.exists

View File

@ -2,6 +2,11 @@
# Tasks related to finishing ansible-pull
# EG: End timer, start conflicting jobs, etc
- name: General | Finish | Ansible Pull Report | Debug
debug:
var: leet_drive_details
when: leet_drive_details is defined
- name: General | Finish | Ansible Pull Report | Finish File
shell: "echo 'FINISH' >> {{ ansible_pull_report }}"
when: leet_drive_details.stat.exists

View File

@ -25,7 +25,7 @@
path: "{{ user_root.home }}/bin/push.sh"
block: |
# 20210215 - Make life even easier!
ssh ling@leet "cd Code/Ansible/ansible-pull; git push"
ssh {{ user }}@leet "cd Code/Ansible/ansible-pull; git push"
marker: '{mark}'
marker_begin: "#!{{ bash_exec.stdout }}"
marker_end: "exit 0"

View File

@ -3,7 +3,7 @@
- name: General | Scripts | User | scm.sh
blockinfile:
path: "{{ user_ling.home }}/bin/scm.sh"
path: "{{ user_user.home }}/bin/scm.sh"
block: |
# 20210211 - Make life easier!
push.sh
@ -16,16 +16,16 @@
- name: General | Scripts | User | scm.sh Permissions
file:
path: "{{ user_ling.home }}/bin/scm.sh"
path: "{{ user_user.home }}/bin/scm.sh"
mode: '0755'
- name: General | Scripts | User | push.sh
blockinfile:
path: "{{ user_ling.home }}/bin/push.sh"
path: "{{ user_user.home }}/bin/push.sh"
block: |
# 20210215 - Make life even easier!
ssh ling@leet "cd Code/Ansible/ansible-pull; git push"
ssh {{ user }}@leet "cd Code/Ansible/ansible-pull; git push"
marker: '{mark}'
marker_begin: "#!{{ bash_exec.stdout }}"
marker_end: "exit 0"
@ -34,13 +34,13 @@
- name: General | Scripts | User | push.sh Permissions
file:
path: "{{ user_ling.home }}/bin/push.sh"
path: "{{ user_user.home }}/bin/push.sh"
mode: '0755'
- name: General | Scripts | User | scm-dev.sh
blockinfile:
path: "{{ user_ling.home }}/bin/scm-dev.sh"
path: "{{ user_user.home }}/bin/scm-dev.sh"
block: |
# 20210713 - Make life easier for development!
@ -66,5 +66,5 @@
- name: General | Scripts | User | scm-dev.sh Permissions
file:
path: "{{ user_ling.home }}/bin/scm-dev.sh"
path: "{{ user_user.home }}/bin/scm-dev.sh"
mode: '0755'

View File

@ -0,0 +1,12 @@
---
# Install Metasploit Framework
- name: General | Software | Metasploit | Install
shell: "{{ item }}"
loop:
- curl https://raw.githubusercontent.com/rapid7/metasploit-omnibus/master/config/templates/metasploit-framework-wrappers/msfupdate.erb > msfinstall
- chmod 755 msfinstall
- mkdir -p /usr/local/bin/
- mv ./msfinstall /usr/local/bin/msfinstall
- msfinstall
when: ansible_system in ("Linux", "Darwin")

View File

@ -60,7 +60,7 @@
create: no
backup: yes
loop:
- { "key": '^[\#]?AllowUsers', "value": 'AllowUsers ling'}
- { "key": '^[\#]?AllowUsers', "value": 'AllowUsers {{ user }}'}
- { "key": '^[\#]?PermitRootLogin', "value": 'PermitRootLogin no'}
- { "key": '^[\#]?AllowTcpForwarding', "value": 'AllowTcpForwarding no'}
- { "key": '^[\#]?ClientAliveInterval', "value": 'ClientAliveInterval 60'}
@ -84,7 +84,7 @@
create: no
backup: yes
loop:
- { "key": '^[\#]?AllowUsers', "value": 'AllowUsers root ling'}
- { "key": '^[\#]?AllowUsers', "value": 'AllowUsers root {{ user }}'}
- { "key": '^[\#]?PermitRootLogin', "value": 'PermitRootLogin yes'}
- { "key": '^[\#]?MaxSessions', "value": 'MaxSessions 5'}
when: "'pve' in ansible_kernel"
@ -94,4 +94,4 @@
name: "{{ sshd }}"
pattern: "{{ sshd_pattern }}"
state: reloaded
enabled: yes
enabled: yes

View File

@ -14,4 +14,4 @@
- name: General | Start | Ansible Pull Report | Add Date Entry
shell: "date >> {{ ansible_pull_report }}"
when: leet_drive_details.stat.exists
when: leet_drive_details.stat.exists

View File

@ -30,4 +30,4 @@
- name: General | Tests | Lynis | Make Report Readable
file:
path: "{{ lynis_report }}"
mode: '0777'
mode: '0777'

View File

@ -10,4 +10,4 @@
- name: General | Tests | nmap | Make Viewable
file:
path: "{{ nmap_report }}"
mode: '0777'
mode: '0777'