Error while executed yml file

19 views
Skip to first unread message

vikram acharya

unread,
Apr 16, 2019, 12:00:37 PM4/16/19
to ansible...@googlegroups.com
Hello Team 

Am pretty new to Ansible trying   , am getting an error while executing yml file .
Here am trying to install httpd services  on one of web server i have inventory file below are the details  ip details added  am able to ping all these IP 

inventory file:

mintty screen dump
[webserver]                                                                     
172.31.17.222                                                                   
                                                                                
[webserver:vars]                                                                
package_name=httpd                                                              
                                                                                
[dbserver]                                                                      
172.31.17.101                                                                   
                                                                                
[local]                                                                         
localhost                                                                       

mintty screen dump
ansible@ip-172-31-18-96:/etc/playbook$ ansible -i inventory -m ping all         
172.31.17.101 | SUCCESS => {                                                    
    "changed": false,                                                           
    "ping": "pong"                                                              
}                                                                               
172.31.17.222 | SUCCESS => {                                                    
    "changed": false,                                                           
    "ping": "pong"                                                              
}                                                                               
localhost | SUCCESS => {                                                        
    "changed": false,                                                           
    "ping": "pong"                                                              


This is YMl file i have written :

---
  - hosts: webserver
    sudo: yes
    tasks:
    - name: install apache
      package:
       name: "{{package_name}}"
       state: present
    - name: start and enable apache service
      service:
       name: "{{package_name}}"
       enabled: yes
       state: started
mintty screen dump
ansible@ip-172-31-18-96:/etc/playbook$ ansible-playbook -i inventory webserver.y
ml                                                                              
ERROR! Syntax Error while loading YAML.                                         
  mapping values are not allowed in this context                                
                                                                                
The error appears to have been in '/etc/playbook/webserver.yml': line 2, column 
10, but may                                                                     
be elsewhere in the file depending on the exact syntax problem.                 
                                                                                
The offending line appears to be:                                               
                                                                                
 ---                                                                            
  - hosts: webserver                                                            
         ^ here                                                                 

Need your help for the same .. 

Thanks for advance 

Regards
Vikram


vikram acharya

unread,
Apr 16, 2019, 1:49:54 PM4/16/19
to ansible...@googlegroups.com
Hello Team

Can some one help me with my request  please 

Regards 
Vk

Fahad Riaz

unread,
Apr 16, 2019, 4:37:07 PM4/16/19
to ansible...@googlegroups.com
try using this syntax and then execute your playbook.

---
- hosts: webservers
  sudo: yes


and then so on and so forth

--
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/CAFAnimCNRcVej5y7DUVCejVMqD53xve3a6bqwE_8xH8Km7yshw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


--
Best,
Fahad Riaz

vikram acharya

unread,
Apr 17, 2019, 5:29:28 AM4/17/19
to ansible...@googlegroups.com
Thank you Riaz  it worked 

Regards
Vikram

Brian Coca

unread,
Apr 18, 2019, 12:01:52 PM4/18/19
to Ansible Project
The sudo: has been deprecated for a long time and recently remove use
`become: yes` instead



--
----------
Brian Coca
Reply all
Reply to author
Forward
0 new messages