ansible-role-yedit
ansible-role-yedit copied to clipboard
Fail to parse multiple document in yaml file
I have yaml file with multiple document . I am trying to read a value from one of the document and I am getting this error while trying to access "spec.selector.name" .
Below is the yaml:
apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
name: epgs.aci.aw
spec:
group: aci.aw
names:
kind: Epg
listKind: EpgList
plural: epgs
scope: Namespaced
version: v1
---
apiVersion: v1
kind: Service
metadata:
name: ep-registry
namespace: kube-system
labels:
app: gbpserver
spec:
clusterIP: 10.96.0.2
ports:
- port: 14443
targetPort: 14443
selector:
name: aci-containers-controller
Error:
Traceback (most recent call last):
File "/tmp/ansible_yedit_payload_v_m8fh76/__main__.py", line 499, in load
AttributeError: module 'yaml' has no attribute 'RoundTripLoader'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/tmp/ansible_yedit_payload_v_m8fh76/__main__.py", line 501, in load
File "/usr/lib/python3/dist-packages/yaml/__init__.py", line 94, in safe_load
return load(stream, SafeLoader)
File "/usr/lib/python3/dist-packages/yaml/__init__.py", line 72, in load
return loader.get_single_data()
File "/usr/lib/python3/dist-packages/yaml/constructor.py", line 35, in get_single_data
node = self.get_single_node()
File "/usr/lib/python3/dist-packages/yaml/composer.py", line 43, in get_single_node
event.start_mark)
yaml.composer.ComposerError: expected a single document in the stream
in "<unicode string>", line 1, column 1:
apiVersion: apiextensions.k8s.io ...
^
but found another document
in "<unicode string>", line 14, column 1:
---
^
Is there a way to resolve this ?
Got this issue aswell.