aboutsummaryrefslogtreecommitdiffstats
path: root/roles/solr/tasks/main.yml
blob: 0538a2a12d2705d6bf97a61ef010d4c8ed48cce2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
- name: install java
  dnf:
    name: java-17-openjdk-headless
    state: present

- name: create installation directory
  file:
    path: '{{ solr_install_dir }}'
    state: directory

- name: unpack solr tarball
  unarchive:
    src: '{{ solr_url }}'
    remote_src: yes
    dest: '{{ solr_install_dir }}'
    extra_opts:
      - '--strip-components=1'
  notify: restart solr

- name: add local user
  user:
    name: solr
    system: yes
    home: '{{ solr_data_dir }}'
    shell: /sbin/nologin
    create_home: no

- name: create data directory
  file:
    path: '{{ solr_data_dir }}'
    state: directory
    owner: solr
    group: solr
    mode: 0770

- name: create systemd unit
  template:
    src: etc/systemd/system/solr.service.j2
    dest: /etc/systemd/system/solr.service
  register: solr_unit

- name: reload systemd units
  systemd:
    daemon_reload: yes
  when: solr_unit.changed

- name: create config directory
  file:
    path: /etc/solr
    state: directory

- name: create EnvironmentFile
  template:
    src: etc/sysconfig/solr.j2
    dest: /etc/sysconfig/solr
  notify: restart solr

- name: create config files
  template:
    src: etc/solr/{{ item }}.j2
    dest: /etc/solr/{{ item }}
  loop:
    - log4j2.xml
    - solrconfig.xml
  notify: restart solr

- name: copy default solr configuration
  copy:
    src: '{{ solr_install_dir }}/server/solr/solr.xml'
    dest: '{{ solr_data_dir }}/solr.xml'
    remote_src: yes

- name: start solr
  systemd:
    name: solr
    enabled: yes
    state: started