ahembree / ansible-hms-docker

Ansible playbook for automated home media server setup
GNU General Public License v3.0
402 stars 51 forks source link

"Error starting project 'ContainerConfig'" #63

Closed LewisLebentz closed 4 months ago

LewisLebentz commented 4 months ago

I installed some updates, and tried to make some var changes (just adding a custom ovpn location), and now I'm unable to run make apply without it failing with this error:

TASK [hmsdocker : Ensure containers defined in compose file.] *** fatal: [localhost]: FAILED! => {"changed": false, "errors": ["ERROR: for 722c8e35b6df_bazarr 'ContainerConfig'"], "module_stderr": "Recreating a6fddf7b912f_portainer ... \nRecreating 722c8e35b6df_bazarr ... \nRecreating 5f5ba7a164ed_prowlarr ... \nRecreating 401c53621034_radarr ... \nRecreating e6c5bbc6e2a0_requestrr ... \nRecreating 7f234c8a87c2_plex ... \nRecreating a417ced53cfb_transmission ... \nRecreating 2a7b66f2062a_cloudflare-tunnel ... \n\nERROR: for 722c8e35b6df_bazarr 'ContainerConfig'\nRecreating 519440a76d8b_overseerr ... \nRecreating 8a96b530e81e_sonarr ... \nRecreating d16768142c0d_tautulli ... \n", "module_stdout": "", "msg": "Error starting project 'ContainerConfig'"}

Every time I run it, it shows the error for a different container, it's not specific to a particular one, a quick Google looks like some Docker changes may have caused this issue, but really can't figure out what's wrong.

ahembree commented 4 months ago

I had this issue as well a couple weeks ago I think but thought it may have been something on my system specifically during my development testing.

I ended up fixing by running sudo docker-compose down and then sudo docker-compose up -d while in the /opt/hms-docker directory. Unfortunately this prefixes the container names with a random string, so it might be due to a Docker update, I'll investigate a bit further and see what, if any, changes are needed.

ahembree commented 4 months ago

Found a solution here: https://askubuntu.com/questions/1508129/docker-compose-giving-containerconfig-errors-after-update-today

Currently working on a patch to also work with existing configs since they change some of the ansible values around, but it's an issue with the docker compose portion of ansible with the v2 release

jrel commented 4 months ago

Hello, after my investigation, I realized this issue is directly linked to a significant change in the docker-compose API. You can read more here

I made this change in my version, and it works for me!

diff --git a/roles/hmsdocker/defaults/main/container_settings.yml b/roles/hmsdocker/defaults/main/container_settings.yml
index 2f8f7bc..2c423c8 100644
--- a/roles/hmsdocker/defaults/main/container_settings.yml
+++ b/roles/hmsdocker/defaults/main/container_settings.yml
@@ -23,7 +23,7 @@ container_uid: 1234
 container_gid: 1234

 # This will download all of the containers before attempting to start them // default: "yes"
-container_pull_images_first: yes
+container_pull_images_first: always

 # This will expose each containers individual ports on the host (check the README for more info on which ports map to which containers) // default: "no"
 # If you disable traefik within the container map, the playbook will automatically override this setting and expose the ports
diff --git a/roles/hmsdocker/tasks/main.yml b/roles/hmsdocker/tasks/main.yml
index b5ea1db..fd97296 100644
--- a/roles/hmsdocker/tasks/main.yml
+++ b/roles/hmsdocker/tasks/main.yml
@@ -106,7 +106,7 @@
     trim_blocks: yes

 - name: Ensure containers defined in compose file.
-  community.docker.docker_compose:
+  community.docker.docker_compose_v2:
     project_src: "{{ hms_docker_data_path }}"
     project_name: "{{ project_name }}"
     pull: "{{ container_pull_images_first }}"
ahembree commented 4 months ago

I've created a new branch for this here: https://github.com/ahembree/ansible-hms-docker/tree/fix-ansible-docker-deployment

Currently working on a way to update the config files while allowing it to still work with previous configurations so people don't have to update multiple files in order to get it back into a working state

jrel commented 4 months ago

The options for pull parameter as changed:

https://docs.ansible.com/ansible/latest/collections/community/docker/docker_compose_module.html#parameter-pull https://docs.ansible.com/ansible/latest/collections/community/docker/docker_compose_v2_module.html#parameter-pull

jrel commented 4 months ago

Probably you can have a verification to change yes to always and no to policy (default value in new module)

ahembree commented 4 months ago

Ended up opting to remove that pull setting entirely since the defaults seem safe enough. Based on what I'm reading, it reads like always will always download the current image version, even if it already exists. I decided to not do always due to people potentially having data caps/quotas from their ISP, and redownloading an already-existing image seems unnecessary.

ahembree commented 4 months ago

This should now be resolved in https://github.com/ahembree/ansible-hms-docker/commit/47018fa580413db3a7fd13fb328eacbf0d7b0cfa

LewisLebentz commented 4 months ago

I'm now getting this error after updating:

ERROR! couldn't resolve module/action 'community.docker.docker_compose_v2'. This often indicates a misspelling, missing collection, or incorrect module path.

The error appears to be in '/home/lewis/ansible-hms-docker/roles/hmsdocker/tasks/main.yml': line 108, column 3, but may
be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:

- name: Ensure containers defined in compose file.
  ^ here
make: *** [Makefile:44: check] Error 4

I tried the fix here without any luck: https://github.com/geerlingguy/internet-pi/issues/577

ahembree commented 4 months ago

I think you may have to reinstall Ansible by running the following:

sudo apt remove ansible
sudo pip3 install -U ansible
ryu777mtg commented 4 months ago

I'm getting same issue as @LewisLebentz is getting spitting image of read out and all. Tried to uninstall and reinstall as suggested however nothing happens.

This is when getting to the make check step

Some info of Distro, OS, etc. Linux eon 6.1.21-v8+ #1642 SMP PREEMPT Mon Apr 3 17:24:16 BST 2023 aarch64 GNU/Linux

NAME="Debian GNU/Linux"
VERSION_ID="11"
VERSION="11 (bullseye)"
VERSION_CODENAME=bullseye
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"
ahembree commented 4 months ago

@ryu777mtg can you try running ansible-galaxy collection install community.docker and see if that fixes it, it's an issue with a missing ansible package/module

ryu777mtg commented 4 months ago

To no avail this is the output

ansible-galaxy collection install community.docker
Starting galaxy collection install process
Nothing to do. All requested collections are already installed. If you want to reinstall them, consider using `--force`.

More info on the output

make check
Starting galaxy role install process
[WARNING]: - geerlingguy.docker (7.1.0) is already installed - use --force to change version to unspecified
[WARNING]: - geerlingguy.pip (3.0.3) is already installed - use --force to change version to unspecified
[DEPRECATION WARNING]: Specifying a list of dictionaries for vars is deprecated in favor of specifying a dictionary.
This feature will be removed in version 2.18. Deprecation warnings can be disabled by setting
deprecation_warnings=False in ansible.cfg.
ERROR! couldn't resolve module/action 'community.docker.docker_compose_v2'. This often indicates a misspelling, missing collection, or incorrect module path.

The error appears to be in '/home/eon/ansible-hms-docker/roles/hmsdocker/tasks/main.yml': line 108, column 3, but may
be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:

- name: Ensure containers defined in compose file.
  ^ here
make: *** [Makefile:44: check] Error 4
ahembree commented 4 months ago

can you provide the output of ansible --version and ansible-galaxy collection list | grep docker command, I'm currently running ansible [core 2.16.6] with community.docker version 3.9.0

ryu777mtg commented 4 months ago

can you provide the output of ansible --version and ansible-galaxy collection list | grep docker command, I'm currently running ansible [core 2.16.6] with community.docker version 3.9.0

ansible [core 2.15.11] community.docker 3.4.11

ryu777mtg commented 4 months ago

Swapped from Debian to Ubuntu 22.04.4 LTS Make config changes run make check seems to go well until

TASK [hmsdocker : Ensure env] *****************************************************************************
fatal: [localhost]: FAILED! => {"censored": "the output has been hidden due to the fact that 'no_log: true' was specified for this result", "changed": false}

PLAY RECAP ************************************************************************************************
localhost                  : ok=22   changed=0    unreachable=0    failed=1    skipped=51   rescued=0    ignored=0

I feel like it may be a config issue of sorts but can't pin point it

ahembree commented 4 months ago

If you change line 89 in roles/hmsdocker/tasks/main.yml from true to false (https://github.com/ahembree/ansible-hms-docker/blob/master/roles/hmsdocker/tasks/main.yml#L89) it will then print out the error it is having, but it seems like a template issue, potentially due to a missing variable.

This task is not logged by default since this file is where secret keys are stored. If you choose to provide the output after changing the no_log option, please be sure to redact any sensitive key material or information

ryu777mtg commented 4 months ago

It's stating my Cloudflare API tokens are undefined however they are defined in the Traefik.yml

ahembree commented 4 months ago

Those should be configured in the vars/custom/cloudflare_ddns.yml or vars/custom/cloudflare.yml file as the cloudflare_api_token variable

ryu777mtg commented 4 months ago

So it finally went through however when trying to access plex.domain it states forbidden however the overseerr.domain does resolve but because the plex.domain is forbidden their is no way of continuing setup.

Aren't the host/subdomains defined automatically from the config? I saw under my cloudflare account where the overseerr record was created then made a cname record for plex pointing to the overseer.domain. Ports are forwarded properly in router but even locally cannot access the plex server.

All other subdomain eg. uptime-kuma, radarr, sonarr, lead to a forbidden page nothing is resolving some guidance on what would be causing this would be helpfull.

ahembree commented 4 months ago

I've moved this to a new issue, #68, as this has been going outside the original scope of this issue submission, I'll be closing this issue since the source of the original issue has been resolved.