Running a script as root user.

Hi All,

I have a script that I need to run on oracle linux when I try the standard “become:” it fails with the error “run with sudo -s”

I have tried many variations but what I have now is below.

  • name: Run gold_changes
    shell: /home/em7admin/gold_changes_8x.sh -y
    become_user: root
    become_method: su
    become: true
    register: script

Any help would be appreciated.

Dave

Try *sudo* plugin
https://docs.ansible.com/ansible/latest/plugins/become/sudo.html

    become_method: sudo

Try *command* module
https://docs.ansible.com/ansible/latest/modules/command_module.html#command-module

    command: /home/em7admin/gold_changes_8x.sh -y

Quoting from *shell* module: "If you want to execute a command securely and
predictably, it may be better to use the command module instead..."
https://docs.ansible.com/ansible/latest/modules/shell_module.html

Cheers,

  -vlado