add feed to muc deployment possible
This commit is contained in:
parent
a834948afd
commit
5b1e440ed5
|
@ -1,6 +1,8 @@
|
|||
---
|
||||
|
||||
#HUBOT DEFAULT VARIABLES
|
||||
# used for hubot bots
|
||||
|
||||
hubot_nodejs_version: '14'
|
||||
hubot_apt:
|
||||
- nodejs
|
||||
|
@ -33,5 +35,28 @@ hubot_list:
|
|||
xmpp_password: test123test123
|
||||
xmpp_room: 'myroom@example.org' # you can add multiple rooms, just separate them with a coma
|
||||
|
||||
|
||||
#BOT DEFAULT VARIABLES
|
||||
# used for feed-to-muc bots
|
||||
|
||||
feedbot_list:
|
||||
- bot_name: mybot1
|
||||
xmpp_server: 'example.com:5222'
|
||||
xmpp_jid: 'feedbot@example.com'
|
||||
xmpp_password: 'ChangeThis'
|
||||
xmpp_muc: 'muc-to-feed@conference.example.com'
|
||||
xmpp_botusername: 'My feed bot'
|
||||
xmpp_contact: 'xmpp:botadmin@example.com'
|
||||
xmpp_MaxArticles: 5
|
||||
xmpp_RefreshTime: 30
|
||||
xmpp_NoExcerpt: 'false'
|
||||
xmpp_Filter: '"submitted by", "[link]"'
|
||||
xmpp_FilterMessage: '"Block me!", "Block me too!"'
|
||||
xmpp_Quiet: 'false'
|
||||
xmpp_Feeds: '"https://www.debian.org/News/news",
|
||||
"https://www.debian.org/security/dsa-long",
|
||||
"https://www.reddit.com/r/FDroidUpdates/new.rss"'
|
||||
|
||||
|
||||
# List the name of the bots to remove, separeted by a comma
|
||||
hubot_delete_list: []
|
||||
bot_delete_list: []
|
|
@ -11,7 +11,6 @@
|
|||
become: yes
|
||||
become_user: '{{ item.0.hubot_name }}'
|
||||
|
||||
|
||||
- name: '[MODULES] - Deploy external-scripts.json config'
|
||||
template:
|
||||
src: hubot/external-scripts.json.j2
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
---
|
||||
|
||||
- name: "[CREATE] - Generate each bot in its path"
|
||||
shell: /usr/local/go/bin/go install salsa.debian.org/mdosch/feed-to-muc@latest
|
||||
args:
|
||||
chdir: '/home/{{ item.bot_name }}'
|
||||
loop: '{{ feedbot_list }}'
|
||||
become: yes
|
||||
become_user: '{{ item.bot_name }}'
|
||||
|
||||
- name: '[CREATE] - Create feed-to-muc directory'
|
||||
file:
|
||||
path: '/home/{{ item.bot_name }}/.config/feed-to-muc/'
|
||||
state: directory
|
||||
mode: '0755'
|
||||
loop: '{{ feedbot_list }}'
|
||||
|
||||
- name: '[CREATE] - Deploy config.json'
|
||||
template:
|
||||
src: home/botname/config.json.j2
|
||||
dest: '/home/{{ item.bot_name }}/.config/feed-to-muc/config.json'
|
||||
owner: '{{ item.bot_name }}'
|
||||
group: '{{ item.bot_name }}'
|
||||
mode: 0644
|
||||
loop: '{{ feedbot_list }}'
|
|
@ -0,0 +1,24 @@
|
|||
---
|
||||
|
||||
- name: '[DELETE] - Stop bot service'
|
||||
systemd:
|
||||
name: "{{ item }}"
|
||||
state: stopped
|
||||
loop: '{{ bot_delete_list }}'
|
||||
|
||||
- name: '[DELETE] - Delete bot service'
|
||||
file:
|
||||
path: "/etc/systemd/system/{{ item }}.service"
|
||||
state: absent
|
||||
loop: '{{ bot_delete_list }}'
|
||||
|
||||
- name: '[DELETE] - Daemon reload'
|
||||
systemd:
|
||||
daemon_reload: yes
|
||||
|
||||
- name: '[DELETE] - Delete bot user'
|
||||
user:
|
||||
name: "{{ item }}"
|
||||
state: absent
|
||||
remove: yes
|
||||
loop: '{{ bot_delete_list }}'
|
|
@ -1,24 +0,0 @@
|
|||
---
|
||||
|
||||
- name: '[DELETE] - Stop hubot service'
|
||||
systemd:
|
||||
name: "{{ item }}"
|
||||
state: stopped
|
||||
loop: '{{ hubot_delete_list }}'
|
||||
|
||||
- name: '[DELETE] - Delete hubot service'
|
||||
file:
|
||||
path: "/etc/systemd/system/{{ item }}.service"
|
||||
state: absent
|
||||
loop: '{{ hubot_delete_list }}'
|
||||
|
||||
- name: '[DELETE] - Daemon reload'
|
||||
systemd:
|
||||
daemon_reload: yes
|
||||
|
||||
- name: '[DELETE] - Delete {{ item }} user'
|
||||
user:
|
||||
name: "{{ item}}"
|
||||
state: absent
|
||||
remove: yes
|
||||
loop: '{{ hubot_delete_list }}'
|
|
@ -0,0 +1,20 @@
|
|||
---
|
||||
|
||||
- name: '[INSTALLDEPS] - Remove any previous Go installation'
|
||||
shell: rm -rf /usr/local/go
|
||||
|
||||
- name: '[INSTALLDEPS] - Get latest go'
|
||||
unarchive:
|
||||
src: https://go.dev/dl/go1.19.4.linux-amd64.tar.gz
|
||||
dest: /usr/local/
|
||||
remote_src: yes
|
||||
|
||||
- name: '[INSTALLDEPS] - Add /usr/local/go/bin to the PATH environment variable'
|
||||
template:
|
||||
src: 'home/botname/profile.j2'
|
||||
dest: '/home/{{ item.bot_name }}/.profile'
|
||||
loop: '{{ feedbot_list }}'
|
||||
|
||||
- name: '[INSTALLDEPS] - Source PATH environment variable'
|
||||
shell: "/bin/bash -c 'source /home/{{ item.bot_name }}/.profile ;'"
|
||||
loop: '{{ feedbot_list }}'
|
|
@ -12,9 +12,15 @@
|
|||
- name: Install hubot modules
|
||||
include: addmodules.yml
|
||||
|
||||
- name: Delete hubot
|
||||
include: deletehubot.yml
|
||||
when: hubot_delete_list is defined and (hubot_delete_list | length > 0)
|
||||
- name: Install go
|
||||
include: installgo.yml
|
||||
|
||||
- name: Generate feedbot instance
|
||||
include: createfeedbot.yml
|
||||
|
||||
- name: Delete bot
|
||||
include: deletebot.yml
|
||||
when: bot_delete_list is defined and (bot_delete_list | length > 0)
|
||||
|
||||
- name: Deploy Systemd
|
||||
include: systemd.yml
|
||||
include: systemd.yml
|
|
@ -1,5 +1,6 @@
|
|||
---
|
||||
|
||||
# HUBOT
|
||||
- name: '[SystemD] - Deploy Systemd config'
|
||||
template:
|
||||
src: 'etc/systemd/system/hubot.service.j2'
|
||||
|
@ -22,3 +23,28 @@
|
|||
name: "{{ item.hubot_name }}"
|
||||
state: restarted
|
||||
loop: '{{ hubot_list }}'
|
||||
|
||||
|
||||
# BOT
|
||||
- name: '[SystemD] - Deploy Systemd config'
|
||||
template:
|
||||
src: 'etc/systemd/system/bot.service.j2'
|
||||
dest: '/etc/systemd/system/{{ item.bot_name }}.service'
|
||||
owner: root
|
||||
group: root
|
||||
mode: 0644
|
||||
loop: '{{ feedbot_list }}'
|
||||
register: config
|
||||
|
||||
- name: '[SystemD] - Enable systemd'
|
||||
systemd:
|
||||
name: "{{ item.bot_name }}"
|
||||
enabled: yes
|
||||
daemon_reload: yes
|
||||
loop: '{{ feedbot_list }}'
|
||||
|
||||
- name: '[SystemD] - Restart bot'
|
||||
systemd:
|
||||
name: "{{ item.bot_name }}"
|
||||
state: restarted
|
||||
loop: '{{ feedbot_list }}'
|
|
@ -1,15 +1,32 @@
|
|||
---
|
||||
|
||||
- name: '[User] - Add group {{ item.hubot_name }}'
|
||||
# HUBOT
|
||||
- name: '[User] - Add hubot group'
|
||||
group:
|
||||
name: '{{ item.hubot_name }}'
|
||||
state: present
|
||||
loop: '{{ hubot_list }}'
|
||||
|
||||
|
||||
- name: '[User] - Add linux user {{ item.hubot_name }}'
|
||||
- name: '[User] - Add hubot linux user'
|
||||
user:
|
||||
name: '{{ item.hubot_name }}'
|
||||
shell: /bin/bash
|
||||
group: '{{ item.hubot_name }}'
|
||||
loop: '{{ hubot_list }}'
|
||||
|
||||
|
||||
# BOT
|
||||
- name: '[User] - Add bot group'
|
||||
group:
|
||||
name: '{{ item.bot_name }}'
|
||||
state: present
|
||||
loop: '{{ feedbot_list }}'
|
||||
|
||||
|
||||
- name: '[User] - Addubot linux user'
|
||||
user:
|
||||
name: '{{ item.bot_name }}'
|
||||
shell: /bin/bash
|
||||
group: '{{ item.bot_name }}'
|
||||
loop: '{{ feedbot_list }}'
|
|
@ -0,0 +1,19 @@
|
|||
[Unit]
|
||||
Description=feed-to-muc robot
|
||||
Documentation=https://salsa.debian.org/mdosch/feed-to-muc
|
||||
Requires=network.target
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
WorkingDirectory=/home/{{ item.bot_name }}
|
||||
RemainAfterExit=yes
|
||||
User={{ item.bot_name }}
|
||||
Restart=always
|
||||
RestartSec=10
|
||||
StandardOutput=syslog
|
||||
SyslogIdentifier={{ item.bot_name }}
|
||||
ExecStart=/home/{{ item.bot_name}}/go/bin/feed-to-muc
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
|
@ -0,0 +1,15 @@
|
|||
{
|
||||
"ServerAddress": "{{ item.xmpp_server }}",
|
||||
"BotJid": "{{ item.xmpp_jid }}",
|
||||
"Password": "{{ item.xmpp_password }}",
|
||||
"Muc": "{{ item.xmpp_muc }}",
|
||||
"MucNick": "{{ item.xmpp_botusername }}",
|
||||
"Contact": "{{ item.xmpp_contact }}",
|
||||
"MaxArticles": {{ item.xmpp_MaxArticles }},
|
||||
"RefreshTime": {{ item.xmpp_RefreshTime }},
|
||||
"NoExcerpt": {{ item.xmpp_NoExcerpt }},
|
||||
"Filter": [ {{ item.xmpp_Filter }} ],
|
||||
"FilterMessage": [ {{ item.xmpp_FilterMessage }} ],
|
||||
"Quiet": {{ item.xmpp_Quiet }},
|
||||
"Feeds": [ {{ item.xmpp_Feeds }} ]
|
||||
}
|
|
@ -0,0 +1,2 @@
|
|||
export PATH=$PATH:/usr/local/go/bin
|
||||
export GOPATH=$HOME/go
|
Loading…
Reference in New Issue