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

时间:2016-08-24 16:00:21

标签: git ansible ansible-playbook ansible-2.x

您好我正在尝试使用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时都会失败。

1 个答案:

答案 0 :(得分:6)

等号语法仅在您使用模块的单行格式时使用;当您将它们拆分为多行时,您应该使用key: value语法传递YAML哈希:

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