dokku / ansible-dokku

Ansible modules for installing and configuring Dokku
MIT License
156 stars 44 forks source link

`dokku_config` does not update values if they exist already #164

Closed jessedobbelaere closed 1 year ago

jessedobbelaere commented 1 year ago

If you're using Dokku - especially for commercial purposes - consider donating to project development via OpenCollective or Patreon. Funds go to general development, support, and infrastructure costs.

If you'd like to sponsor specific functionality, see the project's Sponsoring document.

If you need support for a version of Dokku that is more than a year old, your issue may be closed without an answer. Please upgrade to a recent version before filing an issue.

Description of problem

Ansible role that sets Dokku config using dokku_config will not update keys that already exist. Is there a workaround for this?

How reproducible

Steps to Reproduce

In an Ansible role, I calculate a var clickhouse_database_url. I then set the env var with Dokku like this:

- name: Set DOKKU env vars for our app
  dokku_config:
    app: "{{ dokku.application }}"
    restart: false
    config:
      CLICKHOUSE_DATABASE_URL: "{{ clickhouse_database_url.stdout }}"

However, if the value changed and we run Ansible again, Dokku ansible will not update the value if the key exists already in the config:

https://github.com/dokku/ansible-dokku/blob/978b45ac436ad2ce563d93955d5d2de30b8c423a/library/dokku_config.py#L86-L87

Actual Results

CLICKHOUSE_DATABASE_URL is still the old value

Expected Results

CLICKHOUSE_DATABASE_URL gets overwritten with the new value, or workaround suggested?

Environment Information

dokku report APP_NAME output

``` -----> uname: Linux plausible-analytics 5.4.0-153-generic #170-Ubuntu SMP Fri Jun 16 13:43:31 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux -----> memory: total used free shared buff/cache available Mem: 1923 831 76 115 1015 843 Swap: 0 0 0 -----> docker version: Client: Docker Engine - Community Version: 24.0.2 API version: 1.43 Go version: go1.20.4 Git commit: cb74dfc Built: Thu May 25 21:52:22 2023 OS/Arch: linux/amd64 Context: default Server: Docker Engine - Community Engine: Version: 24.0.2 API version: 1.43 (minimum version 1.12) Go version: go1.20.4 Git commit: 659604f Built: Thu May 25 21:52:22 2023 OS/Arch: linux/amd64 Experimental: false containerd: Version: 1.6.21 GitCommit: 3dce8eb055cbb6872793272b4f20ed16117344f8 runc: Version: 1.1.7 GitCommit: v1.1.7-0-g860f061 docker-init: Version: 0.19.0 GitCommit: de40ad0 -----> docker daemon info: Client: Docker Engine - Community Version: 24.0.2 Context: default Debug Mode: true Plugins: buildx: Docker Buildx (Docker Inc.) Version: v0.10.5 Path: /usr/libexec/docker/cli-plugins/docker-buildx compose: Docker Compose (Docker Inc.) Version: v2.18.1 Path: /usr/libexec/docker/cli-plugins/docker-compose Server: Containers: 11 Running: 8 Paused: 0 Stopped: 3 Images: 30 Server Version: 24.0.2 Storage Driver: overlay2 Backing Filesystem: extfs Supports d_type: true Using metacopy: false Native Overlay Diff: true userxattr: false Logging Driver: json-file Cgroup Driver: cgroupfs Cgroup Version: 1 Plugins: Volume: local Network: bridge host ipvlan macvlan null overlay Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog Swarm: inactive Runtimes: io.containerd.runc.v2 runc Default Runtime: runc Init Binary: docker-init containerd version: 3dce8eb055cbb6872793272b4f20ed16117344f8 runc version: v1.1.7-0-g860f061 init version: de40ad0 Security Options: apparmor seccomp Profile: builtin Kernel Version: 5.4.0-153-generic Operating System: Ubuntu 20.04.2 LTS OSType: linux Architecture: x86_64 CPUs: 1 Total Memory: 1.878GiB WARNING: No swap limit support Name: plausible-analytics ID: c4517169-92b4-4913-b234-65513c0af112 Docker Root Dir: /var/lib/docker Debug Mode: false Experimental: false Insecure Registries: 127.0.0.0/8 Live Restore Enabled: false -----> git version: git version 2.25.1 -----> sigil version: 0.6.0 -----> herokuish version: ! Herokuish image gliderlabs/herokuish:latest-20 is not available -----> dokku version: dokku version 0.30.8 -----> plugn version: plugn: 0.6.1 -----> dokku plugins: 00_dokku-standard 0.30.8 enabled dokku core standard plugin 20_events 0.30.8 enabled dokku core events logging plugin app-json 0.30.8 enabled dokku core app-json plugin apps 0.30.8 enabled dokku core apps plugin builder 0.30.8 enabled dokku core builder plugin builder-dockerfile 0.30.8 enabled dokku core builder-dockerfile plugin builder-herokuish 0.30.8 enabled dokku core builder-herokuish plugin builder-lambda 0.30.8 enabled dokku core builder-lambda plugin builder-null 0.30.8 enabled dokku core builder-null plugin builder-pack 0.30.8 enabled dokku core builder-pack plugin buildpacks 0.30.8 enabled dokku core buildpacks plugin caddy-vhosts 0.30.8 enabled dokku core caddy-vhosts plugin certs 0.30.8 enabled dokku core certificate management plugin checks 0.30.8 enabled dokku core checks plugin clickhouse 1.34.0 enabled dokku clickhouse service plugin common 0.30.8 enabled dokku core common plugin config 0.30.8 enabled dokku core config plugin cron 0.30.8 enabled dokku core cron plugin docker-options 0.30.8 enabled dokku core docker-options plugin domains 0.30.8 enabled dokku core domains plugin enter 0.30.8 enabled dokku core enter plugin git 0.30.8 enabled dokku core git plugin haproxy-vhosts 0.30.8 enabled dokku core haproxy-vhosts plugin letsencrypt 0.13.0 enabled Automated installation of let's encrypt TLS certificates logs 0.30.8 enabled dokku core logs plugin network 0.30.8 enabled dokku core network plugin nginx-vhosts 0.30.8 enabled dokku core nginx-vhosts plugin plugin 0.30.8 enabled dokku core plugin plugin postgres 1.34.0 enabled dokku postgres service plugin proxy 0.30.8 enabled dokku core proxy plugin ps 0.30.8 enabled dokku core ps plugin registry 0.30.8 enabled dokku core registry plugin repo 0.30.8 enabled dokku core repo plugin resource 0.30.8 enabled dokku core resource plugin run 0.30.8 enabled dokku core run plugin scheduler 0.30.8 enabled dokku core scheduler plugin scheduler-docker-local 0.30.8 enabled dokku core scheduler-docker-local plugin scheduler-null 0.30.8 enabled dokku core scheduler-null plugin shell 0.30.8 enabled dokku core shell plugin ssh-keys 0.30.8 enabled dokku core ssh-keys plugin storage 0.30.8 enabled dokku core storage plugin trace 0.30.8 enabled dokku core trace plugin traefik-vhosts 0.30.8 enabled dokku core traefik-vhosts plugin =====> plausible app-json information App json computed selected: app.json App json global selected: app.json App json selected: =====> plausible app information App created at: 1688599338 App deploy source: docker-image App deploy source metadata: dokku/master-9993a7a4-1688631847 App dir: /home/dokku/plausible App locked: true =====> plausible builder information Builder build dir: Builder computed build dir: Builder computed selected: Builder global build dir: Builder global selected: Builder selected: =====> plausible builder-dockerfile information Builder dockerfile computed dockerfile path: Dockerfile Builder dockerfile global dockerfile path: Dockerfile Builder dockerfile dockerfile path: =====> plausible builder-herokuish information Builder herokuish computed allowed: true Builder herokuish global allowed: true Builder herokuish allowed: =====> plausible builder-lambda information Builder lambda computed lambdayml path: lambda.yml Builder lambda global lambdayml path: lambda.yml Builder lambda lambdayml path: =====> plausible builder-pack information Builder pack computed projecttoml path: project.toml Builder pack global projecttoml path: project.toml Builder pack projecttoml path: =====> plausible buildpacks information Buildpacks computed stack: gliderlabs/herokuish:latest-20 Buildpacks global stack: Buildpacks list: Buildpacks stack: =====> plausible caddy information Caddy image: lucaslorentz/caddy-docker-proxy:2.7 Caddy letsencrypt email: Caddy letsencrypt server: https://acme-v02.api.letsencrypt.org/directory Caddy log level: ERROR Caddy polling interval: 5s Caddy tls internal: false =====> plausible ssl information Ssl dir: /home/dokku/plausible/tls Ssl enabled: true Ssl hostnames: pa.jessedobbelae.re Ssl expires at: Sep 21 21:00:24 2023 GMT Ssl issuer: C = US, O = Let's Encrypt, CN = R3 Ssl starts at: Jun 23 21:00:25 2023 GMT Ssl subject: subject=CN = pa.jessedobbelae.re Ssl verified: self signed =====> plausible checks information Checks disabled list: none Checks skipped list: none Checks computed wait to retire: 60 Checks global wait to retire: 60 Checks wait to retire: =====> plausible cron information Cron task count: 0 =====> plausible docker options information Docker options build: --link dokku.clickhouse.plausible-db:dokku-clickhouse-plausible-db --link dokku.postgres.plausible-db:dokku-postgres-plausible-db Docker options deploy: --link dokku.clickhouse.plausible-db:dokku-clickhouse-plausible-db --link dokku.postgres.plausible-db:dokku-postgres-plausible-db --restart=on-failure:10 -v /var/lib/dokku/data/storage/plausible/geoip/GeoLite2-City.mmdb:/geoip/GeoLite2-City.mmdb -v /var/lib/dokku/data/storage/plausible/geoip/GeoLite2-Country.mmdb:/geoip/GeoLite2-Country.mmdb Docker options run: --link dokku.clickhouse.plausible-db:dokku-clickhouse-plausible-db --link dokku.postgres.plausible-db:dokku-postgres-plausible-db -v /var/lib/dokku/data/storage/plausible/geoip/GeoLite2-City.mmdb:/geoip/GeoLite2-City.mmdb -v /var/lib/dokku/data/storage/plausible/geoip/GeoLite2-Country.mmdb:/geoip/GeoLite2-Country.mmdb =====> plausible domains information Domains app enabled: true Domains app vhosts: pa.jessedobbelae.re Domains global enabled: true Domains global vhosts: dokku.me =====> plausible git information Git deploy branch: master Git global deploy branch: master Git keep git dir: false Git rev env var: GIT_REV Git sha: 641e4de Git source image: dokku/master-81bd2795-1689765780 Git last updated at: 1689765783 =====> plausible haproxy information Haproxy image: byjg/easy-haproxy:4.3.0 Haproxy letsencrypt email: Haproxy letsencrypt server: https://acme-v02.api.letsencrypt.org/directory Haproxy log level: ERROR =====> plausible logs information Logs computed max size: 10m Logs global max size: 10m Logs global vector sink: Logs max size: Logs vector sink: =====> plausible network information Network attach post create: Network attach post deploy: Network bind all interfaces: false Network computed attach post create: Network computed attach post deploy: Network computed bind all interfaces: false Network computed initial network: Network computed tld: Network global attach post create: Network global attach post deploy: Network global bind all interfaces: false Network global initial network: Network global tld: Network initial network: Network static web listener: Network tld: Network web listeners: 172.17.0.8:8000 =====> plausible nginx information Nginx access log format: Nginx access log path: /var/log/nginx/plausible-access.log Nginx bind address ipv4: Nginx bind address ipv6: :: Nginx client max body size: Nginx disable custom config: false Nginx error log path: /var/log/nginx/plausible-error.log Nginx global hsts: true Nginx computed hsts: true Nginx hsts: Nginx hsts include subdomains: true Nginx hsts max age: 15724800 Nginx hsts preload: false Nginx computed nginx conf sigil path: nginx.conf.sigil Nginx global nginx conf sigil path: nginx.conf.sigil Nginx nginx conf sigil path: Nginx proxy buffer size: 4096 Nginx proxy buffering: on Nginx proxy buffers: 8 4096 Nginx proxy busy buffers size: 8192 Nginx proxy read timeout: 60s Nginx last visited at: 1689765725 Nginx x forwarded for value: $proxy_add_x_forwarded_for Nginx x forwarded port value: $server_port Nginx x forwarded proto value: $scheme Nginx x forwarded ssl: =====> plausible proxy information Proxy enabled: true Proxy port map: http:80:8000 https:443:8000 Proxy type: nginx =====> plausible ps information Deployed: true Processes: 1 Ps can scale: true Ps computed procfile path: Procfile Ps global procfile path: Procfile Ps procfile path: Ps restart policy: on-failure:10 Restore: true Running: true Status web 1: running (CID: 6d1b484dedc) =====> plausible registry information Registry computed image repo: dokku/plausible Registry computed push on release: false Registry computed server: Registry global push on release: Registry global server: Registry image repo: Registry push on release: Registry server: Registry tag version: =====> plausible resource information =====> plausible scheduler information Scheduler computed selected: docker-local Scheduler global selected: docker-local Scheduler selected: =====> plausible scheduler-docker-local information Scheduler docker local disable chown: Scheduler docker local init process: true Scheduler docker local parallel schedule count: =====> plausible storage information Storage build mounts: Storage deploy mounts: -v /var/lib/dokku/data/storage/plausible/geoip/GeoLite2-City.mmdb:/geoip/GeoLite2-City.mmdb -v /var/lib/dokku/data/storage/plausible/geoip/GeoLite2-Country.mmdb:/geoip/GeoLite2-Country.mmdb Storage run mounts: -v /var/lib/dokku/data/storage/plausible/geoip/GeoLite2-City.mmdb:/geoip/GeoLite2-City.mmdb -v /var/lib/dokku/data/storage/plausible/geoip/GeoLite2-Country.mmdb:/geoip/GeoLite2-Country.mmdb =====> plausible traefik information Traefik api enabled: false Traefik api vhost: traefik.dokku.me Traefik basic auth password: Traefik basic auth username: Traefik dashboard enabled: false Traefik image: traefik:v2.8 Traefik letsencrypt email: Traefik letsencrypt server: https://acme-v02.api.letsencrypt.org/directory Traefik log level: ERROR Traefik priority: ```

This is required! Issues missing this information may be closed.

For problems affecting all applications, the report output for a broken application is useful for our debugging. In these cases, you may run dokku report without any arguments to display the top-level reporting information.

How (deb/make) and where (AWS, VirtualBox, physical, etc.) was Dokku installed?:

Additional information

ltalirz commented 1 year ago

Hi @jessedobbelaere , thanks for the report!

The code you link to should actually only skip, if the key already exists and the value for that key is already the one you are trying to set.

Maybe you can open a pull request adding a failing test to https://github.com/dokku/ansible-dokku/blob/master/molecule/default/verify.yml that demonstrates the problem you are seeing?

jessedobbelaere commented 1 year ago

Right, it checks the value 🤦 I will do another test and see how to exactly reproduce it! Will close until I have a reproducible case