HiveBrain v1.2.0
Get Started
← Back to all entries
snippetMinor

How to run Ansible with sudo no password commands with become syntax

Submitted by: @import:stackexchange-devops··
0
Viewed 0 times
runwithcommandspasswordbecomesyntaxhowansiblesudo

Problem

When I run ansible against a host machine that has some commands I need to run as root, I can't run these with "become" because it runs the commands as root instead of just running them with sudo.

What I've been doing is just using command: sudo ... and then suppressing warnings with

args: 
  warn: no


is there a better, more standardized, way to run a linux commandline with sudo sans password?

Solution

When I run ansible against a host machine that has some commands I need to run as root, I can't run these with "become" because it runs the commands as root instead of just running them with sudo.

That's not true; become uses a variety of methods for privilege escalation, and defaults to using sudo.

Are you perhaps running into one of the known limitations with the become module, like trying to limit sudo access to certain commands?

Context

StackExchange DevOps Q#2963, answer score: 7

Revisions (0)

No revisions yet.