Using a hyphen inaccessible

I learn Ansible, but I get confused when to use a hyphen and when not to use a hyphen in a playbook. As I know, a hyphen is used for a list in Ansible.

For instance,

--- # my first playbook
      - hosts: webservers  ( why did we use hyphen here it is not a list)
        tasks: 
          - name: installing httpd
            yum: name=httpd state=installed ( why we shouldn't use hyphen here).

The Ansible documentation says that the hyphen is for a list, for example:

fruits:
  - apple
  - grapes
  - orange

So, I am confused when using hyphens and when not using.

+7
source share
2 answers

Hyphen - , : -. , (, Python) . , my_list :

my_list = ['foo', 'bar']

Ansible :

my_list:
  - foo
  - bar

, :

my_dict = {
    'key_foo': 'value_foo', 
    'key_bar': 'value_bar'
}

Ansible - :

my_dict:
  key_foo: value_foo
  key_bar: value_bar

, . tasks - , , :

tasks:
  - task_1

  - task_2

. , name yum. yum name, state ..

, , , , .

+7

, "- hosts: webservers". . , "yum: name = httpd = " "- " .

0

All Articles