解析块映射时未找到预期的键

shu*_*han 18 ubuntu node.js ansible

我正在运行ansible play-book,但出现以下错误,-使用ansible 2.7.6,ubuntu 16.04。在剧本中提到

(<unknown>): did not find expected key while parsing a block mapping at line 6 column 3
Run Code Online (Sandbox Code Playgroud)

我尝试过没有变成-yes,ubuntu,sudo,也遇到了同样的问题并且 ansible 说:

The offending line appears to be:


   - name: build npm
   ^ here
Run Code Online (Sandbox Code Playgroud)
 - hosts: all
   vars:
       app_dir: /home/ubuntu/app/backend-app-name
   tasks:
 - name: build npm
   command: "chdir={{ app_dir }} {{ item }}"
     with_items:
     - /usr/bin/npm run build
      become: yes
      become_user: ubuntu
      become_method: sudo
Run Code Online (Sandbox Code Playgroud)

Vla*_*tka 21

缩进是错误的。正确的语法是

   tasks:
     - name: build npm
       command: ...
       with_items:
         - /usr/bin/npm run build
       become: yes
       become_user: ubuntu
       become_method: sudo
Run Code Online (Sandbox Code Playgroud)


jay*_*eek 7

当 YAML 任务中存在额外的单引号时,我收到了同样的错误。

解析块映射时,未找到预期的键。

    - task: DotNetCoreCLI@2
      inputs:
        command: 'pack'
        packagesToPack: '**/DoesNotMatter/OL.csproj'
        #...
        versionEnvVar: 'PACKAGEVERSION''
Run Code Online (Sandbox Code Playgroud)

请参阅代码示例的最后一个(额外')字符。