You are currently viewing Update a command in AWS instances (using ansible & ssh-agent)?

Update a command in AWS instances (using ansible & ssh-agent)?

1) First, we need to start the ssh-agent (this program holds private keys for public key authentication) using the command.
ssh-agent bash



2) Now, we need to add the private key, along with its passphrase, to the list maintained by the ssh-agent using the following command:
ssh-add privatekey.pem


NOTE
:

The ssh-agent can then use the private key to log into other servers without requiring the user to retype the passphrase or provide the private key during an ssh connection.

 

3) Create a [aws] group in /etc/ansible/hosts and add all the IPs of the AWS instances where we want to execute a command.


4) Run the ansible command,
ansible aws -u ubuntu  -a "uname -r" (“uname -r” is the ad-hoc command we want to run in all the AWS Instances)


5) Following these steps enables us to execute a command on multiple AWS instances.









Leave a Reply