【问题标题】:Offending lines appears while running ansible playbook to git clone a project运行 ansible playbook 以 git clone 项目时出现违规行
【发布时间】:2016-08-24 16:00:20
【问题描述】:

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

【问题讨论】:

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


    【解决方案1】:

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

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

    【讨论】:

    • @smiller171 你是不同意我的观点,还是不同意现在已删除的评论?
    • 不,另一条评论已被删除。无法编辑 cmets,所以我要继续删除它。
    猜你喜欢
    • 1970-01-01
    • 2021-06-04
    • 1970-01-01
    • 2018-02-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多