-
-
Notifications
You must be signed in to change notification settings - Fork 72
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
692 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
######################################################################### | ||
# Title: Saltbox: Docker | Controller Tasks # | ||
# Author(s): salty # | ||
# URL: https://github.com/saltyorg/Saltbox # | ||
# -- # | ||
######################################################################### | ||
# GNU General Public License v3.0 # | ||
######################################################################### | ||
--- | ||
- name: Controller | Set Python version | ||
ansible.builtin.set_fact: | ||
docker_controller_python_version: "{{ 'python3' | ||
if ansible_distribution_version is version('22.04', '==') | ||
else 'python3.10' }}" | ||
|
||
- name: Controller | Check if venv folder exists | ||
ansible.builtin.stat: | ||
path: "/srv/docker-controller/venv" | ||
register: docker_controller_venv | ||
|
||
- name: Controller | Delete venv folder | ||
ansible.builtin.file: | ||
path: "/srv/docker-controller/venv" | ||
state: absent | ||
when: docker_controller_venv.stat.exists | ||
|
||
- name: Controller | Install pip requirements | ||
ansible.builtin.pip: | ||
requirements: "/srv/git/saltbox/scripts/saltbox_docker_controller_requirements.txt" | ||
virtualenv_python: "{{ docker_controller_python_version }}" | ||
virtualenv: "/srv/docker-controller/venv" | ||
become: true | ||
become_user: "{{ user.name }}" | ||
|
||
- name: Controller | Find pip3 path | ||
ansible.builtin.find: | ||
paths: "/srv/docker-controller/venv" | ||
recurse: yes | ||
patterns: 'uvicorn' | ||
register: docker_controller_venv_files | ||
|
||
- name: Controller | Path | ||
ansible.builtin.set_fact: | ||
docker_controller_uvicorn_path: "{{ docker_controller_venv_files.files[0].path }}" | ||
|
||
- name: Controller | Import 'saltbox_managed_docker_controller.service' | ||
ansible.builtin.template: | ||
src: docker-controller.service.j2 | ||
dest: /etc/systemd/system/saltbox_managed_docker_controller.service | ||
mode: "0644" | ||
force: true | ||
|
||
- name: Controller | Enable 'saltbox_managed_docker_controller.service' | ||
ansible.builtin.systemd_service: | ||
name: saltbox_managed_docker_controller | ||
enabled: true | ||
state: restarted | ||
daemon_reload: true | ||
|
||
- name: "Controller | Wait for 10 seconds" | ||
ansible.builtin.wait_for: | ||
timeout: "10" | ||
|
||
- name: Controller | Import 'saltbox_managed_docker_controller.service' | ||
ansible.builtin.template: | ||
src: docker-controller-helper.service.j2 | ||
dest: /etc/systemd/system/saltbox_managed_docker_controller_helper.service | ||
mode: "0644" | ||
force: true | ||
|
||
- name: Controller | Enable 'saltbox_managed_docker_controller_helper.service' | ||
ansible.builtin.systemd_service: | ||
name: saltbox_managed_docker_controller_helper.service | ||
enabled: true | ||
state: started | ||
daemon_reload: true |
24 changes: 24 additions & 0 deletions
24
roles/docker/templates/docker-controller-helper.service.j2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# /etc/systemd/system/saltbox_managed_docker_controller_helper.service | ||
######################################################################### | ||
# Title: Saltbox: Docker Controller Helper # | ||
# Author(s): salty # | ||
# URL: https://github.com/saltyorg/Saltbox # | ||
# -- # | ||
######################################################################### | ||
# GNU General Public License v3.0 # | ||
######################################################################### | ||
[Unit] | ||
Description=Saltbox Docker Controller Helper | ||
Requires=docker.service | ||
After=docker.service | ||
PartOf=docker.service | ||
|
||
[Service] | ||
Type=simple | ||
ExecStart=/srv/git/saltbox/scripts/saltbox_docker_controller_helper.sh | ||
ExecStop=/bin/kill $MAINPID | ||
TimeoutStartSec=360 | ||
TimeoutStopSec=360 | ||
|
||
[Install] | ||
WantedBy=multi-user.target |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# /etc/systemd/system/saltbox_managed_docker_controller.service | ||
######################################################################### | ||
# Title: Saltbox: Docker Controller # | ||
# Author(s): salty # | ||
# URL: https://github.com/saltyorg/Saltbox # | ||
# -- # | ||
######################################################################### | ||
# GNU General Public License v3.0 # | ||
######################################################################### | ||
[Unit] | ||
Description=Saltbox Docker Controller | ||
|
||
[Service] | ||
Type=simple | ||
WorkingDirectory=/srv/git/saltbox/scripts | ||
ExecStart={{ docker_controller_uvicorn_path }} saltbox_docker_controller:app --host 127.0.0.1 --port 3377 | ||
Restart=on-failure | ||
RestartSec=5s | ||
|
||
[Install] | ||
WantedBy=multi-user.target |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.