ansible-role-orientdb/tasks/orientdb_install.yml

146 lines
5.4 KiB
YAML

---
- name: orientdb_install | OrientDB installation
tags: ['orientdb']
when: orientdb_install
block:
- name: orientdb_install | Create the orientdb user
ansible.builtin.user:
name: "{{ orientdb_user }}"
home: "{{ orientdb_base_dir }}"
createhome: false
shell: /bin/bash
- name: orientdb_install | Create the orientdb directories
ansible.builtin.file:
dest: "{{ item }}"
owner: "{{ orientdb_user }}"
group: "{{ orientdb_user }}"
mode: "0750"
state: directory
loop:
- "{{ orientdb_base_dir }}"
- "{{ orientdb_data_dir }}"
- name: orientdb_install | Get the orientdb distribution
ansible.builtin.get_url:
url: "{{ orientdb_binary_distribution_url }}"
dest: "{{ orientdb_base_dir }}/{{ orientdb_tar_file }}"
validate_certs: false
owner: root
group: root
mode: "0444"
- name: orientdb_install | Unpack the orientdb distribution
ansible.builtin.unarchive:
src: '{{ orientdb_base_dir }}/{{ orientdb_tar_file }}'
dest: '{{ orientdb_base_dir }}'
copy: false
owner: root
group: root
args:
creates: '{{ orientdb_home_prefix }}/{{ orientdb_user }}/{{ orientdb_dir }}-{{ orientdb_version }}'
- name: orientdb_install | Create some directories inside the orientdb user home
become: true
become_user: '{{ orientdb_user }}'
ansible.builtin.file:
dest: "{{ item }}"
state: directory
mode: "0750"
loop:
- '{{ orientdb_pid_dir }}'
- '{{ orientdb_automatic_backup_directory }}'
- name: orientdb_install | Link to the databases directory
become: true
become_user: '{{ orientdb_user }}'
ansible.builtin.file:
src: "{{ orientdb_data_dir }}"
dest: "{{ orientdb_link_to_data_dir }}"
state: link
- name: orientdb_install | Remove the demodb database
ansible.builtin.file:
dest: '{{ orientdb_home_prefix }}/{{ orientdb_user }}/{{ orientdb_dir }}-{{ orientdb_version }}/databases/demodb'
state: absent
- name: orientdb_install | Link to the latest version
become: true
become_user: '{{ orientdb_user }}'
ansible.builtin.file:
src: '{{ orientdb_tar_filename }}'
dest: '{{ orientdb_install_dir }}'
state: link
- name: orientdb_install | Create a link to the data directory
ansible.builtin.file:
src: '{{ orientdb_data_dir }}'
dest: '{{ orientdb_home_prefix }}/{{ orientdb_user }}/{{ orientdb_dir }}-{{ orientdb_version }}/databases'
state: link
owner: '{{ orientdb_user }}'
group: '{{ orientdb_user }}'
force: true
- name: orientdb_install | Create a orientdb log directory out of the distribution directory
ansible.builtin.file:
dest: '{{ orientdb_log_dir }}'
state: directory
owner: '{{ orientdb_user }}'
group: '{{ orientdb_user }}'
mode: '0755'
- name: orientdb_install | Link the log directory inside the orientdb user home
become: true
become_user: '{{ orientdb_user }}'
ansible.builtin.file:
src: "{{ orientdb_log_dir }}"
dest: "{{ orientdb_home_prefix }}/{{ orientdb_user }}/logs"
state: link
- name: orientdb_install | Remove the old hook jars
ansible.builtin.command: rm -f {{ orientdb_install_dir }}/lib/{{ item }}
loop: '{{ orientdb_hooks_to_be_removed | default([]) }}'
register: hook_jars_rm
changed_when: hook_jars_rm.rc
tags: ['orientdb', 'orientdb_hooks']
- name: orientdb_install | Fetch and install the hook jars
ansible.builtin.get_url:
url: "{{ item }}"
dest: "{{ orientdb_install_dir }}/lib"
owner: root
group: root
mode: "0644"
loop: '{{ orientdb_hooks_jars | default([]) }}'
notify: Restart orientdb
tags: ['orientdb', 'orientdb_hooks']
- name: orientdb_install | Install the orientdb default settings
ansible.builtin.template:
src: orientdb.default.j2
dest: /etc/default/orientdb
owner: root
group: root
mode: "0444"
notify: Restart orientdb
- name: orientdb_install | Fix the pid file path inside the start and shutdown scripts
ansible.builtin.lineinfile:
dest: '{{ orientdb_install_dir }}/bin/{{ item }}'
regexp: "^ORIENTDB_PID=.*$"
line: "ORIENTDB_PID={{ orientdb_pid_dir }}/orientdb.pid"
insertafter: "^PRG=.*$"
firstmatch: true
loop:
- server.sh
- shutdown.sh
tags: ['orientdb', 'orientdb_pid']
- name: orientdb_install | Install the orientdb configuration files
ansible.builtin.template:
src: '{{ item }}.j2'
dest: '{{ orientdb_install_dir }}/config/{{ item }}'
owner: '{{ orientdb_user }}'
group: '{{ orientdb_user }}'
mode: '0640'
loop: '{{ orientdb_configuration_files }}'
notify: Restart orientdb
tags: ['orientdb', 'orientdb_config']
- name: orientdb_install | Set the permissions of some configuration files
ansible.builtin.file:
dest: '{{ orientdb_install_dir }}/config/{{ item }}'
owner: '{{ orientdb_user }}'
group: '{{ orientdb_user }}'
mode: '0600'
loop:
- custom-sql-functions.json
- security.json
- orientdb-etl-log.properties
notify: Restart orientdb
tags: ['orientdb', 'orientdb_config']