Initial commit - working.

This commit is contained in:
Mike Holloway committed 2026-08-02 00:58:04 -04:00
commit dc401dc6f2
19 files changed
+331

No files matched your search

+9
View File
@@ -0,0 +1,9 @@
Copyright 2024 Equilibrate IT Inc.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+38
View File
@@ -0,0 +1,38 @@
Role Name
=========
A brief description of the role goes here.
Requirements
------------
Any pre-requisites that may not be covered by Ansible itself or the role should be mentioned here. For instance, if the role uses the EC2 module, it may be a good idea to mention in this section that the boto package is required.
Role Variables
--------------
A description of the settable variables for this role should go here, including any variables that are in defaults/main.yml, vars/main.yml, and any variables that can/should be set via parameters to the role. Any variables that are read from other roles and/or the global scope (ie. hostvars, group vars, etc.) should be mentioned here as well.
Dependencies
------------
A list of other roles hosted on Galaxy should go here, plus any details in regards to parameters that may need to be set for other roles, or variables that are used from other roles.
Example Playbook
----------------
Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too:
- hosts: servers
roles:
- { role: username.rolename, x: 42 }
License
-------
BSD
Author Information
------------------
An optional section for the role authors to include contact information, or a website (HTML is not allowed).
+2
View File
@@ -0,0 +1,2 @@
---
# defaults file for podman_ollama
+2
View File
@@ -0,0 +1,2 @@
---
# handlers file for podman_ollama
+28
View File
@@ -0,0 +1,28 @@
---
dependencies: []
galaxy_info:
role_name: podman_ollama
author: "Mike Holloway"
description: "Installs and configures ollama + open-webui."
company: "Equilibrate IT Inc."
license: "license (BSD-2-Clause)"
min_ansible_version: 2.10
platforms:
- name: Fedora
versions:
- all
- name: Ubuntu
versions:
- all
- name: Debian
versions:
- all
galaxy_tags:
- networking
- system
- podman
- container
- ollama
- llm
- open-webui
+17
View File
@@ -0,0 +1,17 @@
- name: Check for certs
file:
path: "/home/{{ user.name }}/proxy/certs/{{ item }}"
state: file
loop:
- "{{ inventory_hostname }}.key"
- "{{ inventory_hostname }}.crt"
ignore_errors: true
register: iscert
- debug: msg="{{ iscert.msg }}"
- import_tasks: certificates_self.yml
when: "'self' in certificates and 'failed' in iscert.msg"
- import_tasks: certificates_certbot.yml
when: "'certbot' in certificates and 'failed' in iscert.msg"
+14
View File
@@ -0,0 +1,14 @@
- name: Create certbot certs
copy:
remote_src: true
src: "/etc/letsencrypt/live/{{ inventory_hostname }}/privkey.pem"
dest: "/home/{{ user.name }}/proxy/certs/{{ inventory_hostname }}.key"
owner: 100033
group: 100033
- copy:
remote_src: true
src: "/etc/letsencrypt/live/{{ inventory_hostname }}/fullchain.pem"
dest: "/home/{{ user.name }}/proxy/certs/{{ inventory_hostname }}.crt"
owner: 100033
group: 100033
+60
View File
@@ -0,0 +1,60 @@
- name: Create self-signed certs
become: yes
become_user: nextcloud
command:
chdir: /home/{{ user.name }}/
creates: "/home/{{ user.name }}/{{ inventory_hostname }}.key"
argv:
- openssl
- req
- -x509
- -newkey
- rsa:4096
- -sha256
- -nodes
- -keyout
- "{{ inventory_hostname }}.key"
- -out
- "{{ inventory_hostname }}.crt"
- -days
- 3650
- -subj
- "/C=CA/ST=ON/L=Toronto/O=EquilibrateIT/OU=SecretManagement/CN={{ inventory_hostname}}"
- -addext
- "subjectAltName = DNS:{{ inventory_hostname }},DNS:localhost,IP:127.0.0.1"
#- name: Add certificate trust
# become: yes
# become_user: nextcloud
# command:
# chdir: /home/nextcloud/
# creates: "/home/nextcloud/{{ inventory_hostname }}.crt"
# argv:
# - openssl
# - x509
# - -trustout
# - -in
# - "{{ inventory_hostname}}.normal.crt"
# - -out
# - "{{ inventory_hostname}}.crt"
- copy:
src: "/home/{{ user.name }}/{{ inventory_hostname }}.crt"
remote_src: true
dest: /home/{{ user.name }}/proxy/certs/
owner: 100033
- copy:
src: "/home/{{ user.name }}/{{ inventory_hostname }}.key"
remote_src: true
dest: /home/{{ user.name }}/proxy/certs/
owner: 100033
- file:
path: "/home/nextcloud/{{ item }}"
state: absent
with_items:
- "{{ inventory_hostname }}.normal.crt"
- "{{ inventory_hostname }}.crt"
- "{{ inventory_hostname }}.key"
+19
View File
@@ -0,0 +1,19 @@
- name: Container directory paths
file:
path: "/home/{{ user.name }}/{{ subdir }}"
state: directory
owner: "{{ user.name }}"
group: "{{ user.name }}"
with_items:
- ".ollama"
- "open-webui/data"
loop_control:
loop_var: "subdir"
- name: Create Compose File
template:
src: "docker-compose.yml.j2"
dest: "/home/{{ user.name }}/docker-compose.yml"
owner: "{{ user.name }}"
group: "{{ user.name }}"
+33
View File
@@ -0,0 +1,33 @@
- name: Root port openings and forwards for web traffic.
firewalld:
port: "{{ item }}"
zone: public
permanent: true
immediate: true
state: enabled
with_items:
- "80/tcp"
- "443/tcp"
- name: Root port openings and forwards for local traffic
firewalld:
port: "{{ item }}"
zone: trusted
permanent: true
immediate: true
state: enabled
with_items:
- "11434/tcp"
- firewalld:
rich_rule: "{{ item }}"
zone: public
permanent: true
immediate: true
state: enabled
with_items:
- "rule family=ipv4 forward-port port=80 protocol=tcp to-port=8080"
- "rule family=ipv4 forward-port port=443 protocol=tcp to-port=4443"
- command:
cmd: "firewall-cmd --reload"
+8
View File
@@ -0,0 +1,8 @@
---
- name: Load a variable file based on the OS type, or a default if not found.
include_vars: "{{ item }}"
with_first_found:
- "{{ ansible_distribution }}-{{ ansible_distribution_version }}.yml"
- "{{ ansible_distribution }}.yml"
- "{{ ansible_os_family }}.yml"
- "default.yml"
+30
View File
@@ -0,0 +1,30 @@
---
# tasks file for podman_ollama
- import_tasks: include-vars.yml
- name: Parse passwd
getent:
database: passwd
- block:
#- include_tasks: certificates.yml
# with_items:
# - "{{ service_users }}"
# loop_control:
# loop_var: "user"
- include_tasks: files.yml
with_items:
- "{{ service_users }}"
loop_control:
loop_var: "user"
- include_tasks: firewall.yml
with_items:
- "{{ service_users }}"
loop_control:
loop_var: "user"
- include_tasks: os.yml
with_items:
- "{{ service_users }}"
loop_control:
loop_var: "user"
when: '"ollama" in user.services'
+29
View File
@@ -0,0 +1,29 @@
- name: NVIDIA Container Toolkit == Prerequisites
dnf:
name: "curl"
state: present
- command: |
curl -s -L https://nvidia.github.io/libnvidia-container/stable/rpm/nvidia-container-toolkit.repo --output /etc/yum.repos.d/nvidia-container-toolkit.repo
args:
creates: "/etc/yum.repos.d/nvidia-container-toolkit.repo"
- vars:
container_toolkit_version: "1.19.1-1"
dnf:
name: "{{ item }}{{ container_toolkit_version}}"
state: present
with_items:
- "nvidia-container-toolkit-"
- "nvidia-container-toolkit-base-"
- "libnvidia-container-tools-"
- "libnvidia-container1-"
- command: |
nvidia-ctk cdi generate --output=/etc/cdi/nvidia.yaml
args:
creates: "/etc/cdi/nvidia.yaml"
- seboolean:
name: container_use_devices
state: true
persistent: true
+3
View File
@@ -0,0 +1,3 @@
POSTGRES_PASSWORD=
NEXTCLOUD_ADMIN_USER="admin"
NEXTCLOUD_ADMIN_PASSWORD=
+27
View File
@@ -0,0 +1,27 @@
services:
ollama:
image: ollama:latest
hostname: ollama
restart: always
devices:
- "nvidia.com/gpu=all"
volumes:
- /home/{{ user.name }}/.ollama:/root/.ollama:Z
ports:
- "11434:11434"
environment:
- OLLAMA_CONTEXT_LENGTH={{ ollama_context_length }}
openwebui:
image: ghcr.io/open-webui/open-webui:main
hostname: openwebui
restart: always
ports:
- "8080:8080"
volumes:
- /home/{{ user.name }}/open-webui:/app/backend/data:Z
environment:
- OLLAMA_BASE_URL=http://ollama:11434
- ENABLE_FOLDERS=true
depends_on:
- ollama
+2
View File
@@ -0,0 +1,2 @@
localhost
+5
View File
@@ -0,0 +1,5 @@
---
- hosts: localhost
remote_user: root
roles:
- podman_ollama
+3
View File
@@ -0,0 +1,3 @@
---
certbot_auto_renew_user: "root"
wordpress_site_url: "ansible_default.url"
+2
View File
@@ -0,0 +1,2 @@
---
# vars file for podman_ollama