尝试在Ansible剧本中使用“with_items”和“when”来克隆回购

时间:2014-08-21 03:54:33

标签: ansible ansible-playbook

大家好,感谢您的踩踏。正如标题所说,我试图使用这些Ansible模块如下。我想克隆一个Wordpress回购,具体取决于变量是"是"或"不"。

这是我的主要Ansible剧本(通过流浪汉使用Vagrant --provision)。我将提供相关的部分。

vars:
  nginx_server_blocks:
  - { server_name: "dev.simple-site.io", document_root: "simple-site", wordpress: "no" }
  - { server_name: "dev.wordpress-site.io", document_root: "wordpress-site", wordpress: "yes" }
tasks:
 - name: clone Wordpress repo
   git: repo=git:https://github.com/WordPress/WordPress.git
        dest=/var/www/{{ item.document_root }}
   with_items: nginx_server_blocks
   when: item.wordpress == "yes"

当我运行vagrant provision时,我收到此错误:

fatal: [default] => failed to parse: SUDO-SUCCESS-rtlizwskstbaxddabxlgqtxxqzambxnh
Traceback (most recent call last):
File "/home/vagrant/.ansible/tmp/ansible-tmp-1408592922.35-152092658109200/git", line 2119, in <module>
    main()
File "/home/vagrant/.ansible/tmp/ansible-tmp-1408592922.35-152092658109200/git", line 524, in main
    add_git_host_key(module, repo, accept_hostkey=module.params['accept_hostkey'])
File "/home/vagrant/.ansible/tmp/ansible-tmp-1408592922.35-152092658109200/git", line 1986, in add_git_host_key
fqdn = get_fqdn(module.params['repo'])
File "/home/vagrant/.ansible/tmp/ansible-tmp-1408592922.35-152092658109200/git", line 2022, in get_fqdn
if "@" in result:
TypeError: argument of type 'NoneType' is not iterable

FATAL: all hosts have already failed -- aborting

错误的任何想法?我已经谷歌并阅读有关使用whenwith_items的ansible文档,但没有运气。

如果有帮助,我的主机是mac,而guest是ubuntu 14.04到Vagrant。 Ansible是通过pip安装的,它是1.7。

1 个答案:

答案 0 :(得分:2)

更改

repo=git:https://github.com/WordPress/WordPress.git

repo=https://github.com/WordPress/WordPress.git

Ansible正在看git前缀,并期待语法git@github.com:Wordpress/Wordpress.git,如果你想使用git-ssh,它也会有用。