ansible/roles/adam/tasks/main.yml
2020-08-23 22:41:13 -05:00

61 lines
1.6 KiB
YAML

#!/usr/bin/ansible-playbook
# vim:ft=ansible:
- name: Set up Adam
block:
- name: Install required packages
apt:
name:
- libopus0
- nodejs
- npm
- name: Install packages without recommends
apt:
install_recommends: no
name:
- ffmpeg
- name: Create Adam user
user:
name: discord-adam
- name: Assure data directory
file:
path: "/var/adam"
state: directory
# Sticky, SetGID
mode: 3775
owner: root
group: discord-adam
- name: Set up bot root
block:
- name: Create specific data directory
file:
path: "/var/adam/{{ adam_name }}"
state: directory
mode: 0755
- name: Clone bot repo
git:
repo: "{{ adam_repo }}"
dest: "/var/adam/{{ adam_name }}"
- name: Initialize NPM modules
npm:
path: "/var/adam/{{ adam_name }}"
- name: Template out authentication token
template:
src: "auth.json"
dest: "/var/adam/{{ adam_name }}/auth.json"
mode: "0600"
become: yes
become_user: discord-adam
- name: Set up system configuration
block:
- name: Template out service
template:
src: "adam@.service"
dest: "/etc/systemd/system/adam@.service"
- name: Start and enable service
systemd:
daemon_reload: yes
name: "adam@{{ adam_name }}.service"
enabled: yes
state: started
become: yes