Question

App deployment fails as my ansible template copy is not performed

Hello,

I am running through a weird behaviour when deploying my Dockerfile on App platform.

I use ansible to deploy my App, I have 2 roles that perform template copy. One is for gunicorn the other is for a settings file. The gunicorn file is well copied, while the settings is simply not copied.

Here are some logs with some debugging session I’ve performed:

  • Ansible display of settings file:
[2022-07-26 12:45:56]     "cmd": [
[2022-07-26 12:45:56]         "cat",
[2022-07-26 12:45:56]         "/crm-pilates/settings.ini"
[2022-07-26 12:45:56]     ],
...
[2022-07-26 12:45:56]     "stdout_lines": [
[2022-07-26 12:45:56]         "[DEFAULT]",
[2022-07-26 12:45:56]         "EVENT_STORE_PATH= PATH",
[2022-07-26 12:45:56]         "",
[2022-07-26 12:45:56]         "[CORS]",
[2022-07-26 12:45:56]         "CORS_ALLOW_ORIGINS= CORS",
[2022-07-26 12:45:56]         "",
[2022-07-26 12:45:56]         "[DATABASE]",
[2022-07-26 12:45:56]         "DATABASE_URL= "
[2022-07-26 12:45:56]     ]

There are no ansible errors at the end of the playbook run.

  • Python logs displaying directory files:
[2022-07-26 12:48:38] WARNING:root:Current main path /crm-pilates/crm_pilates/main.py
[2022-07-26 12:48:38] WARNING:root:Current working dir /crm-pilates
[2022-07-26 12:48:38] WARNING:root:Root dir: .dockerignore, .venv, Dockerfile, LICENSE, Makefile, README.md, crm_pilates, docker-compose.yml, local.persistent, log-config.json, poetry.lock, pyproject.toml, run.sh, scripts
[2022-07-26 12:48:38] WARNING:root:Module dir: __init__.py, __pycache__, api.py, command, domain, event, gunicorn.py, infrastructure, main.py, settings.py, web

you can see the gunicorn.py in the module dir but there are no settings.ini in the root dir where it should be.

Below are some logs from a local docker container (using the same deployment method):

WARNING:root:Current main path /crm-pilates/crm_pilates/main.py
WARNING:root:Current working dir /crm-pilates
WARNING:root:Root dir: crm_pilates, local.persistent, settings.ini, .venv, log-config.json, README.md, Makefile, pyproject.toml, scripts, docker-compose.yml, LICENSE, run.sh, poetry.lock, __pycache__, .dockerignore, Dockerfile
WARNING:root:Module dir: __init__.py, settings.py, api.py, main.py, command, event, infrastructure, domain, __pycache__, web, gunicorn.py

As you may see the settings.ini is present and the app is running fine on local docker.

Here is the ansible playbook command: $(virtualenv_path)/bin/ansible-playbook scripts/ansible/playbook.yml --inventory scripts/ansible/deploy.yml --diff -vvvv

the settings role:

- name: copy settings
  template:
    src: settings.ini
    dest: "{{ root_dir }}/settings.ini"

the server role (that copy gunicorn file):

- name: copy gunicorn configuration
  template:
    src: gunicorn.py
    dest: "{{ root_dir }}/crm_pilates/gunicorn.py"

and the playbook:

- name: Configure settings
  hosts: all
  roles:
    - role: settings
    - role: display_settings
    - role: print_settings

- name: Deploy
  hosts:
    deploy
    docker-local
  roles:
    - role: server

I really don’t get why it is working on a local container and not on digital ocean App container.

If anyone has an idea and see what I don’t see.


Submit an answer
Answer a question...

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer