infra/ansible/roles/uisp/tasks/main.yml
Graham McIntire fb5803c866
add FreeBSD bootstrap, irc servers, hostname overrides, and cleanups
- bootstrap.yml: support pkg for FreeBSD sudo/python3 install
- base role: FreeBSD package sets, sudoers paths, host key regen, admin group, usermod process-in-use tolerance
- freebsd role: pkg update/upgrade tasks
- general role: standalone hostname tasks (ungated from network.skip), hostname_override support
- inspircd role: deploy configs for ca/us manero.org irc servers with vault-backed secrets
- uisp role: download and run installer on fresh hosts, skip if already running
- netbox role: stop services before usermod to avoid process-in-use failures
- hosts: add irc_servers group, ca/us.manero.org (Tailscale), drop staging.towerops.net
- all.yml: graham user gets static ed25519 key alongside github keys
2026-06-19 17:19:29 -05:00

137 lines
3.4 KiB
YAML

---
- name: Install Docker prerequisites
ansible.builtin.apt:
name:
- apt-transport-https
- ca-certificates
- curl
- gnupg
state: present
update_cache: yes
- name: Add Docker GPG key
ansible.builtin.get_url:
url: https://download.docker.com/linux/debian/gpg
dest: /etc/apt/keyrings/docker.asc
mode: '0644'
- name: Add Docker APT repository
ansible.builtin.deb822_repository:
name: docker
types: [deb]
uris: https://download.docker.com/linux/debian
suites: "{{ ansible_facts['distribution_release'] }}"
components: [stable]
architectures: [amd64]
signed_by: /etc/apt/keyrings/docker.asc
state: present
- name: Remove legacy Docker .list repo (superseded by deb822 .sources)
ansible.builtin.file:
path: /etc/apt/sources.list.d/docker.list
state: absent
- name: Install Docker CE
ansible.builtin.apt:
name:
- docker-ce
- docker-ce-cli
- containerd.io
- docker-buildx-plugin
- docker-compose-plugin
- docker-ce-rootless-extras
state: present
update_cache: yes
- name: Create UISP group
ansible.builtin.group:
name: "{{ uisp_group }}"
gid: "{{ uisp_group_gid }}"
state: present
- name: Create UISP user
ansible.builtin.user:
name: "{{ uisp_user }}"
uid: "{{ uisp_user_uid }}"
group: "{{ uisp_group }}"
groups: docker
append: yes
home: "{{ uisp_home }}"
shell: /bin/sh
state: present
- name: Ensure Docker is running
ansible.builtin.systemd:
name: docker
state: started
enabled: yes
- name: Create containerd killmode override directory
ansible.builtin.file:
path: /usr/lib/systemd/system/containerd.service.d
state: directory
owner: root
group: root
mode: '0755'
- name: Configure containerd KillMode for UISP
ansible.builtin.copy:
dest: /usr/lib/systemd/system/containerd.service.d/unms-killmode.conf
content: |
[Service]
KillMode=mixed
owner: root
group: root
mode: '0644'
notify:
- Reload systemd
- Restart containerd
- name: Ensure UISP app directory exists
ansible.builtin.file:
path: "{{ uisp_app_dir }}"
state: directory
owner: "{{ uisp_user }}"
group: root
mode: '0700'
- name: Ensure UISP data directory exists
ansible.builtin.file:
path: "{{ uisp_data_dir }}"
state: directory
owner: "{{ uisp_user }}"
group: root
mode: '0700'
- name: Download UISP installer script
ansible.builtin.get_url:
url: https://getuisp.com/install.sh
dest: "{{ uisp_app_dir }}/update.sh"
owner: "{{ uisp_user }}"
group: root
mode: "0755"
register: uisp_installer
- name: Check if UISP containers are already running
community.docker.docker_container_info:
name: unms-postgres
register: uisp_postgres_container
failed_when: false
- name: Run UISP installer (first install only — skips existing)
ansible.builtin.command: "{{ uisp_app_dir }}/update.sh"
become: true
become_user: "{{ uisp_user }}"
when:
- not uisp_postgres_container.exists | default(false)
register: uisp_install
changed_when: uisp_install.rc == 0
- name: Deploy UISP auto-update cron job
ansible.builtin.copy:
dest: /etc/cron.d/unms-update
content: |
* * * * * {{ uisp_user }} {{ uisp_app_dir }}/update.sh --cron > /dev/null 2>&1 || true
owner: root
group: root
mode: '0644'