This commit is contained in:
Maveno
2024-11-12 19:40:35 +01:00
parent 5febb96916
commit 303fd4bc80
6 changed files with 190 additions and 78 deletions

View File

@@ -0,0 +1,8 @@
all:
hosts:
ffx:
ansible_host: <domain>
ansible_user: <system user>
ffxSystemUsername: <system user>
ffxHomeDirectory: <home directory>

113
ansible/setup_node.yml Normal file
View File

@@ -0,0 +1,113 @@
- name: Setup FFX node
hosts: all
vars:
ffxRepoUrl: https://gitea.maveno.de/Javanaut/ffx.git
tasks:
- name: Update system and install packages
become: true
ansible.builtin.apt:
name:
- python3-virtualenv
- ffmpeg
- git
- screen
update_cache: yes
- name: Create sync dir
become: true
file:
path: "{{ ffxHomeDirectory }}/.local/var/sync/ffx"
state: directory
owner: "{{ ffxSystemUsername }}"
group: "{{ ffxSystemUsername }}"
mode: 0755
- name: Ensure local etc directory
become: true
file:
path: "{{ ffxHomeDirectory }}/.local/etc"
state: directory
owner: "{{ ffxSystemUsername }}"
group: "{{ ffxSystemUsername }}"
mode: 0755
- name: Ensure local src directory
become: true
file:
path: "{{ ffxHomeDirectory }}/.local/src"
state: directory
owner: "{{ ffxSystemUsername }}"
group: "{{ ffxSystemUsername }}"
mode: 0755
- name: Ensure local share directory
become: true
file:
path: "{{ ffxHomeDirectory }}/.local/share"
state: directory
owner: "{{ ffxSystemUsername }}"
group: "{{ ffxSystemUsername }}"
mode: 0755
- name: Prepare ffx virtualenv
become: true
become_user: "{{ ffxSystemUsername }}"
ansible.builtin.pip:
name:
- click
- textual
- sqlalchemy
- requests
virtualenv: "{{ ffxHomeDirectory }}/.local/share/ffx.venv"
- name: Clone ffx repository
become: true
become_user: "{{ ffxSystemUsername }}"
ansible.builtin.git:
repo: "{{ ffxRepoUrl }}"
dest: "{{ ffxHomeDirectory }}/.local/src/ffx"
version: dev
- name: Add TMDB API token placeholer to .bashrc
become: true
become_user: "{{ ffxSystemUsername }}"
ansible.builtin.lineinfile:
path: "{{ ffxHomeDirectory }}/.bashrc"
insertbefore: BOF
line: >-
export TMDB_API_KEY="<TMDB API token>"
- name: Add ffx alias to .bashrc
become: true
become_user: "{{ ffxSystemUsername }}"
ansible.builtin.lineinfile:
path: "{{ ffxHomeDirectory }}/.bashrc"
insertbefore: BOF
line: >-
alias ffx="{{ ffxHomeDirectory }}/.local/share/ffx.venv/bin/python
{{ ffxHomeDirectory }}/.local/src/ffx/bin/ffx.py"
- name: Ensure local sync directory
become: true
file:
path: "{{ ffxHomeDirectory }}/.local/var/sync/ffx"
state: directory
owner: "{{ ffxSystemUsername }}"
group: "{{ ffxSystemUsername }}"
mode: 0755
- name: Create ffx config file
become: true
become_user: "{{ ffxSystemUsername }}"
vars:
ffxConfiguration:
databasePath: "{{ ffxHomeDirectory }}/.local/var/sync/ffx/ffx.db"
ansible.builtin.copy:
content: "{{ ffxConfiguration | to_json }}"
dest: "{{ ffxHomeDirectory }}/.local/etc/ffx.json"
owner: "{{ ffxSystemUsername }}"
group: "{{ ffxSystemUsername }}"
mode: 0644