mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-06-29 19:50:25 -07:00
Adding new playbook objects for v2
* Playbook * TaskInclude
This commit is contained in:
parent
cbad867f24
commit
229d49fe36
42 changed files with 2041 additions and 81 deletions
|
@ -23,6 +23,10 @@ from yaml.constructor import Constructor
|
|||
from ansible.parsing.yaml.objects import AnsibleMapping
|
||||
|
||||
class AnsibleConstructor(Constructor):
|
||||
def __init__(self, file_name=None):
|
||||
self._ansible_file_name = file_name
|
||||
super(AnsibleConstructor, self).__init__()
|
||||
|
||||
def construct_yaml_map(self, node):
|
||||
data = AnsibleMapping()
|
||||
yield data
|
||||
|
@ -36,7 +40,16 @@ class AnsibleConstructor(Constructor):
|
|||
ret = AnsibleMapping(super(Constructor, self).construct_mapping(node, deep))
|
||||
ret._line_number = node.__line__
|
||||
ret._column_number = node.__column__
|
||||
ret._data_source = node.__datasource__
|
||||
|
||||
# in some cases, we may have pre-read the data and then
|
||||
# passed it to the load() call for YAML, in which case we
|
||||
# want to override the default datasource (which would be
|
||||
# '<string>') to the actual filename we read in
|
||||
if self._ansible_file_name:
|
||||
ret._data_source = self._ansible_file_name
|
||||
else:
|
||||
ret._data_source = node.__datasource__
|
||||
|
||||
return ret
|
||||
|
||||
AnsibleConstructor.add_constructor(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue