Install & Configure Ansible

$ sudo apt update
$ sudo apt install software-properties-common
$ sudo apt-add-repository --yes --update ppa:ansible/ansible
$ sudo apt install ansible
$ ansible --version
ansible 2.5.1
config file = /etc/ansible/ansible.cfg
configured module search path = [u'/home/$user/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
ansible python module location = /usr/lib/python2.7/dist-packages/ansible
executable location = /usr/bin/ansible
python version = 2.7.15+ (default, Oct 7 2019, 17:39:04) [GCC 7.4.0]
$ grep '\"public_ip' terraform.tfstate
> "public_ip": "18.194.17.171",
$ ansible all -m ping -e "ansible_ssh_private_key_file=keys/terraform-key-pair"18.194.17.171 | UNREACHABLE! => {
"changed": false,
"msg": "Failed to connect to the host via ssh: root@18.194.17.171: Permission denied (publickey).\r\n",
"unreachable": true
}
18.194.17.171 ansible_user=ubuntusudo ansible all -m ping -e "ansible_ssh_private_key_file=keys/terraform-key-pair"18.194.17.171 | SUCCESS => {
"changed": false,
"ping": "pong"
}

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store