mirror of
https://git.lapiole.org/dani/ansible-roles.git
synced 2025-09-14 11:34:56 +02:00
Update to 2021-12-01 19:13
This commit is contained in:
8
roles/glpi/tasks/archive_post.yml
Normal file
8
roles/glpi/tasks/archive_post.yml
Normal file
@@ -0,0 +1,8 @@
|
||||
---
|
||||
|
||||
- import_tasks: ../includes/webapps_compress_archive.yml
|
||||
vars:
|
||||
- root_dir: "{{ glpi_root_dir }}"
|
||||
- version: "{{ glpi_current_version }}"
|
||||
tags: glpi
|
||||
|
9
roles/glpi/tasks/archive_pre.yml
Normal file
9
roles/glpi/tasks/archive_pre.yml
Normal file
@@ -0,0 +1,9 @@
|
||||
---
|
||||
|
||||
- import_tasks: ../includes/webapps_archive.yml
|
||||
vars:
|
||||
- root_dir: "{{ glpi_root_dir }}"
|
||||
- version: "{{ glpi_current_version }}"
|
||||
- db_name: "{{ glpi_mysql_db }}"
|
||||
tags: glpi
|
||||
|
20
roles/glpi/tasks/cleanup.yml
Normal file
20
roles/glpi/tasks/cleanup.yml
Normal file
@@ -0,0 +1,20 @@
|
||||
---
|
||||
|
||||
- name: Remove plugins archives
|
||||
file:
|
||||
path: "{{ glpi_root_dir }}/tmp/{{ glpi_plugins[item].url | urlsplit('path') | basename }}"
|
||||
state: absent
|
||||
with_items: "{{ glpi_plugins_to_install }}"
|
||||
when: glpi_plugins[item] is defined
|
||||
tags: glpi
|
||||
|
||||
- name: Remove temp files
|
||||
file: path={{ item }} state=absent
|
||||
with_items:
|
||||
- "{{ glpi_root_dir }}/tmp/glpi"
|
||||
- "{{ glpi_root_dir }}/tmp/glpi-{{ glpi_version }}.tgz"
|
||||
- "{{ glpi_root_dir }}/db_dumps"
|
||||
- /etc/backup/pre.d/glpi_{{ glpi_id }}_dump_db
|
||||
- /etc/backup/post.d/glpi_{{ glpi_id }}_rm_dump
|
||||
tags: glpi
|
||||
|
39
roles/glpi/tasks/conf.yml
Normal file
39
roles/glpi/tasks/conf.yml
Normal file
@@ -0,0 +1,39 @@
|
||||
---
|
||||
|
||||
- import_tasks: ../includes/webapps_webconf.yml
|
||||
vars:
|
||||
- app_id: glpi_{{ glpi_id }}
|
||||
- php_version: "{{ glpi_php_version }}"
|
||||
- php_fpm_pool: "{{ glpi_php_fpm_pool | default('') }}"
|
||||
tags: glpi
|
||||
|
||||
- name: Deploy glpi configuration
|
||||
template: src={{ item }}.j2 dest={{ glpi_root_dir }}/web/config/{{ item }} owner=root group={{ glpi_php_user }} mode=660
|
||||
with_items:
|
||||
- local_define.php
|
||||
- config_db.php
|
||||
tags: glpi
|
||||
|
||||
- name: Remove obsolete conf files
|
||||
file: path={{ glpi_root_dir }}/web/config/{{ item }} state=absent
|
||||
with_items:
|
||||
- config_path.php
|
||||
tags: glpi
|
||||
|
||||
- name: Init database
|
||||
command: "/bin/php{{ glpi_php_version }} {{ glpi_root_dir }}/web/bin/console -n db:install"
|
||||
when: glpi_install_mode == 'install'
|
||||
tags: glpi
|
||||
|
||||
- name: Upgrade database
|
||||
command: "/bin/php{{ glpi_php_version }} {{ glpi_root_dir }}/web/bin/console -n db:update"
|
||||
when: glpi_install_mode == 'upgrade'
|
||||
tags: glpi
|
||||
|
||||
- name: Deploy sso.php script
|
||||
template: src=sso.php.j2 dest={{ glpi_root_dir }}/web/sso.php
|
||||
tags: glpi
|
||||
|
||||
- name: Deploy logrotate conf
|
||||
template: src=logrotate.conf.j2 dest=/etc/logrotate.d/glpi_{{ glpi_id }}
|
||||
tags: glpi
|
24
roles/glpi/tasks/directories.yml
Normal file
24
roles/glpi/tasks/directories.yml
Normal file
@@ -0,0 +1,24 @@
|
||||
---
|
||||
|
||||
- name: Create directory structure
|
||||
file: path={{ item }} state=directory
|
||||
with_items:
|
||||
- "{{ glpi_root_dir }}"
|
||||
- "{{ glpi_root_dir }}/web"
|
||||
- "{{ glpi_root_dir }}/tmp"
|
||||
- "{{ glpi_root_dir }}/sessions"
|
||||
- "{{ glpi_root_dir }}/meta"
|
||||
- "{{ glpi_root_dir }}/backup"
|
||||
- "{{ glpi_root_dir }}/data"
|
||||
- "{{ glpi_root_dir }}/data/_files"
|
||||
- "{{ glpi_root_dir }}/data/_cache"
|
||||
- "{{ glpi_root_dir }}/data/_cron"
|
||||
- "{{ glpi_root_dir }}/data/_dumps"
|
||||
- "{{ glpi_root_dir }}/data/_graphs"
|
||||
- "{{ glpi_root_dir }}/data/_lock"
|
||||
- "{{ glpi_root_dir }}/data/_log"
|
||||
- "{{ glpi_root_dir }}/data/_pictures"
|
||||
- "{{ glpi_root_dir }}/data/_plugins"
|
||||
- "{{ glpi_root_dir }}/data/_rss"
|
||||
tags: glpi
|
||||
|
21
roles/glpi/tasks/facts.yml
Normal file
21
roles/glpi/tasks/facts.yml
Normal file
@@ -0,0 +1,21 @@
|
||||
---
|
||||
|
||||
- import_tasks: ../includes/webapps_set_install_mode.yml
|
||||
vars:
|
||||
- root_dir: "{{ glpi_root_dir }}"
|
||||
- version: "{{ glpi_version }}"
|
||||
tags: glpi
|
||||
- set_fact: glpi_install_mode={{ (install_mode == 'upgrade' and not glpi_manage_upgrade) | ternary('none',install_mode) }}
|
||||
tags: glpi
|
||||
- set_fact: glpi_current_version={{ current_version | default('') }}
|
||||
tags: glpi
|
||||
|
||||
- import_tasks: ../includes/get_rand_pass.yml
|
||||
vars:
|
||||
- pass_file: "{{ glpi_root_dir }}/meta/ansible_dbpass"
|
||||
when: glpi_mysql_pass is not defined
|
||||
tags: glpi
|
||||
- set_fact: glpi_mysql_pass={{ rand_pass }}
|
||||
when: glpi_mysql_pass is not defined
|
||||
tags: glpi
|
||||
|
5
roles/glpi/tasks/filebeat.yml
Normal file
5
roles/glpi/tasks/filebeat.yml
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
|
||||
- name: Deploy filebeat configuration
|
||||
template: src=filebeat.yml.j2 dest=/etc/filebeat/ansible_inputs.d/glpi_{{ glpi_id }}.yml
|
||||
tags: glpi,log
|
142
roles/glpi/tasks/install.yml
Normal file
142
roles/glpi/tasks/install.yml
Normal file
@@ -0,0 +1,142 @@
|
||||
---
|
||||
|
||||
- name: Install needed tools
|
||||
yum:
|
||||
name:
|
||||
- unzip
|
||||
- tar
|
||||
- bzip2
|
||||
- acl
|
||||
- mariadb
|
||||
tags: glpi
|
||||
|
||||
- name: Download glpi
|
||||
get_url:
|
||||
url: "{{ glpi_zip_url }}"
|
||||
dest: "{{ glpi_root_dir }}/tmp/"
|
||||
checksum: "sha1:{{ glpi_zip_sha1 }}"
|
||||
when: glpi_install_mode != "none"
|
||||
tags: glpi
|
||||
|
||||
- name: Extract glpi archive
|
||||
unarchive:
|
||||
src: "{{ glpi_root_dir }}/tmp/glpi-{{ glpi_version }}.tgz"
|
||||
dest: "{{ glpi_root_dir }}/tmp/"
|
||||
remote_src: yes
|
||||
when: glpi_install_mode != "none"
|
||||
tags: glpi
|
||||
|
||||
- name: Move the content of glpi to the correct top directory
|
||||
synchronize:
|
||||
src: "{{ glpi_root_dir }}/tmp/glpi/"
|
||||
dest: "{{ glpi_root_dir }}/web/"
|
||||
recursive: True
|
||||
delete: True
|
||||
rsync_opts:
|
||||
- '--exclude=/install/install.php'
|
||||
- '--exclude=/files/'
|
||||
- '--exclude=/config/glpicrypt.key'
|
||||
delegate_to: "{{ inventory_hostname }}"
|
||||
when: glpi_install_mode != "none"
|
||||
tags: glpi
|
||||
|
||||
- name: Remove unwanted files and directories
|
||||
file: path={{ glpi_root_dir }}/web/{{ item }} state=absent
|
||||
with_items:
|
||||
- files
|
||||
- install/install.php
|
||||
tags: glpi
|
||||
|
||||
- name: Build a list of installed plugins
|
||||
shell: find {{ glpi_root_dir }}/web/plugins -maxdepth 1 -mindepth 1 -type d -exec basename "{}" \;
|
||||
register: glpi_installed_plugins
|
||||
changed_when: False
|
||||
tags: glpi
|
||||
|
||||
- name: Download plugins
|
||||
get_url:
|
||||
url: "{{ glpi_plugins[item].url }}"
|
||||
dest: "{{ glpi_root_dir }}/tmp/"
|
||||
checksum: "sha1:{{ glpi_plugins[item].sha1 }}"
|
||||
when:
|
||||
- item not in glpi_installed_plugins.stdout_lines
|
||||
- glpi_plugins[item] is defined
|
||||
with_items: "{{ glpi_plugins_to_install }}"
|
||||
tags: glpi
|
||||
|
||||
- name: Extract plugins
|
||||
unarchive:
|
||||
src: "{{ glpi_root_dir }}/tmp/{{ glpi_plugins[item].url | urlsplit('path') | basename }}"
|
||||
dest: "{{ glpi_root_dir }}/web/plugins/"
|
||||
remote_src: yes
|
||||
when:
|
||||
- item not in glpi_installed_plugins.stdout_lines
|
||||
- glpi_plugins[item] is defined
|
||||
with_items: "{{ glpi_plugins_to_install }}"
|
||||
tags: glpi
|
||||
|
||||
# Some plugins have the directory name not matching the plugin name
|
||||
# Eg, glpi-dashboard-1.0.2 instead of dashboard. So it's removed as if it was an unmanaged plugin
|
||||
# If the prop rename_from is defined for the plugin, rename the dir
|
||||
- name: Rename plugin dir
|
||||
command: mv {{ glpi_root_dir }}/web/plugins/{{ glpi_plugins[item].rename_from }} {{ glpi_root_dir }}/web/plugins/{{ item }}
|
||||
args:
|
||||
creates: "{{ glpi_root_dir }}/web/plugins/{{ item }}"
|
||||
when: glpi_plugins[item].rename_from is defined
|
||||
loop: "{{ glpi_plugins_to_install }}"
|
||||
tags: glpi
|
||||
|
||||
- name: Build a list of installed plugins
|
||||
shell: find {{ glpi_root_dir }}/web/plugins -maxdepth 1 -mindepth 1 -type d -exec basename "{}" \;
|
||||
register: glpi_installed_plugins
|
||||
changed_when: False
|
||||
tags: glpi
|
||||
|
||||
- name: Remove unmanaged plugins
|
||||
file: path={{ glpi_root_dir }}/web/plugins/{{ item }} state=absent
|
||||
with_items: "{{ glpi_installed_plugins.stdout_lines }}"
|
||||
when: item not in glpi_plugins_to_install
|
||||
tags: glpi
|
||||
|
||||
- import_tasks: ../includes/webapps_create_mysql_db.yml
|
||||
vars:
|
||||
- db_name: "{{ glpi_mysql_db }}"
|
||||
- db_user: "{{ glpi_mysql_user }}"
|
||||
- db_server: "{{ glpi_mysql_server }}"
|
||||
- db_pass: "{{ glpi_mysql_pass }}"
|
||||
tags: glpi
|
||||
|
||||
- set_fact: glpi_db_created={{ db_created }}
|
||||
tags: glpi
|
||||
|
||||
- name: Deploy cron task
|
||||
cron:
|
||||
name: glpi_{{ glpi_id }}
|
||||
cron_file: glpi_{{ glpi_id }}
|
||||
user: "{{ glpi_php_user }}"
|
||||
job: "/bin/php{{ (glpi_php_version == '54') | ternary('',glpi_php_version) }} {{ glpi_root_dir }}/web/front/cron.php"
|
||||
minute: "*/5"
|
||||
tags: glpi
|
||||
|
||||
- name: Deploy backup scripts
|
||||
template: src={{ item }}_backup.j2 dest=/etc/backup/{{ item }}.d/glpi_{{ glpi_id }} mode=750
|
||||
loop:
|
||||
- pre
|
||||
- post
|
||||
tags: glpi
|
||||
|
||||
- name: Download the logo
|
||||
get_url:
|
||||
url: "{{ glpi_logo }}"
|
||||
dest: "{{ glpi_root_dir }}/web/pics/fd_logo.png"
|
||||
force: True
|
||||
when: glpi_logo is defined
|
||||
tags: glpi
|
||||
|
||||
- name: Download the login page logo
|
||||
get_url:
|
||||
url: "{{ glpi_login_logo }}"
|
||||
dest: "{{ glpi_root_dir }}/web/pics/login_logo_glpi.png"
|
||||
force: True
|
||||
when: glpi_login_logo is defined
|
||||
tags: glpi
|
14
roles/glpi/tasks/main.yml
Normal file
14
roles/glpi/tasks/main.yml
Normal file
@@ -0,0 +1,14 @@
|
||||
---
|
||||
|
||||
- include: user.yml
|
||||
- include: directories.yml
|
||||
- include: facts.yml
|
||||
- include: archive_pre.yml
|
||||
when: glpi_install_mode == 'upgrade'
|
||||
- include: install.yml
|
||||
- include: conf.yml
|
||||
- include: cleanup.yml
|
||||
- include: write_version.yml
|
||||
- include: archive_post.yml
|
||||
when: glpi_install_mode == 'upgrade'
|
||||
- include: filebeat.yml
|
8
roles/glpi/tasks/user.yml
Normal file
8
roles/glpi/tasks/user.yml
Normal file
@@ -0,0 +1,8 @@
|
||||
---
|
||||
|
||||
- import_tasks: ../includes/create_system_user.yml
|
||||
vars:
|
||||
- user: "{{ glpi_php_user }}"
|
||||
- comment: "PHP FPM for glpi {{ glpi_id }}"
|
||||
tags: glpi
|
||||
|
17
roles/glpi/tasks/write_version.yml
Normal file
17
roles/glpi/tasks/write_version.yml
Normal file
@@ -0,0 +1,17 @@
|
||||
---
|
||||
|
||||
- name: Write plugin versions
|
||||
shell: echo {{ glpi_plugins[item].version }} > {{ glpi_root_dir }}/meta/glpi_plugin_{{ item }}_ansible_version
|
||||
when:
|
||||
- item not in glpi_installed_plugins
|
||||
- glpi_plugins[item] is defined
|
||||
with_items: "{{ glpi_plugins_to_install }}"
|
||||
changed_when: False
|
||||
tags: glpi
|
||||
|
||||
- import_tasks: ../includes/webapps_post.yml
|
||||
vars:
|
||||
- root_dir: "{{ glpi_root_dir }}"
|
||||
- version: "{{ glpi_version }}"
|
||||
tags: glpi
|
||||
|
Reference in New Issue
Block a user