diff options
author | Volodymyr Mytnyk <volodymyrx.mytnyk@intel.com> | 2019-02-25 12:24:15 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@opnfv.org> | 2019-02-25 12:24:15 +0000 |
commit | 4c995d8a3ad25afe2ad8d75d43c7519ce22797eb (patch) | |
tree | abec90e5e0ad9b4f32983e4d594aaf87a7ce7e41 | |
parent | 7b394e216fb921958380510a4b5dcc914704f02e (diff) | |
parent | 38c458e35a181e9cced957d733832c1e297e2e35 (diff) |
Merge "Yardstick container rabbitmq supervisor RUN state"
-rw-r--r-- | ansible/install.yaml | 3 | ||||
-rw-r--r-- | ansible/roles/configure_rabbitmq/tasks/main.yml | 37 | ||||
-rw-r--r-- | ansible/roles/configure_rabbitmq/templates/rabbitmq.sh.j2 | 20 | ||||
-rwxr-xr-x | docker/supervisor.sh | 12 |
4 files changed, 46 insertions, 26 deletions
diff --git a/ansible/install.yaml b/ansible/install.yaml index 184fa8607..558c48609 100644 --- a/ansible/install.yaml +++ b/ansible/install.yaml @@ -39,7 +39,8 @@ - { role: configure_gui, when: installation_mode != inst_mode_container_pull } - { role: download_trex, when: installation_mode != inst_mode_container_pull } - { role: install_trex, when: installation_mode != inst_mode_container_pull } - - { role: configure_rabbitmq, when: installation_mode == inst_mode_baremetal } + - role: configure_rabbitmq + install_mode: "{{ installation_mode }}" post_tasks: diff --git a/ansible/roles/configure_rabbitmq/tasks/main.yml b/ansible/roles/configure_rabbitmq/tasks/main.yml index 3ad60c1ea..59998abc0 100644 --- a/ansible/roles/configure_rabbitmq/tasks/main.yml +++ b/ansible/roles/configure_rabbitmq/tasks/main.yml @@ -12,19 +12,28 @@ # See the License for the specific language governing permissions and # limitations under the License. --- -- name: Restart rabbitmq - service: - name: rabbitmq-server - state: restarted +- block: + - name: Restart rabbitmq + service: + name: rabbitmq-server + state: restarted -- name: rabbitmqctl start_app - shell: rabbitmqctl start_app + - name: rabbitmqctl start_app + shell: rabbitmqctl start_app -- name: Configure rabbitmq - rabbitmq_user: - user: yardstick - password: yardstick - configure_priv: .* - read_priv: .* - write_priv: .* - state: present + - name: Configure rabbitmq + rabbitmq_user: + user: yardstick + password: yardstick + configure_priv: .* + read_priv: .* + write_priv: .* + state: present + when: install_mode == inst_mode_baremetal + +- name: Create rabbitmq file for supervisor + template: + src: rabbitmq.sh.j2 + dest: /etc/yardstick/rabbitmq.sh + mode: 0755 + when: install_mode == inst_mode_container diff --git a/ansible/roles/configure_rabbitmq/templates/rabbitmq.sh.j2 b/ansible/roles/configure_rabbitmq/templates/rabbitmq.sh.j2 new file mode 100644 index 000000000..a91565c01 --- /dev/null +++ b/ansible/roles/configure_rabbitmq/templates/rabbitmq.sh.j2 @@ -0,0 +1,20 @@ +#!/bin/bash
+trap "rabbitmqctl stop_app" EXIT
+
+rabbitmqctl stop_app
+service rabbitmq-server restart
+rabbitmqctl start_app
+
+tmp_file="/tmp/$(basename -- $0).configured"
+if [ ! -f "$tmp_file" ]; then
+ rabbitmqctl add_user yardstick yardstick
+ rabbitmqctl set_permissions -p / yardstick '.*' '.*' '.*'
+ touch "$tmp_file"
+fi
+
+while :
+do
+ sleep 5
+ service rabbitmq-server status > /dev/null 2>&1 || exit 1
+ rabbitmqctl report | grep "Status of node rabbit@`hostname`" > /dev/null 2>&1 || exit 1
+done
diff --git a/docker/supervisor.sh b/docker/supervisor.sh index bd17cfbc4..a4104c7fb 100755 --- a/docker/supervisor.sh +++ b/docker/supervisor.sh @@ -10,7 +10,6 @@ # nginx service start when boot supervisor_config='/etc/supervisor/conf.d/yardstick.conf' -rabbitmq_config='/etc/supervisor/conf.d/rabbitmq.conf' if [[ ! -e "${supervisor_config}" ]]; then @@ -24,18 +23,9 @@ command = service nginx restart [program:yardstick_uwsgi] directory = /etc/yardstick command = uwsgi -i yardstick.ini -EOF - -fi - -if [[ ! -e "${rabbitmq_config}" ]]; then - cat << EOF > "${rabbitmq_config}" [program:rabbitmq] -command = /bin/bash -c "service rabbitmq-server restart - rabbitmqctl start_app - rabbitmqctl add_user yardstick yardstick - rabbitmqctl set_permissions -p / yardstick '.*' '.*'" +command=/etc/yardstick/rabbitmq.sh EOF fi |