运行 ansible playbook 到 git 克隆项目时出现违规行

Offending lines appears while running ansible playbook to git clone a project

您好,我正在尝试使用 ansible 克隆一个项目,但我不断收到以下错误

ERROR! this task 'git' has extra params, which is only allowed in the following modules: command, shell, script, include, include_vars, add_host, group_by, set_fact, raw, meta

The error appears to have been in '/vagrant/ansible/roles/rolename/tasks/main.yml': line 67, column 5, but may
be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:

  - git: repo=ssh://git@git.example.sample.net:/component/exact/repo.git
    ^ here


The error appears to have been in '/vagrant/ansible/roles/rolename/tasks/main.yml': line 67, column 5, but may
be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:


  - git: repo=ssh://git@git.example.sample.net:/component/exact/repo.git
    ^ here

Ansible failed to complete successfully. Any error output should be
visible above. Please fix these errors and try again.

我的 Ansible 任务是

  - git: repo=ssh://git@git.example.sample.net:/component/exact/repo.git
         dest=/home/
         accept_hostkey = true
         version= {{someversion}}
         accept_hostkey = true

我的剧本中还有其他任务,但这些工作正常,但每当我包含 git 时,它都会失败。

只有在模块使用单行格式时才会使用等号语法;当您将它们分成多行时,您应该使用 key: value 语法传递 YAML 哈希:

- git:
    repo: ssh://git@git.example.sample.net:/component/exact/repo.git
    dest: /home/
    accept_hostkey: true
    version: "{{someversion}}"