Installing Git and Ansible on our EC2 instance

Since we need to be able to run Ansible and Git remotely, we first need to install those packages on our EC2 instance. For now, we will do that by manually installing those two packages. We will implement a reusable solution later in this chapter.

Since Ansible is a perfect tool to run remote commands and has a module to manage most common needs such as installing packages, instead of logging in on the host through ssh and running some commands, we are going to use Ansible to push out those changes. We will install Git from the Epel yum repository and Ansible using pip. This will require running commands as root, which you can do with the help of the become option. Adapting the IP address of your EC2 instance, run the following commands:

$ ansible '54.175.86.38' 
      --private-key ~/.ssh/EffectiveDevOpsAWS.pem 
      --become 
      -m yum -a 'name=git enablerepo=epel state=installed'
    
$ ansible '54.175.86.38' 
      --private-key ~/.ssh/EffectiveDevOpsAWS.pem 
      --become 
      -m pip -a 'name=ansible state=present'  

With ansible-pull, our goal is for Ansible to apply the change locally; we can make a change to our Ansible repository to optimize this operation.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset