我知道这确实是一个非常基本的问题,但我真的想要解释一下:
repos:
- name: 'EPEL'
url: 'http://download.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm'
key: 'http://ftp.riken.jp/Linux/fedora/epel/RPM-GPG-KEY-EPEL-6'
- name: 'RPMForge'
url: 'http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.3-1.el6.rf.x86_64.rpm'
key: 'http://apt.sw.be/RPM-GPG-KEY.dag.txt'
- name: 'Remi'
url: 'http://rpms.famillecollet.com/enterprise/remi-release-6.rpm'
key: 'http://rpms.famillecollet.com/RPM-GPG-KEY-remi'
- name: 'Webtatic'
url: 'http://mirror.webtatic.com/yum/el6/latest.rpm'
key: 'http://mirror.webtatic.com/yum/RPM-GPG-KEY-webtatic-andy'
就像什么是“回购”一样,我认为这是清单?但是什么是“名字”,“网址”和“密钥”?为什么只有“名字”在其前面有“ - ”?
提前致谢
答案 0 :(得分:1)
如果按照python
dict
和list
来看待它,也许会有所帮助:
$ python -c "
import yaml
import pprint
pp = pprint.PrettyPrinter(indent=3);
x = yaml.load('''repos:
- name: 'EPEL'
url: 'http://download.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm'
key: 'http://ftp.riken.jp/Linux/fedora/epel/RPM-GPG-KEY-EPEL-6'
- name: 'RPMForge'
url: 'http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.3-1.el6.rf.x86_64.rpm'
key: 'http://apt.sw.be/RPM-GPG-KEY.dag.txt'
- name: 'Remi'
url: 'http://rpms.famillecollet.com/enterprise/remi-release-6.rpm'
key: 'http://rpms.famillecollet.com/RPM-GPG-KEY-remi'
- name: 'Webtatic'
url: 'http://mirror.webtatic.com/yum/el6/latest.rpm'
key: 'http://mirror.webtatic.com/yum/RPM-GPG-KEY-webtatic-andy'
''');
pp.pprint( x );"
{ 'repos': [ { 'key': 'http://ftp.riken.jp/Linux/fedora/epel/RPM-GPG-KEY-EPEL-6',
'name': 'EPEL',
'url': 'http://download.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm'},
{ 'key': 'http://apt.sw.be/RPM-GPG-KEY.dag.txt',
'name': 'RPMForge',
'url': 'http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.3-1.el6.rf.x86_64.rpm'},
{ 'key': 'http://rpms.famillecollet.com/RPM-GPG-KEY-remi',
'name': 'Remi',
'url': 'http://rpms.famillecollet.com/enterprise/remi-release-6.rpm'},
{ 'key': 'http://mirror.webtatic.com/yum/RPM-GPG-KEY-webtatic-andy',
'name': 'Webtatic',
'url': 'http://mirror.webtatic.com/yum/el6/latest.rpm'}]}
$
这样:
repos
是dict
repos
的list
dicts
为什么只有" name"有" - "面前呢?
无效的问题。当您要声明dict
时,该YAML语法就是您如何做到的。
O和Marc说:ansible YAML Syntax