Here's the situation: I frequently build new AWS hosts using terraform. After the initial build, there are several interactive steps that need to be performed on the hosts involving sudo. Would it be possible (assuming the password is provided by the user) to create a Perl (with expect) or Python3 (pexpect) script to interact with the SSH session to automate these steps?
An example task to automate (this is ONLY an example; I'm looking for a general solution, not one specifically for yum
) would be:
$ ssh <new host>
Password:
$ sudo yum -y update
[sudo] password for <my username>: