Skip to content

Commit

Permalink
Merge pull request #53 from ahembree/migrate-to-ansible-galaxy-docker…
Browse files Browse the repository at this point in the history
…-role

Migrate to ansible galaxy docker role
  • Loading branch information
ahembree authored Dec 13, 2023
2 parents 5fcc970 + c90b25d commit ff767c5
Show file tree
Hide file tree
Showing 14 changed files with 34 additions and 24 deletions.
34 changes: 14 additions & 20 deletions .github/workflows/run-playbook.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: GitHub Actions Testing
run-name: Test OS Deployments
name: HMS-Docker Install Tests
run-name: Test OS Installs
on:
push:
workflow_dispatch:
Expand All @@ -8,7 +8,7 @@ permissions:
contents: read

jobs:
Ubuntu22_Basic:
Ubuntu_22:
runs-on: ubuntu-22.04
steps:
- name: Check out repo code
Expand All @@ -17,25 +17,19 @@ jobs:
run: |
sudo apt update
sudo apt install ansible make python3-pip
- name: Run playbook
- name: Ensure base playbook requirements
run: |
mkdir -p ./vars/custom
cp vars/default/*.yml ./vars/custom
mv ./vars/custom/main.yml ./vars/custom/main_custom.yml
sudo ansible-playbook -i inventory --connection local hms-docker.yml --diff --extra-vars "hms_docker_compose_container_state=absent hms_docker_container_map.transmission.enabled=no hms_docker_container_map.plex.enabled=no is_github_runner=yes"
Ubuntu22_Advanced:
runs-on: ubuntu-22.04
steps:
- name: Check out repo code
uses: actions/checkout@v4
- name: Install ansible
run: |
sudo apt update
sudo apt install ansible make python3-pip
sudo make install-reqs
- name: Run playbook
run: |
mkdir -p ./vars/custom
cp roles/hmsdocker/defaults/main/*.yml ./vars/custom
mv ./vars/custom/main.yml ./vars/custom/main_custom.yml
sudo ansible-playbook -i inventory --connection local hms-docker.yml --diff --extra-vars "hms_docker_compose_container_state=absent hms_docker_container_map.transmission.enabled=no hms_docker_container_map.plex.enabled=no is_github_runner=yes"
run: >-
sudo ansible-playbook
-i inventory
--connection local
hms-docker.yml
--diff
--extra-vars "
is_github_runner=yes
"
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
# python stuff
__pycache__/

galaxy-roles/
vars/custom.yml
vars/custom/*
!vars/custom/main.yml
Expand Down
8 changes: 6 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,18 @@ advanced:
mv $(CUSTOM_CONF_DIR)/main.yml $(CUSTOM_CONF_DIR)/main_custom.yml; \
fi

check:
check: install-reqs
@ansible-playbook -i inventory --connection local hms-docker.yml --diff --check

apply:
apply: install-reqs
@ansible-playbook -i inventory --connection local hms-docker.yml --diff

install-reqs:
@ansible-galaxy install -r galaxy-requirements.yml -p ./galaxy-roles

help:
@echo make basic :: for a basic config
@echo make advanced :: for an advanced config
@echo make check :: check for any changes without doing anything \(diff\)
@echo make apply :: apply any changes identified in the diff
@echo make install-reqs :: installs ansible galaxy role requirements
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,8 @@ make advanced

NOTE: Re-running these commands will overwrite any existing files in the `vars/custom` directory

If you wish to add a user(s) to the `docker` group so they can run `docker` commands without using `sudo`, you can uncomment and modify the lines in `vars/default/docker.yml`, or just run (as a user with sudo/root access) `sudo usermod -aG docker <username>`

## Content Layout

By default, the content is laid out in the following directory structure, if you wish to change the install location, you must use the advanced configuration
Expand Down
2 changes: 2 additions & 0 deletions galaxy-requirements.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- src: geerlingguy.docker
- src: geerlingguy.pip
7 changes: 6 additions & 1 deletion hms-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,14 @@
vars:
regex: '[^A-Za-z0-9._-]'
replace: '_'
pip_install_packages:
- name: docker
version: "6.1.3"
- name: docker-compose

roles:
- docker
- galaxy-roles/geerlingguy.docker
- galaxy-roles/geerlingguy.pip

tasks:
- name: Ensure vars are loaded
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
1 change: 0 additions & 1 deletion roles/hmsdocker/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@
# env_file: "{{ compose_env.dest }}" # Commented out since this module defaults to using the .env file within the project_src location, but leaving just in case advanced users wish to point to a different location
when:
- not ansible_check_mode
- not is_github_runner|default(false)

- name: Sabnzbd additional config
when: container_enabled_sabnzbd
Expand Down
3 changes: 3 additions & 0 deletions vars/default/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# docker_users:
# - user1
# - user2

0 comments on commit ff767c5

Please sign in to comment.