[Cleanup] lxc-solr

Replaced direct call to lxc-attach with the lxc_container module calling
a container_command.

(+ spaces before and after variable name)
This commit is contained in:
Mathieu Trossevin 2020-06-19 12:18:33 +02:00
parent 5cf81335e6
commit d206ae4c85
Signed by: mtrossevin
GPG Key ID: 81987323AE7F3E99
2 changed files with 26 additions and 8 deletions

View File

@ -11,6 +11,6 @@
with_items:
- "{{ lxc_containers }}"
- include: "solr.yml name={{item.name}} solr_version={{item.solr_version}} solr_port={{item.solr_port}}"
- include: "solr.yml name={{ item.name }} solr_version={{ item.solr_version }} solr_port={{ item.solr_port }}"
with_items:
- "{{ lxc_containers }}"

View File

@ -1,6 +1,9 @@
---
- name: Install openjdk-8-jre-headless and lsof packages
command: "lxc-attach -n {{name}} -- apt-get install -y openjdk-8-jre-headless lsof"
lxc_container:
name: "{{ name }}"
container_command: "apt-get install -y openjdk-8-jre-headless lsof"
state: started
- name: "Download Solr {{ solr_version }}"
get_url:
@ -15,10 +18,16 @@
remote_src: yes
- name: "Install Solr {{ solr_version }}"
command: "lxc-attach -n {{name}} -- /root/solr-{{ solr_version }}/bin/install_solr_service.sh /root/solr-{{ solr_version }}.tgz"
lxc_container:
name: "{{ name }}"
container_command: "/root/solr-{{ solr_version }}/bin/install_solr_service.sh /root/solr-{{ solr_version }}.tgz"
state: started
- name: "Stop Solr"
command: "lxc-attach -n {{name}} -- /etc/init.d/solr stop"
lxc_container:
name: "{{ name }}"
container_command: "/etc/init.d/solr stop"
state: started
ignore_errors: True
- name: "Make sure /home/solr exists"
@ -27,11 +36,17 @@
state: directory
mode: '0755'
- name: "Move Solr data directory to /home/solr/{{name}}"
command: "lxc-attach -n {{name}} -- mv /var/solr /home/solr/{{name}}"
- name: "Move Solr data directory to /home/solr/{{ name }}"
lxc_container:
name: "{{ name }}"
container_command: "mv /var/solr /home/solr/{{ name }}"
state: started
- name: "Create a symbolic link to /home/solr/{{name}}"
command: "lxc-attach -n {{name}} -- ln -s /home/solr/{{name}} /var/solr"
lxc_container:
name: "{{ name }}"
container_command: "ln -s /home/solr/{{ name }} /var/solr"
state: started
- name: "Set Solr port to {{ solr_port }}"
lineinfile:
@ -39,4 +54,7 @@
line: "SOLR_PORT={{ solr_port }}"
- name: "Start Solr"
command: "lxc-attach -n {{name}} -- /etc/init.d/solr start"
lxc_container:
name: "{{ name }}"
container_command: "/etc/init.d/solr start"
state: started