How can Ansible “register” in a variable the result of including a playbook?

前端 未结 2 1252
囚心锁ツ
囚心锁ツ 2020-12-10 11:39

How can an Ansible playbook register in a variable the result of including another playbook?

For example, would the following register the result of executing

2条回答
  •  无人及你
    2020-12-10 12:17

    The short answer is that this can't be done.

    The register statement is used to store the output of a single task into a variable. The exact contents of the registered variable can vary widely depending on the type of task (for example a shell task will include stdout & stderr output from the command you run in the registered variable, while the stat task will provide details of the file that is passed to the task).

    If you have an include file with an arbitrary number of tasks within it then Ansible would have no way of knowing what to store in the variable in your example.

    Each individual task within your include file can register variables, and you can reference those variables elsewhere, so there's really no need to even do something like this.

提交回复
热议问题