How to Install and Use Ansible on Ubuntu 16.04

Prerequisites

Launch Alibaba Cloud ECS instance

Install Ansible

Ansible is a radically simple IT automation platform that makes your applications and systems easier to deploy. Avoid writing scripts or custom code to deploy and update your applications— automate in a language that approaches plain English, using SSH, with no agents to install on remote systems.http://ansible.com/
More info: https://launchpad.net/~ansible/+archive/ubuntu/ansible
Press [ENTER] to continue or ctrl-c to cancel adding it
gpg: keyring `/tmp/tmpiylu9n1t/secring.gpg' created
gpg: keyring `/tmp/tmpiylu9n1t/pubring.gpg' created
gpg: requesting key 7BB9C367 from hkp server keyserver.ubuntu.com
gpg: /tmp/tmpiylu9n1t/trustdb.gpg: trustdb created
gpg: key 7BB9C367: public key "Launchpad PPA for Ansible, Inc." imported
gpg: Total number processed: 1
gpg: imported: 1 (RSA: 1)
OK

Configure Ansible Host

[servers]
client-node ansible_ssh_host=192.168.0.104

Setup SSH Keys for Remote Hosts

Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:3FvzXmI3EhW7idSZy+ITzW7UrefZP/R5AYx2VBu3ytU root@server-node
The key's randomart image is:
+---[RSA 4096]----+
| .+.|
| .. @|
| +. XE|
| . . oo+O *|
| S o +B.Oo|
| o.o*+ |
| . +*+B|
| o+O*|
| ..B|
+----[SHA256]-----+

Test Ansible

client-node | SUCCESS => {
"changed": false,
"failed": false,
"ping": "pong"
}
ansible -m ping client-node
ansible -m ping servers
client-node | SUCCESS | rc=0 >>
total used free shared buffers cached
Mem: 3835 3185 649 177 77 929
-/+ buffers/cache: 2179 1656
Swap: 10793 0 10793
client-node | SUCCESS | rc=0 >>
Filesystem Size Used Avail Use% Mounted on
/dev/sda4 92G 27G 61G 31% /
none 4.0K 0 4.0K 0% /sys/fs/cgroup
udev 1.9G 4.0K 1.9G 1% /dev
tmpfs 384M 1.2M 383M 1% /run
none 5.0M 0 5.0M 0% /run/lock
none 1.9G 1.9M 1.9G 1% /run/shm
none 100M 44K 100M 1% /run/user
/dev/sda5 353G 75G 261G 23% /Data

Conclusion

--

--

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