Compare commits

...
6 Commits
8 changed files with 285 additions and 243 deletions

No files matched your search

+1
View File
@@ -10,6 +10,7 @@ skip_list:
- yaml[comments]
- yaml[commas]
- var-naming[pattern]
- yaml[braces]
warn_list:
- literal-compare
+6 -151
View File
@@ -9,147 +9,9 @@
tasks:
####### Lock #######
# Ensure a process is not already running.
- name: Main | Lock
block:
- name: Main | Lock | Check
ansible.builtin.include_tasks: tasks/general/tests/lock_check.yml
- name: Main | Lock | Create
ansible.builtin.include_tasks: tasks/general/tests/lock_create.yml
####### Gather #######
# Load facts for all systems.
- name: Main | Gather
block:
- name: Main | Gather | Facts
ansible.builtin.include_tasks: facts/general/gather.yml
- name: Main | Gather | Account Management
ansible.builtin.include_tasks: tasks/general/acct_mgmt/provision_config.yml
- name: Main | Gather | System
ansible.builtin.include_tasks: facts/general/system.yml
- name: Main | Gather | Package
ansible.builtin.include_tasks: facts/general/package.yml
- name: Main | Gather | Service
ansible.builtin.include_tasks: facts/general/service.yml
- name: Main | Gather | User
ansible.builtin.include_tasks: facts/general/user.yml
- name: Main | Gather | Internet Check
ansible.builtin.include_tasks: tasks/general/tests/internet_check.yml
####### Start #######
- name: Main | Start
block:
- name: Main | Start | Notify
ansible.builtin.include_tasks: tasks/general/acct_mgmt/notify.yml
vars:
notify_message: "Provisioning Started"
when: workstation
####### NixOS #######
# Install the .nix files and do a little data setup.
- name: Main | NixOS Setup
block:
- name: Main | NixOS Setup | NixOS
ansible.builtin.include_tasks: tasks/general/software/nixos.yml
# TBD if we are going to use this many, then just have IF statements
# and use blocks within the General area for NixOS vs not-NixOS.
- name: Main | NixOS Setup | Swap
ansible.builtin.include_tasks: tasks/general/software/swap.yml
- ansible.builtin.include_tasks: tasks/general/acct_mgmt/groups.yml
- ansible.builtin.include_tasks: tasks/general/acct_mgmt/users.yml
- ansible.builtin.include_tasks: tasks/general/acct_mgmt/sudo.yml
- ansible.builtin.include_tasks: tasks/general/acct_mgmt/doas.yml
- ansible.builtin.include_tasks: tasks/general/scripts/root.yml
- ansible.builtin.include_tasks: tasks/general/scripts/user.yml
- ansible.builtin.include_tasks: tasks/general/scripts/install.yml
- ansible.builtin.include_tasks: tasks/general/cron/ansible.yml
# psutil does not work in NixOS. Cannot figure out how to fix it. Maybe
# time to start looking into home-manager but still not wanting to
# maintain two different GNOME setups. HMMMM!
- ansible.builtin.include_tasks: tasks/workstation/shared/settings/gnome.yml
when: workstation
# Try including these. Really need to get NixOS working with the rest!
#- ansible.builtin.include_tasks: tasks/general/software/telegraf.yml # "Could not find a module for unknown.""
- ansible.builtin.include_tasks: tasks/general/tests/services.yml
- ansible.builtin.include_tasks: tasks/general/tests/lynis.yml
- ansible.builtin.include_tasks: tasks/general/tests/nmap.yml
- name: NixOS | Complete
ansible.builtin.meta: end_play
when: ansible_distribution == "NixOS"
####### General #######
# Basic setup for all enabled systems.
- name: Main | General Setup
block:
- name: Main | General Setup | Swap
ansible.builtin.include_tasks: tasks/general/software/swap.yml
- name: Main | General Setup | runit
ansible.builtin.include_tasks: tasks/general/software/runit.yml
- name: Main | General Setup | Packages
ansible.builtin.include_tasks: tasks/general/software/packages.yml
when: internet
- name: Main | General Setup | Services
ansible.builtin.include_tasks: tasks/general/software/services.yml
- name: Main | General Setup | Sendmail
ansible.builtin.include_tasks: tasks/general/software/sendmail.yml
when: ansible_system == "FreeBSD"
and internet
- ansible.builtin.include_tasks: tasks/general/software/aur.yml
when: internet and ansible_pkg_mgr == "pacman"
# Gather again in case missing programs have now been installed.
- ansible.builtin.include_tasks: facts/general/gather.yml
- ansible.builtin.include_tasks: tasks/general/settings/keyboard.yml
- ansible.builtin.include_tasks: tasks/general/acct_mgmt/groups.yml
- ansible.builtin.include_tasks: tasks/general/acct_mgmt/users.yml
- ansible.builtin.include_tasks: tasks/general/acct_mgmt/sudo.yml
- ansible.builtin.include_tasks: tasks/general/acct_mgmt/doas.yml
when: internet
- ansible.builtin.include_tasks: tasks/general/software/env-shared.yml
when: internet
- ansible.builtin.include_tasks: tasks/general/scripts/root.yml
- ansible.builtin.include_tasks: tasks/general/scripts/user.yml
- ansible.builtin.include_tasks: tasks/general/scripts/install.yml
- ansible.builtin.include_tasks: tasks/general/cron/ansible.yml
# TODO Need to refactor. Maybe tasks/general/cron/freebsd.yml
- ansible.builtin.include_tasks: tasks/workstation/freebsd/cron/ansible.yml
when: ansible_system == "FreeBSD"
- ansible.builtin.include_tasks: tasks/general/software/metasploit.yml
when: internet
when: provision
####### Header #######
- name: Main | Header
ansible.builtin.include_tasks: tasks/header.yml
####### Workstations #######
@@ -345,13 +207,6 @@
- ansible.builtin.include_tasks: tasks/general/tests/nmap.yml
####### Finish #######
- name: Main | Finish
block:
- name: Main | Finish | Notify
ansible.builtin.include_tasks: tasks/general/acct_mgmt/notify.yml
vars:
notify_message: "Provisioning Finished"
- ansible.builtin.include_tasks: tasks/general/tests/lock_remove.yml
####### Footer #######
- name: Main | Footer
ansible.builtin.include_tasks: tasks/footer.yml
+9 -3
View File
@@ -6,6 +6,7 @@
DIR="$(dirname -- "${BASH_SOURCE[0]}")"
PROG="$(basename -- "${BASH_SOURCE[0]}")"
LOCAL="$DIR/local.yml"
TEST="$DIR/test.yml"
URL="https://git.hyperling.com/me/env-ansible"
if [[ -z $BRANCH ]]; then
export BRANCH="main"
@@ -31,7 +32,7 @@ branch=""
function usage {
cat <<- EOF
$PROG [-l] [-b branch_name] [-g] [-w] [-s] [-f] [-h]
$PROG [-l | -t] [-b branch_name] [-g] [-w] [-s] [-f] [-h]
Program to initialize synchronization with Hyperling's Ansible configuration.
$URL
@@ -39,6 +40,7 @@ function usage {
-l : Run the local playbook associated with this $PROG.
This is helpful for development or just saving bandwidth.
It also provides prettier colors than the plaintext from ansible-pull. ;)
-t : Run the test playbook which has a much smaller set of includes.
-b branch_name : Download and run a specific branch. Default is $BRANCH.
-g : Enable the General config with test contents.
-w : Enable the Workstation config with test contents.
@@ -52,9 +54,10 @@ function usage {
## Parameter Parsing ##
while getopts ":lb:gwsfh" arg; do
while getopts ":ltb:gwsfh" arg; do
case $arg in
l) local="Y" && echo "Running $LOCAL as the playbook." ;;
t) test="Y" && echo "Running $TEST as the playbook." ;;
b) branch="$OPTARG" && echo "Using branch $branch instead of $BRANCH." ;;
g) create_general="Y" && echo "Generating test '$general_config'." ;;
w) create_workstation="Y" && echo "Generating test '$workstation_config'." ;;
@@ -232,7 +235,10 @@ echo " "
echo "Provisioning Ansible..."
status=""
if [[ "$local" == "Y" ]]; then
if [[ "$test" == "Y" ]]; then
sudo ansible-playbook $TEST
status=$?
elif [[ "$local" == "Y" ]]; then
sudo ansible-playbook $LOCAL
status=$?
else
+12
View File
@@ -0,0 +1,12 @@
---
####### Footer #######
- name: Footer
block:
- name: Footer | Notify
ansible.builtin.include_tasks: tasks/general/acct_mgmt/notify.yml
vars:
notify_message: "Provisioning Finished"
- ansible.builtin.include_tasks: tasks/general/tests/lock_remove.yml
+2 -2
View File
@@ -294,7 +294,7 @@
; Automatically choose and pull the models to use based on system
; resources. Otherwise leaves images alone but still handles config.
;
; zero (default=false)
; zero (default=true)
; Install and enable the Zeroclaw web daemon, a minimalistic interface
; for many models and providers with negligible resource usage. Also
; installs the CLI tool zerocode as an alternative to the web GUI.
@@ -371,7 +371,7 @@
# LLMs
ollama_enabled: "{{ lookup('ini', 'ollama file={{wrk_file}} default=true' ) | bool }}"
manage_models: "{{ lookup('ini', 'manage_models file={{wrk_file}} default=true' ) | bool }}"
zeroclaw_enabled: "{{ lookup('ini', 'zero file={{wrk_file}} default=false') | bool }}"
zeroclaw_enabled: "{{ lookup('ini', 'zero file={{wrk_file}} default=true ') | bool }}"
open_webui_enabled: "{{ lookup('ini', 'open_webui file={{wrk_file}} default=false') | bool }}"
open_webui_port: "{{ lookup('ini', 'open_webui_port file={{wrk_file}} default=3000' ) | int }}"
open_webui_key: "{{ lookup('ini', 'open_webui_key file={{wrk_file}} default=yolo' ) }}"
+143
View File
@@ -0,0 +1,143 @@
---
####### Lock #######
# Ensure a process is not already running.
- name: Main | Lock
block:
- name: Main | Lock | Check
ansible.builtin.include_tasks: tasks/general/tests/lock_check.yml
- name: Main | Lock | Create
ansible.builtin.include_tasks: tasks/general/tests/lock_create.yml
####### Gather #######
# Load facts for all systems.
- name: Main | Gather
block:
- name: Main | Gather | Facts
ansible.builtin.include_tasks: facts/general/gather.yml
- name: Main | Gather | Account Management
ansible.builtin.include_tasks: tasks/general/acct_mgmt/provision_config.yml
- name: Main | Gather | System
ansible.builtin.include_tasks: facts/general/system.yml
- name: Main | Gather | Package
ansible.builtin.include_tasks: facts/general/package.yml
- name: Main | Gather | Service
ansible.builtin.include_tasks: facts/general/service.yml
- name: Main | Gather | User
ansible.builtin.include_tasks: facts/general/user.yml
- name: Main | Gather | Internet Check
ansible.builtin.include_tasks: tasks/general/tests/internet_check.yml
####### Start #######
- name: Main | Start
block:
- name: Main | Start | Notify
ansible.builtin.include_tasks: tasks/general/acct_mgmt/notify.yml
vars:
notify_message: "Provisioning Started"
when: workstation
####### NixOS #######
# Install the .nix files and do a little data setup.
- name: Main | NixOS Setup
block:
- name: Main | NixOS Setup | NixOS
ansible.builtin.include_tasks: tasks/general/software/nixos.yml
# TBD if we are going to use this many, then just have IF statements
# and use blocks within the General area for NixOS vs not-NixOS.
- name: Main | NixOS Setup | Swap
ansible.builtin.include_tasks: tasks/general/software/swap.yml
- ansible.builtin.include_tasks: tasks/general/acct_mgmt/groups.yml
- ansible.builtin.include_tasks: tasks/general/acct_mgmt/users.yml
- ansible.builtin.include_tasks: tasks/general/acct_mgmt/sudo.yml
- ansible.builtin.include_tasks: tasks/general/acct_mgmt/doas.yml
- ansible.builtin.include_tasks: tasks/general/scripts/root.yml
- ansible.builtin.include_tasks: tasks/general/scripts/user.yml
- ansible.builtin.include_tasks: tasks/general/scripts/install.yml
- ansible.builtin.include_tasks: tasks/general/cron/ansible.yml
# psutil does not work in NixOS. Cannot figure out how to fix it. Maybe
# time to start looking into home-manager but still not wanting to
# maintain two different GNOME setups. HMMMM!
- ansible.builtin.include_tasks: tasks/workstation/shared/settings/gnome.yml
when: workstation
# Try including these. Really need to get NixOS working with the rest!
#- ansible.builtin.include_tasks: tasks/general/software/telegraf.yml # "Could not find a module for unknown.""
- ansible.builtin.include_tasks: tasks/general/tests/services.yml
- ansible.builtin.include_tasks: tasks/general/tests/lynis.yml
- ansible.builtin.include_tasks: tasks/general/tests/nmap.yml
- name: NixOS | Complete
ansible.builtin.meta: end_play
when: ansible_distribution == "NixOS"
####### General #######
# Basic setup for all enabled systems.
- name: Main | General Setup
block:
- name: Main | General Setup | Swap
ansible.builtin.include_tasks: tasks/general/software/swap.yml
- name: Main | General Setup | runit
ansible.builtin.include_tasks: tasks/general/software/runit.yml
- name: Main | General Setup | Packages
ansible.builtin.include_tasks: tasks/general/software/packages.yml
when: internet
- name: Main | General Setup | Services
ansible.builtin.include_tasks: tasks/general/software/services.yml
- name: Main | General Setup | Sendmail
ansible.builtin.include_tasks: tasks/general/software/sendmail.yml
when: ansible_system == "FreeBSD"
and internet
- ansible.builtin.include_tasks: tasks/general/software/aur.yml
when: internet and ansible_pkg_mgr == "pacman"
# Gather again in case missing programs have now been installed.
- ansible.builtin.include_tasks: facts/general/gather.yml
- ansible.builtin.include_tasks: tasks/general/settings/keyboard.yml
- ansible.builtin.include_tasks: tasks/general/acct_mgmt/groups.yml
- ansible.builtin.include_tasks: tasks/general/acct_mgmt/users.yml
- ansible.builtin.include_tasks: tasks/general/acct_mgmt/sudo.yml
- ansible.builtin.include_tasks: tasks/general/acct_mgmt/doas.yml
when: internet
- ansible.builtin.include_tasks: tasks/general/software/env-shared.yml
when: internet
- ansible.builtin.include_tasks: tasks/general/scripts/root.yml
- ansible.builtin.include_tasks: tasks/general/scripts/user.yml
- ansible.builtin.include_tasks: tasks/general/scripts/install.yml
- ansible.builtin.include_tasks: tasks/general/cron/ansible.yml
# TODO Need to refactor. Maybe tasks/general/cron/freebsd.yml
- ansible.builtin.include_tasks: tasks/workstation/freebsd/cron/ansible.yml
when: ansible_system == "FreeBSD"
- ansible.builtin.include_tasks: tasks/general/software/metasploit.yml
when: internet
when: provision
+84 -87
View File
@@ -296,100 +296,97 @@
mode: "0755"
- name: Workstation | Linux | Software | LLMs | runit | open-webui
block:
- name: Workstation | Linux | Software | LLMs | runit | open-webui | Packages
ansible.builtin.package:
name:
- docker
state: present
- name: Workstation | Linux | Software | LLMs | runit | open-webui | Packages | init
ansible.builtin.package:
name:
- docker-runit
state: present
when: ansible_pkg_mgr == "pacman"
- name: Workstation | Linux | Software | LLMs | runit | open-webui | Dir | /etc/sv
ansible.builtin.file:
name: "/etc/sv/open_webui/log"
state: directory
owner: root
mode: "0755"
- name: Workstation | Linux | Software | LLMs | runit | open-webui | Dir | /var/log
ansible.builtin.file:
name: "/var/log/open_webui"
state: directory
owner: "{{ user }}"
mode: "0755"
- name: Workstation | Linux | Software | LLMs | runit | open-webui | Script | File
ansible.builtin.copy:
dest: /etc/sv/open_webui/run
content: |
#!/bin/sh
exec 2>&1
# Wait for Docker to start up.
while [ ! -S /var/run/docker.sock ]; do sleep 1; done
# Ensure the old container is gone.
echo "Stopping..."
docker stop open-webui &&
echo "Container stopped" ||
echo "Container already stopped."
echo "Deleting..."
docker rm -f open-webui &&
echo "Container deleted" ||
echo "Container already deleted."
# Start the open-webui program.
set -e
exec docker run --rm \
-p {{ open_webui_port }}:8080 \
--add-host=host.docker.internal:host-gateway \
-v open-webui:/app/backend/data \
{{ ("-e HF_TOKEN=" ~ hf_token) if hf_token else '' }} \
-e WEBUI_SECRET_KEY={{ open_webui_key }} \
-e OLLAMA_BASE_URL=http://host.docker.internal:11434 \
--name open-webui \
ghcr.io/open-webui/open-webui:main
mode: "0755"
- name: Workstation | Linux | Software | LLMs | runit | open-webui | Script | Log
ansible.builtin.copy:
dest: /etc/sv/open_webui/log/run
content: |
#!/bin/sh -e
exec svlogd -tt /var/log/open_webui
mode: "0755"
- name: Workstation | Linux | Software | LLMs | runit | open-webui | Script | Log Config
ansible.builtin.copy:
dest: /var/log/open_webui/config
content: |
s1000000 # rotate at 1 MB
n5 # keep 5 old files
dateformat %Y-%m-%d_%H-%M-%S # each run gets its own file.
mode: "0755"
- name: Workstation | Linux | Software | LLMs | runit | open-webui | Packages
ansible.builtin.package:
name:
- docker
state: present
when: open_webui_enabled
- name: Workstation | Linux | Software | LLMs | runit | open-webui | Packages | init
ansible.builtin.package:
name:
- docker-runit
state: present
when: open_webui_enabled
and ansible_pkg_mgr == "pacman"
- name: Workstation | Linux | Software | LLMs | runit | open-webui | Dir | /etc/sv
ansible.builtin.file:
name: "/etc/sv/open-webui/log"
state: directory
owner: root
mode: "0755"
- name: Workstation | Linux | Software | LLMs | runit | open-webui | Dir | /var/log
ansible.builtin.file:
name: "/var/log/open-webui"
state: directory
owner: "{{ user }}"
mode: "0755"
- name: Workstation | Linux | Software | LLMs | runit | open-webui | Script | File
ansible.builtin.copy:
dest: /etc/sv/open-webui/run
content: |
#!/bin/sh
exec 2>&1
# Wait for Docker to start up.
while [ ! -S /var/run/docker.sock ]; do sleep 1; done
# Ensure the old container is gone.
echo "Stopping..."
docker stop open-webui &&
echo "Container stopped" ||
echo "Container already stopped."
echo "Deleting..."
docker rm -f open-webui &&
echo "Container deleted" ||
echo "Container already deleted."
# Start the open-webui program.
set -e
exec docker run --rm \
-p {{ open_webui_port }}:8080 \
--add-host=host.docker.internal:host-gateway \
-v open-webui:/app/backend/data \
{{ ("-e HF_TOKEN=" ~ hf_token) if hf_token else '' }} \
-e WEBUI_SECRET_KEY={{ open_webui_key }} \
-e OLLAMA_BASE_URL=http://host.docker.internal:11434 \
--name open-webui \
ghcr.io/open-webui/open-webui:main
mode: "0755"
- name: Workstation | Linux | Software | LLMs | runit | open-webui | Script | Log
ansible.builtin.copy:
dest: /etc/sv/open-webui/log/run
content: |
#!/bin/sh -e
exec svlogd -tt /var/log/open-webui
mode: "0755"
- name: Workstation | Linux | Software | LLMs | runit | open-webui | Script | Log Config
ansible.builtin.copy:
dest: /var/log/open-webui/config
content: |
s1000000 # rotate at 1 MB
n5 # keep 5 old files
dateformat %Y-%m-%d_%H-%M-%S # each run gets its own file.
mode: "0755"
when: ansible_service_mgr == "runit"
- name: Workstation | Linux | Software | LLMs | Services | Enable
ansible.builtin.service:
name: "{{ item }}"
state: started
enabled: true
name: "{{ item.name }}"
state: "{{ 'started' if item.status else 'stopped' }}"
enabled: "{{ item.status }}"
loop:
- "{{ ollama if ollama_enabled else dummy_service }}"
- "{{ zeroclaw if zeroclaw_enabled else dummy_service }}"
- "{{ 'docker' if open_webui_enabled else dummy_service }}"
- "{{ 'open_webui' if open_webui_enabled else dummy_service }}"
- { 'name': "{{ ollama }}" , 'status': "{{ ollama_enabled }}" }
- { 'name': "{{ zeroclaw }}", 'status': "{{ zeroclaw_enabled }}" }
- { 'name': 'docker' , 'status': true }
- { 'name': 'open-webui' , 'status': "{{ open_webui_enabled }}" }
- name: Workstation | Linux | Software | LLMs | Services | Verify
ansible.builtin.uri:
+28
View File
@@ -0,0 +1,28 @@
---
# Harmonize systems rather than doing everything manually. :)
# Setup of any device connected to this repo.
- name: Main | Default Setup
hosts: localhost
connection: local
become: true
tasks:
- ansible.builtin.include_tasks: tasks/header.yml
#######################
#######################
####### TESTING #######
#######################
#######################
- ansible.builtin.include_tasks: tasks/workstation/linux/software/llm.yml
#######################
#######################
###### / TESTING ######
#######################
#######################
- ansible.builtin.include_tasks: tasks/footer.yml