You need to be root to perform this command.

1,844 views
Skip to first unread message

Anushri Mishra

unread,
Aug 4, 2016, 5:47:03 PM8/4/16
to Ansible Project
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.

Kai Stian Olstad

unread,
Aug 5, 2016, 2:03:23 PM8/5/16
to ansible...@googlegroups.com
On 04. aug. 2016 23:35, Anushri Mishra wrote:
> *The offending line appears to be:*
>
> * sudo:yes*
>

You need a space after the colon, and
sudo: is deprecated so use become: yes

--
Kai Stian Olstad

Anushri Mishra

unread,
Aug 5, 2016, 2:42:02 PM8/5/16
to Ansible Project, ansible-pr...@olstad.com
ok. Thank you .

Anushri Mishra

unread,
Aug 5, 2016, 2:42:23 PM8/5/16
to Ansible Project
Reply all
Reply to author
Forward
0 new messages