Skip to content

Commit

Permalink
Merge pull request #16 from mwhahaha/ansible-task-options
Browse files Browse the repository at this point in the history
Add task_options to ansible runner tasks
  • Loading branch information
mwhahaha committed Dec 13, 2021
2 parents fe0464e + 352fc26 commit 2c81982
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 2 additions & 0 deletions schema/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,8 @@ definitions:
type: string
runner_options:
type: object
task_options:
type: object
global_fact_cache:
type: boolean
required:
Expand Down
9 changes: 8 additions & 1 deletion task_core/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,10 @@ def working_dir(self) -> str:
def runner_options(self) -> dict:
return self._data.get("runner_options", {})

@property
def task_options(self) -> dict:
return self._data.get("task_options", {})

@property
def global_fact_cache(self) -> bool:
return self._data.get("global_fact_cache", True)
Expand Down Expand Up @@ -311,7 +315,10 @@ def execute(self, *args, **kwargs) -> list:
runner_config.prepare()
# TODO: the call back needs to be overridden here if you want something
# other than the default.
# runner_config.env["ANSIBLE_STDOUT_CALLBACK"] = "tripleo_dense"
if self.task_options and "ANSIBLE_STDOUT_CALLBACK" in self.task_options:
runner_config.env["ANSIBLE_STDOUT_CALLBACK"] = self.task_options[
"ANSIBLE_STDOUT_CALLBACK"
]

# By default ansible-runner forces a per-execution fact cache but we
# want to share fact caches between our tasks. This can be disabled
Expand Down

0 comments on commit 2c81982

Please sign in to comment.