Skip to content

Commit

Permalink
refactor scripts to inventories
Browse files Browse the repository at this point in the history
  • Loading branch information
rkm committed Nov 29, 2023
1 parent 7f49893 commit d70dab2
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 25 deletions.
12 changes: 1 addition & 11 deletions bin/build-docker-aio
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,7 @@ docker container rm -f "${CONTAINER_NAME}" || true
docker run --rm -d --name "${CONTAINER_NAME}" "${IMAGE}:build"

ansible-playbook \
--connection docker \
--inventory "${CONTAINER_NAME}," \
--limit "${CONTAINER_NAME}" \
-e "ansible_python_interpreter=python3.10" \
-e "smi_preflight_group_name=smi" \
-e "smi_preflight_allow_create_group=true" \
-e "host_role='Docker AIO'" \
-e "smi_service_software_allow_create_install_dir=true" \
-e "smi_service_software_allow_create_logs_dir=true" \
-e "smi_service_software_allow_create_pacs_dir=true" \
-e "smi_service_software_allow_create_extract_dir=true" \
--inventory inventories/docker-aio/hosts.ini \
"${@}" \
site.yml

Expand Down
12 changes: 7 additions & 5 deletions bin/start-docker-services
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@

set -euxo pipefail

# NOTE(rkm 2023-11-29) Use the current python interpreter instead
# of the system default
local_python="$(command -v python || true)"

ansible-playbook \
--connection local \
--inventory "localhost," \
-e "ansible_python_interpreter=$(command -v python || true)" \
-e "smi_preflight_group_name=${USER}" \
--inventory inventories/local/hosts.ini \
-e "ansible_python_interpreter=${local_python}" \
-e "smi_docker_services_state=present" \
--tags docker \
--tags none,docker \
"${@}" \
site.yml
12 changes: 7 additions & 5 deletions bin/stop-docker-services
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@

set -euxo pipefail

# NOTE(rkm 2023-11-29) Use the current python interpreter instead
# of the system default
local_python="$(command -v python || true)"

ansible-playbook \
--connection local \
--inventory "localhost," \
-e "ansible_python_interpreter=$(command -v python || true)" \
-e "smi_preflight_group_name=${USER}" \
--inventory inventories/local/hosts.ini \
-e "ansible_python_interpreter=${local_python}" \
-e "smi_docker_services_state=absent" \
--tags docker \
--tags none,docker \
"${@}" \
site.yml
5 changes: 5 additions & 0 deletions inventories/docker-aio/group_vars/all.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
smi_preflight_group_name: smi
smi_fs_software_root: "/opt/epcc/smi/software"
smi_fs_data_root: "/opt/epcc/smi/data"
smi_base_dirs_allow_create_dirs: true
10 changes: 10 additions & 0 deletions inventories/docker-aio/hosts.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[all]
docker_aio_build

[all:vars]
ansible_connection=docker
ansible_python_interpreter=python3.10
host_role='Docker AIO'

[file_server]
docker_aio_build
10 changes: 8 additions & 2 deletions inventories/local/hosts.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
[all]
localhost ansible_connection=local
localhost

[all:vars]
ansible_connection=local

[file_server]
localhost

[primary_file_server]
[docker_host]
localhost
4 changes: 2 additions & 2 deletions site.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@
- 01-system
tags: [system]
- name: Start Docker services
hosts: all
hosts: docker_host
roles:
- 02-docker-services
tags: [never, docker]
- name: Install service software on primary file server
hosts: primary_file_server,smi_aio_build
hosts: file_server
pre_tasks:
- name: Assert required variables are defined
ansible.builtin.assert:
Expand Down

0 comments on commit d70dab2

Please sign in to comment.