Skip to content

Commit

Permalink
Merge branch 'improvement/enhance_some_ansible_roles' into testing/mc…
Browse files Browse the repository at this point in the history
…donnnj
  • Loading branch information
mcdonnnj committed Oct 16, 2024
2 parents 7cb06d9 + 79b554e commit c37072f
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 2 deletions.
10 changes: 9 additions & 1 deletion ansible/roles/cyhy_commander/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
---
#
# Make sure the cyhy-commander is not running before we make configuration changes
#
- name: Ensure cyhy-commander is stopped
ansible.builtin.service:
name: cyhy-commander
state: stopped

#
# Copy private key to new instance
#
Expand Down Expand Up @@ -34,7 +42,7 @@
ansible.builtin.service:
name: cyhy-commander
enabled: true
state: restarted
state: started

#
# Grab the files we need to create the "places" collection from cyhy-core
Expand Down
4 changes: 3 additions & 1 deletion ansible/roles/cyhy_dashboard/files/ncats-webui.service
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@
Description=ncats-webui service

[Service]
Type=simple
Type=oneshot
RemainAfterExit=yes
Restart=on-failure
RestartSec=10
User=cyhy
ExecStart=/usr/bin/make --directory /var/cyhy/ncats-webui/ dev-start
ExecStart=/usr/bin/make --directory /var/cyhy/ncats-webui/ dev-stop
23 changes: 23 additions & 0 deletions ansible/roles/mongo/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,19 @@
---
- name: Get service information
ansible.builtin.service_facts:

- name: Determine if cyhy-commander needs to be stopped
ansible.builtin.set_fact:
mongo_stop_commander: "{{ 'cyhy-commander' in ansible_facts.services and ansible_facts.services['cyhy-commander'].state != 'stopped' }}"

# This role will restart MongoDB no matter what which will make the
# cyhy-commander unhappy if it is running
- name: Stop the cyhy-commander service
ansible.builtin.service:
name: cyhy-commander
state: stopped
when: mongo_stop_commander

- name: Check if any mongo users already exist
ansible.builtin.command: mongo --eval 'db.getUsers()' admin
# This is a read-only operation
Expand Down Expand Up @@ -68,3 +83,11 @@
ansible.builtin.service:
name: mongod
state: restarted

# Since we would have stopped the cyhy-commander if it was running we need to
# start it back up.
- name: Start the cyhy-commander service
ansible.builtin.service:
name: cyhy-commander
state: started
when: mongo_stop_commander

0 comments on commit c37072f

Please sign in to comment.