hi,I have been trying to run this playbook. 

- hosts: webservers

  vars:

    http_port: 80

    max_clients: 200

  remote_user: root

  tasks:

  - name: ensure apache is at the latest version

    yum: name=httpd state=latest

  - name: write the apache config file

    template: src=/srv/httpd.j2 dest=/etc/httpd.conf

    notify:

    - restart apache

  - name: ensure apache is running (and enable it at boot)

    service: name=httpd state=started enabled=yes

  handlers:

    - name: restart apache

      service: name=httpd state=restarted

~


but getting this error:


*task path: /etc/ansible/playbook.yml:8*

*<localhost> ESTABLISH LOCAL CONNECTION FOR USER: ec2-user*

*<localhost> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo 
$HOME/.ansible/tmp/ansible-tmp-1470343536.38-16560069967558 `" && echo 
ansible-tmp-1470343536.38-16560069967558="` echo 
$HOME/.ansible/tmp/ansible-tmp-1470343536.38-16560069967558 `" ) && sleep 
0'*

*<localhost> PUT /tmp/tmpdwLoYn TO 
/home/ec2-user/.ansible/tmp/ansible-tmp-1470343536.38-16560069967558/yum*

*<localhost> EXEC /bin/sh -c 'LANG=en_US.UTF-8 LC_ALL=en_US.UTF-8 
LC_MESSAGES=en_US.UTF-8 /usr/bin/python 
/home/ec2-user/.ansible/tmp/ansible-tmp-1470343536.38-16560069967558/yum; 
rm -rf 
"/home/ec2-user/.ansible/tmp/ansible-tmp-1470343536.38-16560069967558/" > 
/dev/null 2>&1 && sleep 0'*

*fatal: [localhost]: FAILED! => {"changed": true, "failed": true, 
"invocation": {"module_args": {"conf_file": null, "disable_gpg_check": 
false, "disablerepo": null, "enablerepo": null, "exclude": null, 
"install_repoquery": true, "list": null, "name": ["httpd"], "state": 
"latest", "update_cache": false, "validate_certs": true}, "module_name": 
"yum"}, "msg": "You need to be root to perform this command.\n", "rc": 1, 
"results": ["Loaded plugins: priorities, update-motd, upgrade-helper\n"]}*


I have read other threads on this topic but no success.Also tried sudo: yes 
and ansible_sudo=yes but that gives another error : 


*ERROR! Syntax Error while loading YAML.*



*The error appears to have been in '/etc/ansible/playbook.yml': line 4, 
column 3, but may*

*be elsewhere in the file depending on the exact syntax problem.*


*The offending line appears to be:*


*  sudo:yes*

*  vars:*

*  ^ here*



Please help.

-- 
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/9c73ff8d-5d41-4107-9e7b-594fdf531eb3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to