gpg-lacre/tasks/install.yml

85 lines
2.4 KiB
YAML

---
- name: '[APT] - Install dependencies'
apt:
name: "{{ lacre_apt }}"
update_cache: yes
- name: '[Install] - Make sure Lacre home exists'
file:
path: '{{ lacre_homedir }}'
state: directory
owner: '{{ lacre_username }}'
group: '{{ lacre_group }}'
- name: '[Install] - Make sure Lacre .gnupg dir exists'
file:
path: '{{ lacre_homedir }}/.gnupg'
state: directory
owner: '{{ lacre_username }}'
group: '{{ lacre_group }}'
mode: '700'
- name: '[Install] - Make sure Lacre smime dir exists'
file:
path: '{{ lacre_homedir }}/smime'
state: directory
owner: '{{ lacre_username }}'
group: '{{ lacre_group }}'
mode: '700'
- name: '[INSTALL] - Install lacre backend requirenments'
pip:
requirements: "{{ lacre_app_dir }}/requirements.txt"
virtualenv: '{{ lacre_homedir }}/venv'
virtualenv_site_packages: yes
- name: '[Install] - Link GnuPG Lacre to virtualenv python modules'
file:
src: '{{ lacre_app_dir }}/GnuPG'
dest: '{{ lacre_homedir }}/venv/lib/python{{ lacre_python_version }}/site-packages/GnuPG'
state: link
- name: '[Install] - Link Lacre module to virtualenv python modules'
file:
src: '{{ lacre_app_dir }}/lacre'
dest: '{{ lacre_homedir }}/venv/lib/python{{ lacre_python_version }}/site-packages/lacre'
state: link
- name: '[INSTALL] - Set cron file permission'
file:
path: '{{ lacre_app_dir }}/webgate-cron.py'
state: 'file'
mode: 'a+x'
owner: '{{ lacre_username }}'
group: '{{ lacre_group }}'
when: lacre_webgate_cron == 'true'
- name: '[INSTALL] - Set cron'
cron:
name: "Lacre-webgate cronjob"
state: present
minute: "*/3"
hour: "*"
day: "*"
month: "*"
weekday: "*"
user: "{{ lacre_username }}"
job: '{{ lacre_homedir }}/venv/bin/python{{ lacre_python_version }} {{ lacre_app_dir }}/webgate-cron.py > /dev/null'
when: lacre_webgate_cron == 'true'
- name: Check if the database exists
shell:
cmd: mysql -h {{ lacre_db_host }} -u {{ lacre_db_username }} -p{{ lacre_db_password }} {{ lacre_db_name }} -se "SHOW TABLES;" | wc -l
register: lacre_db_info
ignore_errors: yes
- name: '[INSTALL] - Run dbschema'
shell:
cmd: '{{ lacre_homedir }}/venv/bin/python{{ lacre_python_version }} {{ lacre_app_dir }}/lacre/admin.py db -i'
become: 'yes'
become_user: '{{ lacre_username }}'
when: lacre_db_info.stdout != '3'