ansible/roles/adam/tasks/main.yml
2020-06-09 01:29:20 -05:00

56 lines
1.5 KiB
YAML

#!/usr/bin/ansible-playbook
# vim:ft=ansible:
- name: Set up Adam
block:
- name: Install required packages
apt:
name:
- libopus0
- nodejs
- npm
- 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: "0700"
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