Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Configuring AWS keys for a Linux user using Ansible

I am trying to find an Ansible module that would allow me to set up the Secret and Access Keys for a certain user on a target machine. The command line equivalent of this would be:-

11:14:26 root@ov90-NAT ~ [33] {e=255}
# aws configure
AWS Access Key ID [None]: something
AWS Secret Access Key [None]: something
Default region name [None]: us-east-1
Default output format [None]: json

I'm fairly new to both Ansible and AWS so any help would be appreciated!

like image 419
divij_o Avatar asked Nov 29 '25 03:11

divij_o


1 Answers

If you want to pass credentials to Ansible modules, Ansible has dedicated section on how to do it using environment variables or vars_file.

You can also explicitly set them using set command, e.g.:

aws configure set aws_access_key_id default_access_key
aws configure set aws_secret_access_key default_secret_key
aws configure set default.region us-west-2

You can also have your Ansible recipe to create the config files ~/.aws/credentials and ~/.aws/config. Their format is shown here.

like image 94
Marcin Avatar answered Dec 01 '25 09:12

Marcin