From cceda1774cbcacce5ed8760bc7309767d3830877 Mon Sep 17 00:00:00 2001 From: Natkeeran Date: Mon, 29 Jul 2019 15:50:15 -0400 Subject: [PATCH 1/2] separate solr tasks so it can be deployed to its own server --- inventory/vagrant/group_vars/solr.yml | 3 ++ roles/internal/webserver-app/meta/main.yml | 3 -- roles/internal/webserver-app/tasks/solr.yml | 34 ++++++--------------- solr.yml | 31 +++++++++++++++++++ 4 files changed, 44 insertions(+), 27 deletions(-) delete mode 100644 roles/internal/webserver-app/meta/main.yml diff --git a/inventory/vagrant/group_vars/solr.yml b/inventory/vagrant/group_vars/solr.yml index 3b72f1a4..958db565 100644 --- a/inventory/vagrant/group_vars/solr.yml +++ b/inventory/vagrant/group_vars/solr.yml @@ -4,3 +4,6 @@ solr_cores: - CLAW solr_install_path: /opt/solr + +solr_user: solr +solr_instance_conf_path: /var/solr/data/CLAW/conf diff --git a/roles/internal/webserver-app/meta/main.yml b/roles/internal/webserver-app/meta/main.yml deleted file mode 100644 index 792e9932..00000000 --- a/roles/internal/webserver-app/meta/main.yml +++ /dev/null @@ -1,3 +0,0 @@ ---- -dependencies: - - geerlingguy.solr diff --git a/roles/internal/webserver-app/tasks/solr.yml b/roles/internal/webserver-app/tasks/solr.yml index cae8a223..8e955bec 100644 --- a/roles/internal/webserver-app/tasks/solr.yml +++ b/roles/internal/webserver-app/tasks/solr.yml @@ -1,30 +1,16 @@ --- + +# Only tasks related to configuring search_api_solr are put here +# Solr server configuration should go into the solr playbook: https://github.com/Islandora-Devops/claw-playbook/blob/dev/solr.yml + +- name: Set default solr server host from hostvars + command: "{{ drush_path }} --root {{ drupal_core_path }} -y config-set search_api.server.default_solr_server backend_config.connector_config.host {{ hostvars[groups['solr'][0]].ansible_ssh_host }}" + register: set_search_api_config_host + changed_when: "'Do you want to update' in set_search_api_config.stdout" + - name: Set default solr server to point to CLAW core command: "{{ drush_path }} --root {{ drupal_core_path }} -y config-set search_api.server.default_solr_server backend_config.connector_config.core CLAW" - register: set_search_api_config + register: set_search_api_config_core changed_when: "'Do you want to update' in set_search_api_config.stdout" -- name: Get solr config files to copy - command: "find {{ webserver_document_root }}/drupal/web/modules/contrib/search_api_solr/solr-conf/7.x -type f" - register: files_to_copy - changed_when: false - -- name: Copy solr config files - copy: - src: "{{ item }}" - dest: "{{ solr_instance_conf_path }}" - owner: "{{ solr_user }}" - group: "{{ solr_user }}" - remote_src: True - with_items: - - "{{ files_to_copy.stdout_lines }}" - -# https://www.drupal.org/project/search_api_solr/issues/3015993 -- name: Set solr_install_path in solrcore.properties - lineinfile: - path: /var/solr/data/CLAW/conf/solrcore.properties - regexp: '^solr\.install\.dir=.*$' - line: solr.install.dir={{ solr_install_path }} - state: present - notify: restart solr diff --git a/solr.yml b/solr.yml index 3583169d..171b51a5 100644 --- a/solr.yml +++ b/solr.yml @@ -13,3 +13,34 @@ java_packages: - java-1.8.0-openjdk - geerlingguy.solr + + tasks: + - name: Unarchive solr config + unarchive: + src: "https://ftp.drupal.org/files/projects/search_api_solr-8.x-2.0.zip" + dest: /tmp + remote_src: yes + + - name: Get solr config files to copy + command: "find /tmp/search_api_solr/solr-conf/7.x -type f" + register: files_to_copy + changed_when: false + + - name: Copy solr config files + copy: + src: "{{ item }}" + dest: "{{ solr_instance_conf_path }}" + owner: "{{ solr_user }}" + group: "{{ solr_user }}" + remote_src: True + with_items: + - "{{ files_to_copy.stdout_lines }}" + + # https://www.drupal.org/project/search_api_solr/issues/3015993 + - name: Set solr_install_path in solrcore.properties + lineinfile: + path: "{{ solr_instance_conf_path }}/solrcore.properties" + regexp: '^solr\.install\.dir=.*$' + line: solr.install.dir={{ solr_install_path }} + state: present + notify: restart solr \ No newline at end of file From 652f919b900001dc6837c2767fdf870f8cd5299d Mon Sep 17 00:00:00 2001 From: Natkeeran Date: Tue, 13 Aug 2019 14:35:42 -0400 Subject: [PATCH 2/2] update ansible_ssh_host -> ansible_host --- inventory/vagrant/hosts | 2 +- roles/internal/webserver-app/tasks/solr.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/inventory/vagrant/hosts b/inventory/vagrant/hosts index 361c9000..7fa3e9b5 100644 --- a/inventory/vagrant/hosts +++ b/inventory/vagrant/hosts @@ -1,6 +1,6 @@ # Generated by Vagrant -default ansible_ssh_host=127.0.0.1 ansible_ssh_port=2222 ansible_ssh_private_key_file='.vagrant/machines/default/virtualbox/private_key' +default ansible_host=127.0.0.1 ansible_port=2222 ansible_ssh_private_key_file='.vagrant/machines/default/virtualbox/private_key' [karaf] default diff --git a/roles/internal/webserver-app/tasks/solr.yml b/roles/internal/webserver-app/tasks/solr.yml index 8e955bec..745e5224 100644 --- a/roles/internal/webserver-app/tasks/solr.yml +++ b/roles/internal/webserver-app/tasks/solr.yml @@ -5,7 +5,7 @@ # Solr server configuration should go into the solr playbook: https://github.com/Islandora-Devops/claw-playbook/blob/dev/solr.yml - name: Set default solr server host from hostvars - command: "{{ drush_path }} --root {{ drupal_core_path }} -y config-set search_api.server.default_solr_server backend_config.connector_config.host {{ hostvars[groups['solr'][0]].ansible_ssh_host }}" + command: "{{ drush_path }} --root {{ drupal_core_path }} -y config-set search_api.server.default_solr_server backend_config.connector_config.host {{ hostvars[groups['solr'][0]].ansible_host }}" register: set_search_api_config_host changed_when: "'Do you want to update' in set_search_api_config.stdout"