- Notifications
You must be signed in to change notification settings - Fork48
Ansible modules for installing and configuring Dokku
License
dokku/ansible-dokku
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
This Ansible role helps install Dokku on Debian/Ubuntu variants. Apartfrom installing Dokku, it also provides various modules that can beused to interface with dokku from your own Ansible playbooks.
Minimum Ansible Version: 2.2
Supported Platforms
- Ubuntu: noble
- Ubuntu: jammy
- Ubuntu: focal
- Debian: bookworm
- Debian: bullseye
- geerlingguy.docker ansible role
- nginxinc.nginx ansible role
- Dokku (for library usage)
- default:
True
- type:
boolean
- description: Whether to install the dokku-daemon
- default:
0.0.2
- type:
string
- description: The version of dokku-daemon to install
- default:
dokku.me
- type:
string
- description: Hostname, used as vhost domain and for showing app URL after deploy
- default:
/root/.ssh/id_rsa.pub
- type:
string
- description: Path on disk to an SSH key to add to the Dokku user (Will be ignored on
dpkg-reconfigure
)
- default:
True
- type:
boolean
- description: Whether we should manage the 00-default nginx site
- default:
present
- type:
string
- description: State of dokku packages. Accepts 'present' and 'latest'
- default:
{}
- type:
list
- description: A list of plugins to install. The hostmust have network access to the install url, and git access if required. Plugins should be specified in the following format:
-name:postgresurl:https://github.com/dokku/dokku-postgres.git-name:redisurl:https://github.com/dokku/dokku-redis.git
- default:
false
- type:
string
- description: Do not check for the existence of the dokku/key_file. Setting this to "true", will require you to manually add an SSH key later on.
- default:
null
- type:
list
- description: A list of users who should have access to Dokku. This willnot grant them generic SSH access, but rather only access as the
dokku
user. Users should be specified in the following format:
-name:Jane Doeusername:janessh_key:JANES_PUBLIC_SSH_KEY-name:Camillausername:camillassh_key:CAMILLAS_PUBLIC_SSH_KEY
- default:
''
- type:
string
- description: The version of dokku to install.Scheduled for deletion after 07/2021. Use
dokku_packages_state
instead.
- default:
true
- type:
string
- description: Use vhost-based deployments (e.g., .dokku.me)
- default:
false
- type:
string
- description: Use web-based config for hostname and keyfile
- default:
''
- type:
string
- description: The version of herokuish to install.Scheduled for deletion after 07/2021. Use
dokku_packages_state
instead.
- default:
''
- type:
string
- description: The version of plugn to install.Scheduled for deletion after 07/2021. Use
dokku_packages_state
instead.
- default:
''
- type:
string
- description: The version of sshcommand to install.Scheduled for deletion after 07/2021. Use
dokku_packages_state
instead.
Manage access control list for a given dokku application
- the
dokku-acl
plugin
Parameter | Choices/Defaults | Comments |
---|---|---|
app required | The name of the app | |
state | Choices:
| Whether the ACLs should be present or absent |
users required | The list of users who can manage the app |
-name:let leopold manage hello-worlddokku_acl_app:app:hello-worldusers: -leopold-name:remove leopold from hello-worlddokku_acl_app:app:hello-worldusers: -leopoldstate:absent
Manage access control list for a given dokku service
- the
dokku-acl
plugin
Parameter | Choices/Defaults | Comments |
---|---|---|
service required | The name of the service | |
state | Choices:
| Whether the ACLs should be present or absent |
type required | The type of the service | |
users required | The list of users who can manage the service |
-name:let leopold manage mypostgres postgres servicedokku_acl_service:service:mypostgrestype:postgresusers: -leopold-name:remove leopold from mypostgres postgres servicedokku_acl_service:service:hello-worldtype:postgresusers: -leopoldstate:absent
Create or destroy dokku apps
Parameter | Choices/Defaults | Comments |
---|---|---|
app required | The name of the app | |
state | Choices:
| The state of the app |
-name:Create a dokku appdokku_app:app:hello-world-name:Delete that repodokku_app:app:hello-worldstate:absent
Manage the builder configuration for a given dokku application
Parameter | Choices/Defaults | Comments |
---|---|---|
app required | The name of the app. This is required only if global is set to False. | |
global | Default: False | If the property being set is global |
property required | The property to be changed (e.g.,build-dir ,selected ) | |
value | The value of the builder property (leave empty to unset) |
-name:Overriding the auto-selected builderdokku_builder:app:node-js-appproperty:selectedvalue:dockerfile-name:Setting the builder to the default valuedokku_builder:app:node-js-appproperty:selected-name:Changing the build build directorydokku_builder:app:monorepoproperty:build-dirvalue:backend-name:Overriding the auto-selected builder globallydokku_builder:global:trueproperty:selectedvalue:herokuish
Manages ssl configuration for an app.
Parameter | Choices/Defaults | Comments |
---|---|---|
app required | The name of the app | |
cert required | Path to the ssl certificate | |
key required | Path to the ssl certificate key | |
state | Choices:
| The state of the ssl configuration |
-name:Adds an ssl certificate and key to an appdokku_certs:app:hello-worldkey:/etc/nginx/ssl/hello-world.keycert:/etc/nginx/ssl/hello-world.crt-name:Removes an ssl certificate and key from an appdokku_certs:app:hello-worldstate:absent
Manage the Zero Downtime checks for a dokku app
Parameter | Choices/Defaults | Comments |
---|---|---|
app required | The name of the app | |
state | Choices:
| The state of the checks functionality |
-name:Disable the zero downtime deploymentdokku_checks:app:hello-worldstate:absent-name:Re-enable the zero downtime deployment (enabled by default)dokku_checks:app:hello-worldstate:present
Clone a git repository and deploy app.
Parameter | Choices/Defaults | Comments |
---|---|---|
app required | The name of the app | |
build | Default: True | Whether to build the app after cloning. |
repository required | Git repository url | |
version | Git tree (tag or branch name). If not provided, default branch is used. |
-name:clone a git repository and build appdokku_clone:app:example-apprepository:https://github.com/heroku/node-js-getting-startedversion:b10a4d7a20a6bbe49655769c526a2b424e0e5d0b-name:clone specific tag from git repository and build appdokku_clone:app:example-apprepository:https://github.com/heroku/node-js-getting-startedversion:b10a4d7a20a6bbe49655769c526a2b424e0e5d0b-name:sync git repository without building appdokku_clone:app:example-apprepository:https://github.com/heroku/node-js-getting-startedbuild:false
Manage environment variables for a given dokku application
Parameter | Choices/Defaults | Comments |
---|---|---|
app required | The name of the app | |
config required | Default: {} | A map of environment variables where key => value |
restart | Default: True | Whether to restart the application or not. If the task is idempotent then setting restart to true will not perform a restart. |
-name:set KEY=VALUEdokku_config:app:hello-worldconfig:KEY:VALUE_1KEY_2:VALUE_2-name:set KEY=VALUE without restartdokku_config:app:hello-worldrestart:falseconfig:KEY:VALUE_1KEY_2:VALUE_2
Manage docker-options for a given dokku application
Parameter | Choices/Defaults | Comments |
---|---|---|
app required | The name of the app | |
option required | A single docker option | |
phase | Choices:
| The phase in which to set the options |
state | Choices:
| The state of the docker options |
-name:docker-options:add hello-world deploydokku_docker_options:app:hello-worldphase:deployoption:"-v /var/run/docker.sock:/var/run/docker.sock"-name:docker-options:remove hello-world deploydokku_docker_options:app:hello-worldphase:deployoption:"-v /var/run/docker.sock:/var/run/docker.sock"state:absent
Manages domains for a given application
Parameter | Choices/Defaults | Comments |
---|---|---|
app required | The name of the app. This is required only if global is set to False. | |
domains required | A list of domains | |
global | Default: False | Whether to change the global domains or app-specific domains. |
state | Choices:
| The state of the application's domains |
# Adds domain, inclusive-name:domains:add hello-world dokku.medokku_domains:app:hello-worlddomains: -dokku.me# Removes listed domains, but leaves others unchanged-name:domains:remove hello-world dokku.medokku_domains:app:hello-worlddomains: -dokku.mestate:absent# Clears all domains-name:domains:clear hello-worlddokku_domains:app:hello-worldstate:clear# Enables the VHOST domain-name:domains:enable hello-worlddokku_domains:app:hello-worldstate:enable# Disables the VHOST domain-name:domains:disable hello-worlddokku_domains:app:hello-worldstate:disable# Sets the domain for the app, clearing all others-name:domains:set hello-world dokku.medokku_domains:app:hello-worlddomains: -dokku.mestate:set
Manages syncing git code from a remote repository for an app
- the
dokku-git-sync
plugin (commercial)
Parameter | Choices/Defaults | Comments |
---|---|---|
app required | The name of the app | |
remote | The git remote url to use | |
state | Choices:
| The state of the git-sync integration |
-name:git-sync:enable hello-worlddokku_git_sync:app:hello-worldremote:git@github.com:hello-world/hello-world.git-name:git-sync:disable hello-worlddokku_git_sync:app:hello-worldstate:absent
Manages global ssl configuration.
- the
dokku-global-cert
plugin
Parameter | Choices/Defaults | Comments |
---|---|---|
cert required | Path to the ssl certificate | |
key required | Path to the ssl certificate key | |
state | Choices:
| The state of the ssl configuration |
-name:Adds an ssl certificate and keydokku_global_cert:key:/etc/nginx/ssl/global-hello-world.keycert:/etc/nginx/ssl/global-hello-world.crt-name:Removes an ssl certificate and keydokku_global_cert:state:absent
Manage HTTP Basic Authentication for a dokku app
- the
dokku-http-auth
plugin
Parameter | Choices/Defaults | Comments |
---|---|---|
app required | The name of the app | |
password | The HTTP Auth Password (required for 'present' state) | |
state | Choices:
| The state of the http-auth plugin |
username | The HTTP Auth Username (required for 'present' state) |
-name:Enable the http-auth plugindokku_http_auth:app:hello-worldstate:presentusername:samsepi0lpassword:hunter2-name:Disable the http-auth plugindokku_http_auth:app:hello-worldstate:absent
Pull Docker image and deploy app
Parameter | Choices/Defaults | Comments |
---|---|---|
app required | The name of the app | |
build_dir | Specify custom build directory for a custom build context | |
image required | Docker image | |
user_email | Git user.email for customizing the author's email | |
user_name | Git user.name for customizing the author's name |
-name:Pull and deploy meilisearchdokku_image:app:meilisearchimage:getmeili/meilisearch:v0.24.0rc1-name:Pull and deploy image with custom authordokku_image:app:hello-worlduser_name:Elliot Aldersonuser_email:elliotalderson@protonmail.chimage:hello-world:latest-name:Pull and deploy image with custom build dirdokku_image:app:hello-worldbuild_dir:/path/to/buildimage:hello-world:latest
Enable or disable the letsencrypt plugin for a dokku app
- the
dokku-letsencrypt
plugin
Parameter | Choices/Defaults | Comments |
---|---|---|
app required | The name of the app | |
state | Choices:
| The state of the letsencrypt plugin |
-name:Enable the letsencrypt plugindokku_letsencrypt:app:hello-world-name:Disable the letsencrypt plugindokku_letsencrypt:app:hello-worldstate:absent
Create or destroy container networks for dokku apps
Parameter | Choices/Defaults | Comments |
---|---|---|
name required | The name of the network | |
state | Choices:
| The state of the network |
-name:Create a networkdokku_network:name:example-network-name:Delete that networkdokku_network:name:example-networkstate:absent
Set or clear a network property for a given dokku application
Parameter | Choices/Defaults | Comments |
---|---|---|
app required | The name of the app. This is required only if global is set to False. | |
global | Default: False | Whether to change the global network property |
property required | The network property to be be modified. This can be any property supported by dokku (e.g.,initial-network ,attach-post-create ,attach-post-deploy ,bind-all-interfaces ,static-web-listener ,tld ). | |
value | The value of the network property (leave empty to unset) |
-name:Associates a network after a container is created but before it is starteddokku_network_property:app:hello-worldproperty:attach-post-createvalue:example-network-name:Associates the network at container creationdokku_network_property:app:hello-worldproperty:initial-networkvalue:example-network-name:Setting a global network propertydokku_network_property:global:trueproperty:attach-post-createvalue:example-network-name:Clearing a network propertydokku_network_property:app:hello-worldproperty:attach-post-create
Manage ports for a given dokku application
Parameter | Choices/Defaults | Comments |
---|---|---|
app required | The name of the app | |
mappings required | A list of port mappings | |
state | Choices:
| The state of the port mappings |
-name:ports:set hello-world http:80:80dokku_ports:app:hello-worldmappings: -http:80:8080-name:ports:remove hello-world http:80:80dokku_ports:app:hello-worldmappings: -http:80:8080state:absent-name:ports:clear hello-worlddokku_ports:app:hello-worldstate:clear
Enable or disable the proxy for a dokku app
Parameter | Choices/Defaults | Comments |
---|---|---|
app required | The name of the app | |
state | Choices:
| The state of the proxy |
-name:Enable the default proxydokku_proxy:app:hello-world-name:Disable the default proxydokku_proxy:app:hello-worldstate:absent
Manage process scaling for a given dokku application
Parameter | Choices/Defaults | Comments |
---|---|---|
app required | The name of the app | |
scale required | Default: {} | A map of scale values where proctype => qty |
skip_deploy | Default: False | Whether to skip the corresponding deploy or not. If the task is idempotent then leaving skip_deploy as false will not trigger a deploy. |
-name:scale web and worker processesdokku_ps_scale:app:hello-worldscale:web:4worker:4-name:scale web and worker processes without deploydokku_ps_scale:app:hello-worldskip_deploy:truescale:web:4worker:4
Manage the registry configuration for a given dokku application
- the
dokku-registry
plugin
Parameter | Choices/Defaults | Comments |
---|---|---|
app required | The name of the app | |
image | Alternative to app name for image repository name | |
password | The registry password (required for 'present' state) | |
server | The registry server hostname (required for 'present' state) | |
state | Choices:
| The state of the registry integration |
username | The registry username (required for 'present' state) |
-name:registry:enable hello-worlddokku_registry:app:hello-worldpassword:passwordserver:localhost:8080username:user-name:registry:enable hello-world with argsdokku_registry:app:hello-worldimage:other-imagepassword:passwordserver:localhost:8080username:user-name:registry:disable hello-worlddokku_registry:app:hello-worldstate:absent
Manage resource limits for a given dokku application
Parameter | Choices/Defaults | Comments |
---|---|---|
app required | The name of the app | |
clear_before | Choices:
| Clear all resource limits before applying |
process_type | The process type selector | |
resources | The Resource type and quantity (required when state=present) | |
state | Choices:
| The state of the resource limits |
-name:Limit CPU and memory of a dokku appdokku_resource_limit:app:hello-worldresources:cpu:100memory:100-name:name: Limit resources per process type of a dokku appdokku_resource_limit:app:hello-worldprocess_type:webresources:cpu:100memory:100-name:Clear limits before applying new limitsdokku_resource_limit:app:hello-worldstate:presentclear_before:Trueresources:cpu:100memory:100-name:Remove all resource limitsdokku_resource_limit:app:hello-worldstate:absent
Manage resource reservations for a given dokku application
Parameter | Choices/Defaults | Comments |
---|---|---|
app required | The name of the app | |
clear_before | Choices:
| Clear all reserves before apply |
process_type | The process type selector | |
resources | The Resource type and quantity (required when state=present) | |
state | Choices:
| The state of the resource reservations |
-name:Reserve CPU and memory for a dokku appdokku_resource_reserve:app:hello-worldresources:cpu:100memory:100-name:Create a reservation per process type of a dokku appdokku_resource_reserve:app:hello-worldprocess_type:webresources:cpu:100memory:100-name:Clear all reservations before applyingdokku_resource_reserve:app:hello-worldstate:presentclear_before:Trueresources:cpu:100memory:100-name:Remove all resource reservationsdokku_resource_reserve:app:hello-worldstate:absent
Creates a given service
Parameter | Choices/Defaults | Comments |
---|---|---|
name required | The name of the service | |
service required | The type of service to create |
-name:redis:create defaultdokku_service_create:name:defaultservice:redis-name:postgres:create defaultdokku_service_create:name:defaultservice:postgres-name:postgres:create default with custom imageenvironment:POSTGRES_IMAGE:postgis/postgisPOSTGRES_IMAGE_VERSION:13-masterdokku_service_create:name:defaultservice:postgres
Links and unlinks a given service to an application
Parameter | Choices/Defaults | Comments |
---|---|---|
app required | The name of the app | |
name required | The name of the service | |
service required | The type of service to link | |
state | Choices:
| The state of the service link |
-name:redis:link default hello-worlddokku_service_link:app:hello-worldname:defaultservice:redis-name:postgres:link default hello-worlddokku_service_link:app:hello-worldname:defaultservice:postgres-name:redis:unlink default hello-worlddokku_service_link:app:hello-worldname:defaultservice:redisstate:absent
Manage storage for dokku applications
Parameter | Choices/Defaults | Comments |
---|---|---|
app | The name of the app | |
create_host_dir | Default: False | Whether to create the host directory or not |
group | Default: 32767 | A group or gid that should own the created folder |
mounts | Default: [] | A list of mounts to create, colon (:) delimited, in the format:host_dir:container_dir |
state | Choices:
| The state of the service link |
user | Default: 32767 | A user or uid that should own the created folder |
-name:mount a pathdokku_storage:app:hello-worldmounts: -/var/lib/dokku/data/storage/hello-world:/data-name:mount a path and create the host_dir directorydokku_storage:app:hello-worldmounts: -/var/lib/dokku/data/storage/hello-world:/datacreate_host_dir:true-name:unmount a pathdokku_storage:app:hello-worldmounts: -/var/lib/dokku/data/storage/hello-world:/datastate:absent-name:unmount a path and destroy the host_dir directory (and contents)dokku_storage:app:hello-worldmounts: -/var/lib/dokku/data/storage/hello-world:/datadestroy_host_dir:truestate:absent
----hosts:allroles: -dokku_bot.ansible_dokku
----hosts:allroles: -dokku_bot.ansible_dokkuvars:dokku_plugins: -name:cloneurl:https://github.com/crisward/dokku-clone.git -name:postgresurl:https://github.com/dokku/dokku-postgres.git
----hosts:allroles: -dokku_bot.ansible_dokkutasks: -name:dokku apps:create inflectordokku_app:app:inflector -name:dokku clone inflectordokku_clone:app:inflectorrepository:https://github.com/cakephp/inflector.cakephp.org
----hosts:allroles: -dokku_bot.ansible_dokku -geerlingguy.swapvars:# If you are running dokku on a small VPS, you'll most likely# need some swap to ensure you don't run out of RAM during deploysswap_file_size_mb:'2048'dokku_version:0.19.13dokku_users: -name:yournameusername:yournamessh_key:"{{lookup('file', '~/.ssh/id_rsa.pub')}}"dokku_plugins: -name:cloneurl:https://github.com/crisward/dokku-clone.git -name:letsencrypturl:https://github.com/dokku/dokku-letsencrypt.gittasks: -name:create appdokku_app:# change this name in your template!app:&appname appname -name:environment configurationdokku_config:app:*appnameconfig:# specify port so `domains` can setup the port mapping properlyPORT:"5000" -name:git clone# note you'll need to add a deployment key to the GH repo if it's private!dokku_clone:app:*appnamerepository:git@github.com:heroku/python-getting-started.git -name:add domaindokku_domains:app:*appnamedomains: -example.com -name:add letsencryptdokku_letsencrypt:app:*appname
SeeCONTRIBUTING.md.
MIT License
See LICENSE.md for further details.
About
Ansible modules for installing and configuring Dokku