Create registrator role
This commit is contained in:
parent
168641b728
commit
04c7efe706
7 changed files with 174 additions and 0 deletions
12
roles/registrator/files/garaze_racunovodstvo.sh
Normal file
12
roles/registrator/files/garaze_racunovodstvo.sh
Normal file
|
@ -0,0 +1,12 @@
|
|||
#!/bin/sh
|
||||
GARAZEDIR="~/garaze/tmp"
|
||||
# RECIPIENTS="polz@fri.uni-lj.si"
|
||||
# RECIPIENTS="anita.strmole@fri.uni-lj.si"
|
||||
# RECIPIENTS="racunovodstvo@fri.uni-lj.si"
|
||||
RECIPIENTS="$(cat ~/garage_recipients.txt)"
|
||||
|
||||
# cd /home/registrator/siemens-spica-rilec
|
||||
|
||||
rm $GARAZEDIR/*.xlsx
|
||||
~/siemens-spica-rilec/garage_count.py --employee --calculation --format xlsx ~/data "$GARAZEDIR/garaze_{start}_{end}.xlsx"
|
||||
echo "Garaže za pretekli mesec" | mail -s "Garaže za pretekli mesec" "$RECIPIENTS" -A $GARAZEDIR/*.xlsx
|
8
roles/registrator/files/get_siemens_logs.sh
Normal file
8
roles/registrator/files/get_siemens_logs.sh
Normal file
|
@ -0,0 +1,8 @@
|
|||
#!/bin/sh
|
||||
|
||||
cd ~/data
|
||||
echo "get -a -p -R /home/siemensfri/*" | sftp -P 2222 spicafri@dioda.fri.uni-lj.si
|
||||
# echo "get -a -p -R /home/siemensfri/*" | sftp -P 2222 spicafri@nebi.fri1.uni-lj.si
|
||||
find ~/data -mtime +365 -exec rm {} \;
|
||||
|
||||
~/siemens-spica-rilec/siemens_to_spool.py 2>> ~/logs/siemens_to_spool.log
|
12
roles/registrator/files/push_siemens_to_spica.sh
Normal file
12
roles/registrator/files/push_siemens_to_spica.sh
Normal file
|
@ -0,0 +1,12 @@
|
|||
#!/bin/sh
|
||||
|
||||
|
||||
/home/registrator/siemens-spica-rilec/spooldirs_from_apis.py
|
||||
/home/registrator/get_siemens_logs.sh 2> /dev/null > /dev/null
|
||||
/home/registrator/siemens-spica-rilec/siemens_to_spool.py 2>> /home/registrator/logs/siemens_to_spool_errors.log
|
||||
|
||||
today=$(date --iso)
|
||||
/home/registrator/siemens-spica-rilec/add_fix.py --time "${today} 23:00" --type "odhod" /home/registrator/spool/*/fixes.csv
|
||||
/home/registrator/siemens-spica-rilec/fix_events.py
|
||||
/home/registrator/siemens-spica-rilec/spool_to_spica.py --commit
|
||||
|
122
roles/registrator/tasks/main.yml
Normal file
122
roles/registrator/tasks/main.yml
Normal file
|
@ -0,0 +1,122 @@
|
|||
- name: Create registrator group
|
||||
group:
|
||||
name: registrator
|
||||
system: yes
|
||||
|
||||
- name: Create registrator user
|
||||
user:
|
||||
name: registrator
|
||||
system: yes
|
||||
home: /home/registrator
|
||||
shell: /sbin/nologin
|
||||
generate_ssh_key: yes
|
||||
ssh_key_comment: "{{ inventory_hostname }}"
|
||||
ssh_key_type: ed25519
|
||||
|
||||
- name: Install packages
|
||||
package:
|
||||
name: git,py3-pip
|
||||
|
||||
- name: Clone siemens-spica-rilec
|
||||
become: yes
|
||||
become_user: registrator
|
||||
become_method: su
|
||||
become_flags: "-s /bin/sh"
|
||||
git:
|
||||
repo: 'https://github.com/polz113/siemens-spica-rilec'
|
||||
dest: /home/registrator/siemens-spica-rilec
|
||||
force: yes
|
||||
|
||||
- name: Install requirements for spica-rilec
|
||||
become: yes
|
||||
become_user: registrator
|
||||
become_method: su
|
||||
become_flags: '-s /bin/sh'
|
||||
pip:
|
||||
requirements: /home/registrator/siemens-spica-rilec/requirements.txt
|
||||
extra_args: --user --break-system-packages --no-warn-script-location
|
||||
|
||||
- name: Configure spica-rilec settings
|
||||
template:
|
||||
dest: "/home/registrator/siemens-spica-rilec/{{ item }}"
|
||||
src: "{{ item }}.j2"
|
||||
owner: registrator
|
||||
group: registrator
|
||||
mode: 0600
|
||||
force: no
|
||||
loop:
|
||||
- siemens_spica_settings.py
|
||||
- apis_preslikava_kadrovskih_settings.py
|
||||
|
||||
- name: Clone web app
|
||||
become: yes
|
||||
become_user: registrator
|
||||
become_method: su
|
||||
become_flags: "-s /bin/sh"
|
||||
git:
|
||||
repo: 'https://github.com/polz113/registrator.git'
|
||||
dest: /home/registrator/registrator
|
||||
force: yes
|
||||
|
||||
- name: Configure registrator settings
|
||||
template:
|
||||
dest: "/home/registrator/registrator/conf/{{ item }}"
|
||||
src: "{{ item }}.j2"
|
||||
owner: registrator
|
||||
group: registrator
|
||||
mode: 0600
|
||||
force: no
|
||||
loop:
|
||||
- loginconf.php
|
||||
|
||||
- name: Create utility / cronjob scripts
|
||||
copy:
|
||||
dest: "/home/registrator/{{ item }}"
|
||||
src: "{{ item }}"
|
||||
mode: 0744
|
||||
owner: registrator
|
||||
group: registrator
|
||||
loop:
|
||||
- get_siemens_logs.sh
|
||||
- push_siemens_to_spica.sh
|
||||
- garaze_racunovodstvo.sh
|
||||
|
||||
- name: Create log/data directories
|
||||
file:
|
||||
dest: "/home/registrator/{{ item }}"
|
||||
owner: registrator
|
||||
loop:
|
||||
- data
|
||||
- logs
|
||||
- spool
|
||||
|
||||
- name: Create garaze config
|
||||
copy:
|
||||
dest: "/home/registrator/garaze_recipients.txt"
|
||||
content: "{{ password.garaze_recipients }}"
|
||||
|
||||
- name: Set up cronjob for fetching the logs
|
||||
cron:
|
||||
name: "get siemens logs"
|
||||
job: "/home/registrator/get_siemens_logs.sh"
|
||||
user: registrator
|
||||
minute: "*/10"
|
||||
|
||||
- name: Set up cronjob for garaze
|
||||
cron:
|
||||
name: "send garaze usage"
|
||||
job: "/home/registrator/garaze_racunovodstvo.sh"
|
||||
user: registrator
|
||||
minute: "15"
|
||||
hour: "00"
|
||||
day: "1"
|
||||
|
||||
- name: Set up cronjob for spica
|
||||
cron:
|
||||
name: "push events to spica"
|
||||
job: "/home/registrator/push_siemens_to_spica.sh >> /home/registrator/logs/siemens_to_spica.log"
|
||||
user: registrator
|
||||
minute: "30"
|
||||
hour: "23"
|
||||
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
APIS_USERS_URL="{{password.apis_users_url}}/"
|
||||
APIS_API_KEY="{{password.apis_api_key}}"
|
||||
APIS_WEB_SPOOL_FIELD = "upn"
|
||||
APIS_MAIN_SPOOL_FIELD = "OsebniPodatki__kadrovskaSt"
|
0
roles/registrator/templates/loginconf.php.j2
Normal file
0
roles/registrator/templates/loginconf.php.j2
Normal file
16
roles/registrator/templates/siemens_spica_settings.py.j2
Normal file
16
roles/registrator/templates/siemens_spica_settings.py.j2
Normal file
|
@ -0,0 +1,16 @@
|
|||
APIURL="{{password.spica_url}}"
|
||||
SPICA_USER="{{password.spica_user}}"
|
||||
SPICA_PASSWD="{{password.spica_passwd}}"
|
||||
SPICA_KEY="{{password.spica_key}}"
|
||||
|
||||
LOG_GLOB="/home/registrator/data/room-access*.csv"
|
||||
SPOOL_DIR="/home/registrator/spool"
|
||||
ULID_SPOOL_DIR="/home/registrator/registrator/spool"
|
||||
# SPOOL_DIR="/home/apis/spool"
|
||||
|
||||
OLD_LOG_LIST="/home/registrator/data/handled_logs.txt"
|
||||
|
||||
SPOOL_FNAME="new_events.csv"
|
||||
OLDEVENTS_FNAME="old_events.csv"
|
||||
NOCOMMIT_FNAME="nocommit.csv"
|
||||
FIX_FNAME="fixes.csv"
|
Loading…
Add table
Add a link
Reference in a new issue