48
roles/ninjabot/tasks/main.yml
Normal file
48
roles/ninjabot/tasks/main.yml
Normal file
@ -0,0 +1,48 @@
|
||||
---
|
||||
- name: Install python3 IRC library
|
||||
apt:
|
||||
name: python3-irc
|
||||
state: present
|
||||
update_cache: true
|
||||
register: apt_result
|
||||
retries: 3
|
||||
until: apt_result is succeeded
|
||||
|
||||
- name: Install Flask for python3
|
||||
apt:
|
||||
name: python3-flask
|
||||
state: present
|
||||
update_cache: true
|
||||
register: apt_result
|
||||
retries: 3
|
||||
until: apt_result is succeeded
|
||||
|
||||
- name: Clone NinjaBot code
|
||||
git:
|
||||
repo: https://gitlab.crans.org/nounous/NinjaBot.git
|
||||
dest: /var/local/ninjabot
|
||||
version: master
|
||||
|
||||
- name: Deploy NinjaBot configuration
|
||||
template:
|
||||
src: ninjabot/ninjabot.json.j2
|
||||
dest: /var/local/ninjabot/ninjabot.json
|
||||
|
||||
- name: Deploy NinjaBot systemd unit
|
||||
template:
|
||||
src: systemd/system/ninjabot.service.j2
|
||||
dest: /etc/systemd/system/ninjabot.service
|
||||
mode: 0644
|
||||
|
||||
- name: Load and activate NinjaBot service
|
||||
systemd:
|
||||
name: ninjabot
|
||||
daemon_reload: true
|
||||
enabled: true
|
||||
state: started
|
||||
|
||||
- name: Indicate NinjaBot in motd
|
||||
template:
|
||||
src: update-motd.d/05-service.j2
|
||||
dest: /etc/update-motd.d/05-ninjabot
|
||||
mode: 0755
|
1
roles/ninjabot/templates/ninjabot/ninjabot.json.j2
Normal file
1
roles/ninjabot/templates/ninjabot/ninjabot.json.j2
Normal file
@ -0,0 +1 @@
|
||||
{{ ninjabot.config | to_nice_json(indent=2) }}
|
15
roles/ninjabot/templates/systemd/system/ninjabot.service.j2
Normal file
15
roles/ninjabot/templates/systemd/system/ninjabot.service.j2
Normal file
@ -0,0 +1,15 @@
|
||||
{{ ansible_header | comment }}
|
||||
[Unit]
|
||||
Description=NinjaBot IRC bot
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
WorkingDirectory=/var/local/ninjabot
|
||||
User=nobody
|
||||
Group=nogroup
|
||||
ExecStart=/usr/bin/python3 /var/local/ninjabot/ninjabot.py
|
||||
Restart=always
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
3
roles/ninjabot/templates/update-motd.d/05-service.j2
Executable file
3
roles/ninjabot/templates/update-motd.d/05-service.j2
Executable file
@ -0,0 +1,3 @@
|
||||
#!/usr/bin/tail +14
|
||||
{{ ansible_header | comment }}
|
||||
[0m> [38;5;82mNinjaBot[0m a été déployé sur cette machine. Voir [38;5;6m/var/local/ninjabot/[0m.
|
Reference in New Issue
Block a user