need explaination

36 views
Skip to first unread message

Arbab Nazar

unread,
Apr 1, 2015, 1:19:32 PM4/1/15
to ansible...@googlegroups.com
I know this is really really basic question, but I really want the explanation of this:


Like what is "repo", I think it's the list? but what is the "name", "url" and "key"? and why only "name" has the "-" infront of it?

Thanks in advance

Ivan S. Freitas

unread,
Apr 1, 2015, 1:43:14 PM4/1/15
to ansible...@googlegroups.com
This is the yaml representation of a list of dictionaries. I strongly
recommend you to study the yaml specificiation [1], but this specific
example can be broken down as this:

"repo" is a variable. Since the elements that follow it start with a
dash, "repo" represents a list. Each dash starts a list element, and
all subelements in the same level of indentation are the part of the
same list element. So each group of "name", "url" and "key" belong to
the same list element.

Each list element is a dictionary. "name", "url" and "key" are the
keys, and after the ":" are their respective values. One way that can
help you understand a yaml document is to install the pyyaml library
and try to parse it with python:

>>> import yaml
>>> 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'
... ''')
{'repos': [{'url':
'http://download.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm',
'name': 'EPEL', 'key': 'http://ftp.riken.jp/Linux/fedora/epel/RPM-GP
G-KEY-EPEL-6'}, {'url':
'http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.3-1.el6.rf.x86_64.rpm',
'name': 'RPMForge', 'key': 'http://apt.sw.be/RPM-GPG-KEY.
dag.txt'}, {'url':
'http://rpms.famillecollet.com/enterprise/remi-release-6.rpm', 'name':
'Remi', 'key': 'http://rpms.famillecollet.com/RPM-GPG-KEY-remi'},
{'url': 'http:
//mirror.webtatic.com/yum/el6/latest.rpm', 'name': 'Webtatic', 'key':
'http://mirror.webtatic.com/yum/RPM-GPG-KEY-webtatic-andy'}]}
>>>

Hope it helps.

[1] http://yaml.org/
> --
> You received this message because you are subscribed to the Google Groups
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to ansible-proje...@googlegroups.com.
> To post to this group, send email to ansible...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/686acd7c-bca6-4979-9c11-ef38f0ce83a1%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.



--
Ivan Sichmann Freitas
Reply all
Reply to author
Forward
0 new messages