Browse Source

Moved ansible config into this repo, manage passwords with ansible

master
Felix Ableitner 2 years ago
parent
commit
48d8308049
  1. 4
      .gitignore
  2. 5
      ansible.cfg
  3. 11
      cron-sample.sh
  4. 0
      files/requirements.txt
  5. 0
      files/tootbot.py
  6. 5
      inventory.example
  7. 34
      templates/run-bot.sh
  8. 51
      tootbot.yml

4
.gitignore

@ -1,3 +1 @@
*.secret
cron.sh
inventory

5
ansible.cfg

@ -0,0 +1,5 @@
[defaults]
inventory=inventory
[ssh_connection]
pipelining = True

11
cron-sample.sh

@ -1,11 +0,0 @@
# activate virtualenv if necessary
# source /home/cquest/.virtualenvs/tootbot/bin/activate
# parameters:
# 1- twitter account to clone
# 2- mastodon login
# 3- mastodon password
# 4- instance domain (https:// is automatically added)
python tootbot.py geonym_fr geonym@amicale.net **password** test.amicale.net
python tootbot.py cq94 cquest@amicale.net **password** test.amicale.net

0
requirements.txt → files/requirements.txt

0
tootbot.py → files/tootbot.py

5
inventory.example

@ -0,0 +1,5 @@
[tootbot]
user@host newsbots_password=my_password
[all:vars]
ansible_connection=ssh

34
templates/run-bot.sh

@ -0,0 +1,34 @@
#!/bin/bash
set -e
# parameters:
# 1- twitter account to clone
# 2- mastodon login
# 3- mastodon password
# 4- instance domain (https:// is automatically added)
PATH="/app/tootbot"
cd "$PATH/telesur_en"
../source/tootbot.py telesurenglish me+telesur_en@nutomic.com {{ newsbots_password }} newsbots.eu &>> bot.log &
/bin/sleep 60
cd "$PATH/telesur_es"
../source/tootbot.py teleSURtv me+telesur_es@nutomic.com {{ newsbots_password }} newsbots.eu &>> bot.log &
/bin/sleep 60
cd "$PATH/itsgoingdown"
../source/tootbot.py IGD_News me+itsgoingdown@nutomic.com {{ newsbots_password }} newsbots.eu &>> bot.log &
/bin/sleep 60
cd "$PATH/postillon"
../source/tootbot.py Der_Postillon me+postillon@nutomic.com {{ newsbots_password }} newsbots.eu &>> bot.log &
/bin/sleep 60
cd "$PATH/telepolis"
../source/tootbot.py telepolis_news me+telepolis@nutomic.com {{ newsbots_password }} newsbots.eu &>> bot.log &
/bin/sleep 60
cd "$PATH/granma"
../source/tootbot.py Granma_English me+granma@nutomic.com {{ newsbots_password }} newsbots.eu &>> bot.log &
/bin/sleep 60

51
tootbot.yml

@ -0,0 +1,51 @@
---
- hosts: all
become: yes
tasks:
- name: add tootbot user
user:
name: tootbot
create_home: yes
system: yes
- name: create tootbot folder
file:
path: /tootbot/
owner: tootbot
group: tootbot
mode: '0755'
state: directory
- name: add all template files
template: src=templates/run-bot.sh dest=/tootbot/run-bot.sh
- name: install dependencies
apt:
pkg: ['python3', 'python3-pip', 'python3-setuptools']
- name: clone/update git repo
git:
repo: 'https://github.com/Nutomic/tootbot.git'
dest: /tootbot/source/
- name: install python requirements
raw: cd /tootbot/source/ && sudo -H -u tootbot pip3 install -r requirements.txt
args:
executable: /bin/bash
- name: chown tootbot folder
file:
path: /tootbot/
owner: tootbot
group: tootbot
state: directory
recurse: yes
- name: create tootbot crontab
cron:
name: "tootbot"
minute: "*/10"
user: tootbot
job: "/tootbot/run-bot.sh >> /tootbot/bot.log 2>&1"
disabled: no
Loading…
Cancel
Save