Skip to content

Commit

Permalink
Merge pull request #57 from decentral1se/config-no-restart
Browse files Browse the repository at this point in the history
Allow to pass --no-restart to dokku_config
  • Loading branch information
josegonzalez authored Mar 16, 2020
2 parents 27435ac + 2b12b84 commit a274206
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,7 @@ Manage environment variables for a given dokku application
|---------|----------------|--------|
|app<br /><sup>*required*</sup>||The name of the app|
|config<br /><sup>*required*</sup>|*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.|

#### Example

Expand All @@ -245,6 +246,14 @@ Manage environment variables for a given dokku application
config:
KEY: VALUE_1
KEY_2: VALUE_2
- name: set KEY=VALUE without restart
dokku_config:
app: hello-world
restart: false
config:
KEY: VALUE_1
KEY_2: VALUE_2
```

### dokku_consul
Expand Down
22 changes: 21 additions & 1 deletion library/dokku_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@
required: True
default: {}
aliases: []
restart:
description:
- Whether to restart the application or not. If the task is idempotent
then setting restart to true will not perform a restart.
required: false
default: true
author: Jose Diaz-Gonzalez
requirements: [ ]
"""
Expand All @@ -40,6 +46,14 @@
config:
KEY: VALUE_1
KEY_2: VALUE_2
- name: set KEY=VALUE without restart
dokku_config:
app: hello-world
restart: false
config:
KEY: VALUE_1
KEY_2: VALUE_2
"""


Expand Down Expand Up @@ -108,7 +122,12 @@ def dokku_config_set(data):
has_changed = False
return (is_error, has_changed, meta)

command = "dokku config:set {0} {1}".format(data["app"], " ".join(values))
command = "dokku config:set {0}{1} {2}".format(
"--no-restart " if data["restart"] is False else "",
data["app"],
" ".join(values),
)

try:
subprocess.check_call(command, shell=True)
is_error = False
Expand All @@ -123,6 +142,7 @@ def main():
fields = {
"app": {"required": True, "type": "str"},
"config": {"required": True, "type": "dict", "no_log": True},
"restart": {"required": False, "type": "bool"},
}

module = AnsibleModule(argument_spec=fields, supports_check_mode=False)
Expand Down

0 comments on commit a274206

Please sign in to comment.