2020-07-06 13:24:10 +02:00
|
|
|
---
|
2020-07-06 14:57:59 +02:00
|
|
|
- block:
|
|
|
|
- name: Create the orientdb user
|
|
|
|
user: name={{ orientdb_user }} home={{ orientdb_base_dir }} createhome=yes shell=/bin/bash
|
|
|
|
|
|
|
|
- name: Get the orientdb distribution
|
|
|
|
get_url: url={{ orientdb_binary_distribution_url }} dest={{ orientdb_base_dir }}/{{ orientdb_tar_file }} validate_certs=no
|
|
|
|
|
|
|
|
- name: Unpack the orientdb distribution
|
|
|
|
unarchive: src={{ orientdb_base_dir }}/{{ orientdb_tar_file }} dest={{ orientdb_base_dir }} copy=no
|
|
|
|
args:
|
|
|
|
creates: '{{ orientdb_home_prefix }}/{{ orientdb_user }}/{{ orientdb_dir }}-{{ orientdb_version }}'
|
|
|
|
|
|
|
|
- name: Link to the latest version
|
|
|
|
become: True
|
|
|
|
become_user: '{{ orientdb_user }}'
|
|
|
|
file: src={{ orientdb_tar_filename }} dest={{ orientdb_install_dir }} state=link
|
|
|
|
|
|
|
|
- name: Create a orientdb log directory out of the distribution directory
|
|
|
|
file: dest={{ orientdb_log_dir }} state=directory owner={{ orientdb_user }} group={{ orientdb_user }} mode=0755
|
|
|
|
|
|
|
|
- name: Link the log directory inside the orientdb user home
|
|
|
|
become: True
|
|
|
|
become_user: '{{ orientdb_user }}'
|
|
|
|
file: dest={{ orientdb_home_prefix }}/{{ orientdb_user }}/logs src={{ orientdb_log_dir }} state=link
|
|
|
|
|
|
|
|
- name: Create the needed directory inside the orientdb user home
|
|
|
|
become: True
|
|
|
|
become_user: '{{ orientdb_user }}'
|
|
|
|
file: dest={{ item }} state=directory mode=0750
|
|
|
|
with_items:
|
|
|
|
- '{{ orientdb_data_dir }}'
|
|
|
|
- '{{ orientdb_pid_dir }}'
|
|
|
|
- '{{ orientdb_automatic_backup_directory }}'
|
|
|
|
|
|
|
|
- name: Remove the old hook jars
|
|
|
|
shell: rm -f {{ orientdb_install_dir }}/lib/{{ item }}
|
|
|
|
with_items: '{{ orientdb_hooks_to_be_removed | default([]) }}'
|
|
|
|
tags: [ 'orientdb', 'orientdb_hooks' ]
|
|
|
|
|
|
|
|
- name: Fetch and install the hook jars
|
|
|
|
get_url: url='{{ item }}' dest={{ orientdb_install_dir }}/lib
|
|
|
|
with_items: '{{ orientdb_hooks_jars | default([]) }}'
|
|
|
|
notify: Restart orientdb
|
|
|
|
tags: [ 'orientdb', 'orientdb_hooks' ]
|
|
|
|
|
|
|
|
- name: Install the orientdb default settings
|
|
|
|
template: src=orientdb.default.j2 dest=/etc/default/orientdb owner=root group=root mode=0444
|
|
|
|
notify: Restart orientdb
|
|
|
|
|
|
|
|
- name: Fix the pid file path inside the start and shutdown scripts
|
|
|
|
lineinfile: dest={{ orientdb_install_dir }}/bin/{{ item }} regexp="^ORIENTDB_PID=.*$" line="ORIENTDB_PID={{ orientdb_pid_dir }}/orientdb.pid" insertafter="^PRG=.*$" firstmatch=yes
|
|
|
|
with_items:
|
|
|
|
- server.sh
|
|
|
|
- shutdown.sh
|
|
|
|
tags: [ 'orientdb', 'orientdb_pid' ]
|
|
|
|
|
|
|
|
- name: Install the orientdb configuration files
|
|
|
|
template: src={{ item }}.j2 dest={{ orientdb_install_dir }}/config/{{ item }} owner={{ orientdb_user }} group={{ orientdb_user }} mode=0640
|
|
|
|
with_items: '{{ orientdb_configuration_files }}'
|
|
|
|
notify: Restart orientdb
|
|
|
|
tags: [ 'orientdb', 'orientdb_config' ]
|
|
|
|
|
|
|
|
- name: Install the nagios nrpe configuration
|
|
|
|
template: src=orientdb-nrpe.cfg.j2 dest={{ nrpe_include_dir }}/orientdb-nrpe.cfg owner=root group=root mode=0444
|
|
|
|
notify: Reload NRPE server
|
|
|
|
when:
|
|
|
|
- nrpe_include_dir is defined
|
|
|
|
- nagios_enabled is defined and nagios_enabled
|
|
|
|
tags: [ 'orientdb', 'orientdb_nagios' ]
|
|
|
|
|
|
|
|
- name: Install the orientdb SYSV startup script
|
|
|
|
template: src=orientdb.init.j2 dest=/etc/init.d/orientdb owner=root group=root mode=0755
|
|
|
|
tags: [ 'orientdb', 'orientdb_init' ]
|
|
|
|
when: ansible_service_mgr != 'systemd'
|
|
|
|
|
|
|
|
- name: Install the orientdb systemd unit
|
|
|
|
template: src=orientdb.service.j2 dest=/usr/lib/systemd/system/orientdb.service owner=root group=root mode=0644
|
|
|
|
tags: [ 'orientdb', 'orientdb_init' ]
|
|
|
|
when: ansible_service_mgr == 'systemd'
|
|
|
|
register: reload_systemd
|
|
|
|
|
|
|
|
- name: Reload the systemd service
|
|
|
|
systemd:
|
|
|
|
daemon_reload: yes
|
|
|
|
when: reload_systemd is changed
|
|
|
|
|
|
|
|
- name: Ensure that the service is enabled and running
|
|
|
|
service: name=orientdb state=started enabled=yes
|
|
|
|
when: orientdb_enabled
|
|
|
|
|
|
|
|
- name: Ensure that the service is stopped and disabled
|
|
|
|
service: name=orientdb state=stopped enabled=no
|
|
|
|
when: not orientdb_enabled
|
|
|
|
|
|
|
|
tags: orientdb
|
|
|
|
when: orientdb_install
|
|
|
|
|
|
|
|
- block:
|
|
|
|
- name: Install a script that removes the old orientdb backups
|
|
|
|
template: src=backup-cleaner.sh.j2 dest=/usr/local/bin/orientdb-backup-cleaner owner=root group=root mode=555
|
|
|
|
|
|
|
|
- name: Add a cron job that removes the old backups
|
|
|
|
cron:
|
|
|
|
cron_file: 'orientdb-backup-cleaner'
|
|
|
|
disabled: no
|
|
|
|
job: "/usr/local/bin/orientdb-backup-cleaner >/dev/null 2>&1"
|
|
|
|
special_time: daily
|
|
|
|
user: '{{ orientdb_user }}'
|
|
|
|
name: "Remove old orientdb backups"
|
|
|
|
state: present
|
|
|
|
|
|
|
|
tags: [ 'orientdb', 'orientdb_backup' ]
|
|
|
|
when: orientdb_install
|
|
|
|
|
|
|
|
|
|
|
|
- block:
|
|
|
|
- name: Create the acme hooks directory if it does not yet exist
|
|
|
|
file: dest={{ letsencrypt_acme_services_scripts_dir }} state=directory owner=root group=root
|
|
|
|
|
|
|
|
- name: Install a letsencrypt hook to update the orientdb certificate
|
|
|
|
template: src=orientdb-letsencrypt-acme.sh.j2 dest={{ letsencrypt_acme_services_scripts_dir }}/orientdb owner=root group=root mode=4555
|
|
|
|
|
|
|
|
tags: [ 'orientdb', 'letsencrypt', 'orientdb_letsencrypt' ]
|
|
|
|
when:
|
|
|
|
- orientdb_install
|
|
|
|
- orientdb_letsencrypt_ssl_enabled
|
|
|
|
|
|
|
|
- block:
|
|
|
|
- name: Ensure that the service is disabled and stopped
|
|
|
|
service: name=orientdb state=stopped enabled=no
|
|
|
|
|
|
|
|
- name: Remove the orientdb SysV startup file
|
|
|
|
file: dest=/etc/init.d/orientdb state=absent
|
|
|
|
when: ansible_service_mgr != 'systemd'
|
|
|
|
|
|
|
|
- name: Remove the orientdb systemd unit
|
|
|
|
file: dest=/usr/lib/systemd/system/orientdb.service state=absent
|
|
|
|
when: ansible_service_mgr == 'systemd'
|
|
|
|
|
|
|
|
- name: Remove the link to the orientdb distribution
|
|
|
|
file: dest={{ orientdb_home_prefix }}/{{ orientdb_user }}/{{ orientdb_dir }} state=absent
|
|
|
|
|
|
|
|
- name: Remove the default options file
|
|
|
|
file: dest=/etc/default/orientdb state=absent
|
|
|
|
|
|
|
|
- name: Remove the backup cleaner script
|
|
|
|
file: dest=/usr/local/bin/orientdb-backup-cleaner state=absent
|
|
|
|
|
|
|
|
- name: Remove the backup cleaner cron job
|
|
|
|
cron:
|
|
|
|
cron_file: 'orientdb-backup-cleaner'
|
|
|
|
disabled: no
|
|
|
|
job: "/usr/local/bin/orientdb-backup-cleaner >/dev/null 2>&1"
|
|
|
|
special_time: daily
|
|
|
|
user: '{{ orientdb_user }}'
|
|
|
|
name: "Remove old orientdb backups"
|
|
|
|
state: absent
|
|
|
|
|
|
|
|
tags: orientdb
|
|
|
|
when: not orientdb_install
|
|
|
|
|