add role_name config option
This commit is contained in:
parent
ea22d67ee3
commit
97d39351e4
|
@ -1,8 +1,4 @@
|
|||
* BUGFIX
|
||||
* add missing default for `role_dir`
|
||||
* fix value mapping in jinja2 source dict
|
||||
* add missing exception handling for dict merge
|
||||
* fix handling of multiline default values in template
|
||||
* add `role_name` config option to overwrite name of the role
|
||||
* FEATURE
|
||||
* use explicit marker to convert annotation values to json
|
||||
* use dictsort filter in template for ordered variable list
|
||||
* add basic hugo theme
|
||||
|
|
|
@ -41,6 +41,11 @@ class Config():
|
|||
"env": "ROLE_DIR",
|
||||
"type": environs.Env().str
|
||||
},
|
||||
"role_name": {
|
||||
"default": "",
|
||||
"env": "ROLE_NAME",
|
||||
"type": environs.Env().str
|
||||
},
|
||||
"dry_run": {
|
||||
"default": False,
|
||||
"env": "DRY_RUN",
|
||||
|
@ -168,6 +173,9 @@ class Config():
|
|||
for key, item in self.SETTINGS.items():
|
||||
normalized = self._add_dict_branch(normalized, key.split("."), item["default"])
|
||||
|
||||
# compute role_name default
|
||||
normalized["role_name"] = os.path.basename(self.role_dir)
|
||||
|
||||
self.schema = anyconfig.gen_schema(normalized)
|
||||
return normalized
|
||||
|
||||
|
|
|
@ -55,7 +55,7 @@ class Parser:
|
|||
if data.get("dependencies") is not None:
|
||||
self._data["meta"]["dependencies"] = {"value": data.get("dependencies")}
|
||||
|
||||
self._data["meta"]["name"] = {"value": os.path.basename(self.config.role_dir)}
|
||||
self._data["meta"]["name"] = {"value": self.config.config["role_name"]}
|
||||
except (ruamel.yaml.composer.ComposerError, ruamel.yaml.scanner.ScannerError) as e:
|
||||
message = "{} {}".format(e.context, e.problem)
|
||||
self.log.sysexit_with_message("Unable to read yaml file {}\n{}".format(rfile, message))
|
||||
|
|
|
@ -6,6 +6,8 @@ title: Default settings
|
|||
---
|
||||
# default is your current working dir
|
||||
role_dir:
|
||||
# default is the basename of 'role_name'
|
||||
role_name:
|
||||
# don't write anything to filesystem
|
||||
dry_run: False
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@ title: Environment Variables
|
|||
{{< highlight Shell "linenos=table" >}}
|
||||
ANSIBLE_DOCTOR_CONFIG_FILE=
|
||||
ANSIBLE_DOCTOR_ROLE_DIR=
|
||||
ANSIBLE_DOCTOR_ROLE_NAME=
|
||||
ANSIBLE_DOCTOR_DRY_RUN=false
|
||||
ANSIBLE_DOCTOR_LOG_LEVEL=warning
|
||||
ANSIBLE_DOCTOR_LOG_JSON=false
|
||||
|
|
Loading…
Reference in New Issue