diff options
author | Will Thames <will@thames.id.au> | 2019-05-08 23:53:25 +1000 |
---|---|---|
committer | Brian Coca <bcoca@users.noreply.github.com> | 2019-05-08 09:53:24 -0400 |
commit | cd95843ea5f1bff40225b0430cfbb379cbe53661 (patch) | |
tree | 6ef325bec9742ec644d900543ed46dc73159145b | |
parent | 2a39dc84b75599db0891398ccb7716601c56b139 (diff) | |
download | ansible-cd95843ea5f1bff40225b0430cfbb379cbe53661.tar.gz |
Make ansible adhoc work with include_role (#56163)
* Make ansible adhoc work with include_role
Fix logic condition so that include_role works
without
```
ERROR! 'async_val' is not a valid attribute for a IncludeRole
The error appears to be in 'None': line 0, column 0, but may
be elsewhere in the file depending on the exact syntax problem.
(could not open file to display line)
```
* Add include_role test for adhoc
-rw-r--r-- | changelogs/fragments/ansible-adhoc.yaml | 2 | ||||
-rw-r--r-- | lib/ansible/cli/adhoc.py | 2 | ||||
-rwxr-xr-x | test/integration/targets/include_import/runme.sh | 4 |
3 files changed, 7 insertions, 1 deletions
diff --git a/changelogs/fragments/ansible-adhoc.yaml b/changelogs/fragments/ansible-adhoc.yaml new file mode 100644 index 0000000000..b5b5d369ec --- /dev/null +++ b/changelogs/fragments/ansible-adhoc.yaml @@ -0,0 +1,2 @@ +bugfixes: + - allow include_role to work with ansible command diff --git a/lib/ansible/cli/adhoc.py b/lib/ansible/cli/adhoc.py index 5108df1845..2f79e881ea 100644 --- a/lib/ansible/cli/adhoc.py +++ b/lib/ansible/cli/adhoc.py @@ -69,7 +69,7 @@ class AdHocCLI(CLI): mytask = {'action': {'module': context.CLIARGS['module_name'], 'args': parse_kv(context.CLIARGS['module_args'], check_raw=check_raw)}} # avoid adding to tasks that don't support it, unless set, then give user an error - if context.CLIARGS['module_name'] not in ('include_role', 'include_tasks') or any(frozenset((async_val, poll))): + if context.CLIARGS['module_name'] not in ('include_role', 'include_tasks') and any(frozenset((async_val, poll))): mytask['async_val'] = async_val mytask['poll'] = poll diff --git a/test/integration/targets/include_import/runme.sh b/test/integration/targets/include_import/runme.sh index cf523a89d9..0d253cc8d1 100755 --- a/test/integration/targets/include_import/runme.sh +++ b/test/integration/targets/include_import/runme.sh @@ -10,6 +10,10 @@ function gen_task_files() { done } +## Adhoc + +ansible -m include_role -a name=role1 localhost + ## Import (static) # Playbook |