Ansible SSH "stderr": "reboot: Need to be root"

Hello Team,

I need to reboot my servers using ansible ,my Problem is i dont have sudo user , i have normal user and root password …

admin = normal user

here is my simple playbook …

  • hosts: unix
    tasks:
  • name: reboot servers
    command: /sbin/reboot

as of now I tried below Option

ansible-playbook packge_install.yum -i hosts --su-user=root --ask-su-pass

ansible-playbook packge_install.yum -i hosts --user=admin --ask-pass --su --ask-su-pass

but its not working … any idea How to achieve this ?

regards…Hemant

I need to reboot my servers using ansible ,my Problem is i dont have sudo
user , i have normal user and root password ..

admin = normal user

here is my simple playbook ...

- hosts: unix
  tasks:
  - name: reboot servers
    command: /sbin/reboot

You could change your playbook to

- hosts: unix
   become: yes
   become_method: su
   tasks:
   - name: reboot servers
     command: /sbin/reboot

Then you can run

ansible-playbook packge_install.yum -i hosts --ask-become-pass

as of now I tried below Option

ansible-playbook packge_install.yum -i hosts --su-user=root --ask-su-pass
ansible-playbook packge_install.yum -i hosts --user=admin --ask-pass --su
--ask-su-pass

but its not working ... any idea How to achieve this ?

If you would like to keep the playbook as is, this should work

ansible-playbook packge_install.yum -i hosts --become-method=su --become --ask-become-pass

You also have the short version of the options, check
anible-playbook -h

Thanks for your Views … I tried that but it seem same error …

below is my playbook

.

Hello,

Just an Update , I did small change in my Play boot …