Ansible : UDMY -- 6. Ansible on Linux

 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++


 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Running Ansible as a Control host on Linux . 




Installing Ansible using APT which is built into the system 

$ ifconfig -a

apt is a command-line utility for installing, updating, removing, and otherwise

$ sudo apt-get update

$ sudo apt install ansible

$ which ansible

/usr/bin/ansible

$ ansible --version

Restored back the machine to its original state before installation -- to show the next method to install Ansible. 

*** Second type : Personal Packages Archive 

$ sudo apt-get update

  1. The sudo apt-get update command is used to download package information from all configured sources.
  2. The sources often defined in /etc/apt/sources.list file and other files located in /etc/apt/sources.list.d/ directory.
  3. So when you run update command, it downloads the package information from the Internet. It is useful to get info on an updated version of packages or their dependencies.

$ sudo apt-get install software-properties-common 

 Now we can add in the APT repository  

$ sudo apt-add-repository ppa:/ansible/ansible

$ sudo apt-get update -- To get that information from that repository

and now 

$ sudo apt-get install ansible 

$ ansible --version

Restored back the machine to its original state before installation -- to show the next method to install Ansible. 

Installing Ansible using VirtualEnv and PIP .

$ sudo apt-get update 

And then we need to install dependencies while we are doing this .

$ sudo apt-get install python-minimal virtualenv python-dev build-essesntial

so we got the dependencies in place 

we will create a directory to store all of this 

$ mkdir ansible

$ cd ansible

 And we will create virtual environment and we will call it 

$ virtualenv venv27


And we will activate that virtual environment 

$ source venv27/bin/activate

$ which python

$ which pip

Now if you are going to install anything using PIP it is going to install into that virtual environment

$ pip install ansible


One of the advantages of PIP is that you have got a loads of control over PIP . 

Now we are going to  uninstall ansible

$ pip uninstall ansible

$ git  -- checking if git is installed -- we do not find it therefore we are installing it .

$ sudo apt install git

Now what we can do is install git again using PIP 

$  pip install git+https://github.com/ansible/ansible

 Now that process can take a while .

Lets see how we install Ansible on RHEL / CentOS - Lab Exercise

We are on the CentOS system

$ ifconfig -a

Installing Ansible but through  the creation of our own RPM . Ansible it is a RedHat Product one of the product that they recommend is to create your own RPM

first we are going to install our dependencies 

$ sudo yum install asciidoc python-jija2 PyYAML git python-setuptools rpm-build python2-devel

 I am just going to go to the /tmp directory and we are going to clone the current version of ansible 

$ git clone git://github.com/ansible/ansible.git 

We go into ansible directory that we just cloned. 

create the rpm -- 

$ make rpm

 It has build our rpm , lets have a look. Our rpm is installed in rpm-build 

$ ls rmp-build/

 Now we can install this 


 Now we need to install dependencies 


Now we can install our package 










Comments

Popular posts from this blog

Ansible : UDMY -- 9. Ansible Modules

Ansible : UDMY -- 7. Validating Ansible Installation -- adhoc commands start - for loop to ssh key

Ansible : UDMY -- 8. Ansible Inventories