Hi all,

I am new to Ansible learning  and I   start practicing  yaml playbook 
writings. 
Though I am able to have a program with  correct indent, ansible-playbook  
still pointing errors. I have no programming experience than bash scripting.

Could someone highlight, what I am missing.
Any  guidance to  do a search here before posting   will be much 
appreciated.

Thanks



[student@mgmvm1 ~]$ ansible --version
ansible 2.3.1.0
  config file = /home/student/ansible.cfg
  configured module search path = Default w/o overrides
  python version = 2.7.5 (default, Nov  6 2016, 00:28:07) [GCC 4.8.5 
20150623 (Red Hat 4.8.5-11)]
[student@mgmvm1 ~]$ python -c 'import yaml, sys; print yaml.load(sys.stdin)' 
< test.yml
[{'become': True, 'tasks': [{'block': [{'state': 'latest', 'yum': None, 
'name': 'httpd'}, {'state': 'latest', 'yum': None, 'name': 'firewalld'}]}, {
'block': [{'state': 'enabled', 'permanent': True, 'name': 'firewalld 
permits http service', 'service': 'http', 'firewalld': None, 'immediate': 
True}]}, {'block': [{'state': 'started', 'enabled': True, 'name': 'httpd', 
'service': None}, {'state': 'started', 'enabled': True, 'name': 'firewalld', 
'service': None}]}, {'block': [{'content': 'Welcome to the example.com 
intranet!\n', 'dest': '/var/www/html/index.html', 'copy': None, 'name': 'test 
html page'}]}], 'hosts': 'ctlvm.example.com', 'name': 'intranet services'}, 
{'tasks': [{'url': 'http://ctlvm.example.com', 'status_code': 200, 'name': 
'connect 
to intranet', 'uri': None}], 'hosts': 'localhost', 'name': 'test'}]
[student@mgmvm1 ~]$ ansible-playbook --syntax-check test.yml
 [WARNING]: While constructing a mapping from /home/student/test.yml, line 7
, column 9, found a duplicate dict key (name).
Using last defined value only.


 [WARNING]: While constructing a mapping from /home/student/test.yml, line 
13, column 9, found a duplicate dict key (name).
Using last defined value only.


 [WARNING]: While constructing a mapping from /home/student/test.yml, line 
28, column 9, found a duplicate dict key (name).
Using last defined value only.


 [WARNING]: While constructing a mapping from /home/student/test.yml, line 
34, column 9, found a duplicate dict key (name).
Using last defined value only.


ERROR! 'state' is not a valid attribute for a Task


The error appears to have been in '/home/student/test.yml': line 7, column 9
, but may
be elsewhere in the file depending on the exact syntax problem.


The offending line appears to be:


  - block:
      - name: latest httpd version installed
        ^ here


[student@mgmvm1 ~]$ cat test.yml
---
- name: intranet services
  hosts: ctlvm.example.com
  become: yes
  tasks:
  - block:
      - name: latest httpd version installed
        yum:
        name: httpd
        state: latest




      - name: latest firewalld version is present
        yum:
        name: firewalld
        state: latest


  - block:


      - name: firewalld permits http service
        firewalld:
        service: http
        permanent: yes
        state: enabled
        immediate: yes


  - block:
      - name: httpd enabled and running
        service:
        name: httpd
        enabled: yes
        state: started


      - name: firewalld is enabled and running
        service:
        name: firewalld
        enabled: yes
        state: started


  - block:
      - name: test html page
        copy:
        content: "Welcome to the example.com intranet!\n"
        dest: /var/www/html/index.html


- name: test
  hosts: localhost
  tasks:
   - name: connect to intranet
     uri:
     url: http://ctlvm.example.com
     status_code: 200
[student@mgmvm1 ~]$

-- 
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 [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/06043ddb-2f9f-4fe2-aa45-b273414f3f25%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to