我正在尝试使用blockinfile,所以我正在做一些测试。 我有下一个任务,但它给了我一个sintax错误。
- name: Prueba
blockinfile:
dest: /opt/a
block: | pruebaa
pruebaaa
这是我的错误:
ERROR! Syntax Error while loading YAML.
The error appears to have been in '/home/ikerlan/ansiblePlaybooks/hadoop-Ansible/roles/comun/tasks/main.yml': line 39, column 12, but may
be elsewhere in the file depending on the exact syntax problem.
The offending line appears to be:
dest: /opt/a
block: | pruebaa
^ here
我的完整main.yml是下一个
#NAMENODES
#Los siguientes comandos solo se ejecutaran en los namenodes
- name: Archivo de configuracion zoo.cfg
template: src=zoo.cfg.j2 dest=/opt/zookeeper-3.4.7/conf/zoo.cfg
- name: Prueba
blockinfile:
dest: /opt/a
block: | pruebaa
pruebaaa
- name: Crear carpeta ZooData
file: path=/opt/ZooData state=directory mode=0755
#command: mkdir -p /opt/ZooData/ creates=/opt/ZooData/
- name: Permisos ZooData
command: chown vagrant /opt/ZooData/
- name: Crear carpeta name
file: path=/hdfs/name state=directory mode=0755
#command: mkdir -p /hdfs/name/ creates=/hdfs/name/
- name: Permisos hdfs/name
command: chown vagrant /hdfs/name/
- name: Crear carpeta journalnode
file: path=/hdfs/journalnode state=directory mode=0755
#command: mkdir -p /hdfs/journalnode/ creates=/hdfs/journalnode/
- name: Permisos hdfs/journalnode
command: chown vagrant /hdfs/journalnode/
- name: Archivo de configuracion slaves
template: src=slaves.j2 dest=/opt/hadoop-2.7.1/etc/hadoop/slaves
任何帮助都会很棒。感谢
答案 0 :(得分:1)
我没有ansible 2.0来测试这个。 阻止后,您不能拥有任何字符:| 试试这个:
blockinfile:
dest: /opt/a
block: |
pruebaa
pruebaaa
答案 1 :(得分:0)
我想在|
字符后应该有换行符。另外,剧本(或一般的YAML文件)必须以---
开头。