Ansible Introduction

Recently I got my hands on a brand new orange pi. However, I found myself stuck in typing the same boring command across all sessions. Hence, I believe this serves as a good opportunity to anisible for better automation across all servers. 
Simple walkthrough the steps to install anisible in master server:
First add anisible repository: 
       sudo apt-add-repository ppa:ansible/ansible -y
Install anisible:
        sudo apt-get update && sudo apt-get install ansible -y
        ansible –version
Create ssh key and copy it across all web-servers:
 [ Note: username must be same as login username and same across all nodes ]
      ssh-copy-id ks@[ first node local ip ]
      ssh-copy-id ks@[ second node local ip ]
Then you should be able to ssh into all servers using the master ssh public key
If all commands works out well, you can start editing /etc/ansible/hosts file and create your swarm name and local ip.
       sudo vim /etc/ansible/hosts
      [web-servers] [ first node local ip ] [ second node local ip ]
One of many possible command in ansible 
      anisible -m command -a ” your-unix-command” [your-serves-group-name] 
this command send the same command to all servers 
Some Command Example:
      ansible -m ping web-servers
      ansible -m command -a “uptime” web-servers
      ansible -m command -a “tmux new -s foo -d” web-servers
      anisible -m command -a “tmux ls” web-servers
Here’s a great proper introduction to ansible by Jeff Geeriling

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s