ansible vars_files vs include_vars

Both vars_files and include_vars are labeled as stable interfaces so neither of them are deprecated. Both of them have some commonalities but they solve different purposes. vars_files: vars_file directive can only be used when defining a play to specify variable files. The variables from those files are included in the playbook. Since it is used … Read more

Ansible with multiple SSH key pair

Good news- in a basic use case, this is fairly easy. Simply use the ansible_ssh_private_key_file parameter in your Ansible inventory. Here are some examples purloined from my personal file: $ cat hosts.ini [server1] 54.1.2.3 ansible_ssh_private_key_file=~/.ssh/server1.pem [testservers] ec2-54-2-3-4.compute-1.amazonaws.com ansible_ssh_private_key_file=~/.ssh/aws-testserver.pem ansible_ssh_user=ubuntu ec2-54-2-3-5.compute-1.amazonaws.com ansible_ssh_private_key_file=~/.ssh/aws-testserver.pem ansible_ssh_user=ubuntu [piwall] 10.0.0.88 ansible_ssh_private_key_file=~/.ssh/raspberrypi.pem ansible_ssh_user=pi

Evaluating return code in ansible conditional

As nikobelia pointed out in the comments, grep returns an exit code of 1 when it doesn’t match any lines. Ansible then interprets this (actually any status code other than 0 from a shell/command task) as an error and so promptly fails. You can tell Ansible to ignore the response code from the shell/command task … Read more

Ansible – Access inventory alias

The variable I was searching for is a built in feature: inventory_hostname Ansible documentation about inventory_hostname and inventory_hostname_short is found from chapter Magic Variables, and How To Access Information About Other Hosts. Original question: https://groups.google.com/forum/#!topic/ansible-project/Oa5YXjHecIw

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)