我尝试使用kosssi.composer Ansible role来安装全局编写器实例以及一些编写器包。
---
-
hosts: myhosts
remote_user: vagrant
sudo: true
roles:
- { role: kosssi.composer,
composer_path_env: true,
composer_home_path: /opt/composer,
composer_home_owner: vagrant,
composer_home_group: vagrant,
composer_global_packages:
phpunit/phpunit: '@stable'
phing/phing: '@stable'
}
我已经尝试了很多不同的方法来编写这个但是我得到语法错误或错误with_dict expects a dict
。查看源代码,我看到composer_global_packages
期望一个至少长度为1的字典,它的定义如下:
with_dict: composer_global_packages
when: composer_global_packages|length > 0
看看yaml文档,我也意识到甚至没有像“dict”这样的概念。或者'字典'定义
我错过了什么?列出全局依赖关系的正确方法是什么?
答案 0 :(得分:2)
字典也称为associative array。有两种方法可以在YAML中定义它们,并且你将它们混合在一起,这会使解析器感到困惑。
以JSON样式编写整个内容:
-
hosts: myhosts
remote_user: vagrant
sudo: true
roles:
- { role: kosssi.composer,
composer_path_env: true,
composer_home_path: /opt/composer,
composer_home_owner: vagrant,
composer_home_group: vagrant,
composer_global_packages:
{
phpunit/phpunit: '@stable',
phing/phing: '@stable'
}
}
,或仅以空白样式:
-
hosts: myhosts
remote_user: vagrant
sudo: true
roles:
role: kosssi.composer
composer_path_env: true
composer_home_path: /opt/composer
composer_home_owner: vagrant
composer_home_group: vagrant
composer_global_packages:
phpunit/phpunit: '@stable'
phing/phing: '@stable'
检查您的YAML结构