Skip to content

Commit

Permalink
Merge pull request #116 from idealista/features/#112
Browse files Browse the repository at this point in the history
Features/#112
  • Loading branch information
sorobon authored May 21, 2020
2 parents dfb12bf + 8aa7895 commit 053c470
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 17 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ All notable changes to this project will be documented in this file.
- *[#110](https://github.com/idealista/solrcloud_role/issues/110) Role fully compatible with solr 8.5.1* @sorobon
- *[#109](https://github.com/idealista/solrcloud_role/issues/109) Migration to molecule 3.x* @sorobon
- *[#113](https://github.com/idealista/solrcloud_role/issues/113) Rename role to solrcloud_role* @sorobon
- *[#112](https://github.com/idealista/solrcloud_role/issues/112) Improve agents management* @sorobon
### Fixed
- *[#106](https://github.com/idealista/solrcloud_role/issues/106) Extra space in SOLR_ULIMIT_CHECKS var in solr.in.sh.j2*
### Removed
Expand Down
2 changes: 1 addition & 1 deletion defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ solr_backup_repository:
# type: int

## Agent configuration (optional)

solr_agents_force_reinstall: false
solr_agents_template_path: "{{ playbook_dir }}/templates/agents"

# solr_agents_required_libs:
Expand Down
43 changes: 27 additions & 16 deletions tasks/agent.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,31 @@
- "{{ solr_agents_config }}"
- vm_opts

- name: SolrCloud | Agent installation | Check agent version
command: "cat {{ solr_installation_dir }}/{{ item.0.name }}/version.txt"
register: agent_version_checked
changed_when: false
ignore_errors: true
with_subelements:
- "{{ solr_agents_config }}"
- vm_opts

- name: SolrCloud | Agent installation | Download agent
get_url:
dest: "/tmp"
dest: "{{ solr_tmp_basedir }}"
url: "{{ item.download_url }}"
owner: "{{ solr_user }}"
group: "{{ solr_group }}"
register: agent_downloaded
with_items: '{{ solr_agents_config }}'
loop: "{{ solr_agents_config|flatten(levels=1) }}"
loop_control:
index_var: index
when: solr_agents_force_reinstall or not agent_file_exists.results[index].stat.exists or item.version != agent_version_checked.results[index].stdout or agent_version_checked.results[index].failed


- name: SolrCloud | Agent installation | Unarchive package
unarchive:
src: "/tmp/{{ item.download_url | basename }}"
src: "{{ solr_tmp_basedir }}/{{ item.download_url | basename }}"
dest: "{{ solr_installation_dir }}"
remote_src: true
owner: "{{ solr_user }}"
Expand All @@ -44,6 +57,15 @@
tags:
- skip_ansible_lint

- name: SolrCloud | Agent installation | Copy version number file
template:
src: "agents/version.txt.j2"
dest: "{{ solr_installation_dir }}/{{ item.name }}/version.txt"
owner: "{{ solr_user }}"
group: "{{ solr_group }}"
mode: 0644
with_items: '{{ solr_agents_config }}'

- name: SolrCloud | Agent installation | Check configuration files
set_fact:
solr_agent_configuration: "{{ solr_agent_configuration|default([]) + [ {'name': item.0.name, 'file': item.1, 'params': item.0.params}] }}"
Expand All @@ -57,6 +79,8 @@
dest: "{{ solr_installation_dir }}/{{ item.name }}/{{ item.file }}"
owner: "{{ solr_user }}"
group: "{{ solr_group }}"
when: agent_downloaded.changed
notify: restart SolrCloud
with_items:
- '{{ solr_agent_configuration }}'

Expand All @@ -66,16 +90,3 @@
with_subelements:
- "{{ solr_agents_config }}"
- vm_opts

# - name: SolrCloud | Agent installation | Check previous solr installation
# stat:
# path: /etc/default/solr.in.sh
# register: agent_previous_solr_exists

# - name: SolrCloud | Agent installation | Configuring SolrCloud init script with agents config
# template:
# src: "{{ solr_templates_dir }}/solr.in.sh.j2"
# dest: /etc/default/solr.in.sh
# force: true
# when: agent_previous_solr_exists.stat is defined and agent_previous_solr_exists.stat.exists == True
# notify: restart SolrCloud
1 change: 1 addition & 0 deletions templates/agents/version.txt.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{{ item.version }}

0 comments on commit 053c470

Please sign in to comment.