Ansible

From PKC
Revision as of 11:09, 9 February 2022 by Benkoo (talk | contribs) (→‎References)
Jump to navigation Jump to search

Ansible (software)(Q2852503), official website: Ansible.com. is an automation tool for IT professionals for managing software in a network environment, particularly designed to apply repetitive changes to a large number of machines. It can be used in conjunction with Terraform. A critical notion in Ansible is Ansible Roles. This helps the organization of tasks to be done in a highly modularized way. The vocabulary of Ansible Roles can also be leveraged in organizational governance.

Installation for Ubuntu

This is the community documentation landing page for Ansible. If you must ask, the answer is Yes, Ansible has a Windows implementation: Ansible for Windows.

Ubuntu Installation

The original documentation on Ansible's Ubuntu installation can be found here: The actual installation commands are:

sudo apt update
sudo apt install software-properties-common
sudo add-apt-repository --yes --update ppa:ansible/ansible
sudo apt install ansible

Installing Kubernetes with Ansible

Ansible is ideal for automating the process of installing Kubernetes software, partially because Kubernetes is a technology for managing replicated computing services in a network cluster. There are many resources that explains how to use Ansible for installing Kubernetes, we provide links to the following tutorials to get started:

  1. Create Kubernetes Cluster Using Ansible Playbook Automation
  2. Installing Kubernetes with Ansible on AWS
  3. Kubernetes setup using Ansible and Vagrant
  4. Video/Kubernetes Cluster Installation using Ansible

Running PHP code with Ansible

  1. Deploy Basic PHP Application using Ansible

Ansible Books

There are a few books on Ansible:

  1. Ansible for DevOps[1]
  2. Ansible for Kubernetes[2]

Ansible Tips

  1. RIP Tutorial on Ansible
  2. Ansible Tutorial at TutorialPoint: Ansible for Beginners
  3. Ansible: How to accept user input using var_prompt and command line
  4. Cron Jobs: Run Cron Job using Ansible Playbook
  5. How to Build Docker Images with Ansible on Ubuntu 20.04
  6. Ansible module: expect Executes a command and responds to prompts
  7. Ansible module: Network commands and responses Working with command output and prompts in network modules
  8. An introduction to Ansible facts
  9. How to navigate Ansible documentation?
  10. Mac OS Setup with Ansible
  11. Ansible Mac OSX Setup

Ansible Tutorials

Video/Create docker containers using Ansible

LaCroix, Jay (Jul 31, 2020). Getting started with Ansible Series. local page: Learn Linux TV. 


Valaxy Technologies

{{#ev:youtube |1VhPVu5EK5o }}


Installation on MacOS

The preferred way to install Ansible on a Mac is with pip.

The instructions can be found in Installing and upgrading Ansible with pip. If you are running macOS version 10.12 or older, then you should upgrade to the latest pip to connect to the Python Package Index securely. It should be noted that pip must be run as a module on macOS.

Note: macOS by default is configured for a small number of file handles, so if you want to use 15 or more forks you’ll need to raise the ulimit with sudo launchctl limit maxfiles unlimited. This command can also fix any “Too many open files” errors.

Once pip is installed, please put below command to install ansible.

python -m pip install --user ansible

Paramiko is a Python (2.7, 3.4+) implementation of the SSHv2 protocol [1], providing both client and server functionality. While it leverages a Python C extension for low level cryptography (Cryptography), Paramiko itself is a pure Python interface around SSH networking concepts. Detailed usage and API documentation can be found at our code documentation site, docs.paramiko.org. In order to use the paramiko connection plugin or modules that require paramiko, install the required module 2:

python -m pip install --user paramiko

Ansible can also be installed inside a new or existing virtualenv:

python -m virtualenv ansible 

This command will create new folder 'ansible' inside home folder, ~/

source ansible/bin/activate

And, this command will activate them

python -m pip install ansible

And, finally, install ansible inside the virtual environment. Note: Default inventory folder in MacOS is in /usr/local/etc/ansible/hosts, but, you may just want to change the defauly by issuing export command as below

export ANSIBLE_HOSTS=/path/to/your/folder

One can also write above command into ~/.bash_profile, to make the configuration persistence. To install docker_compose module for ansible, please issue below command

pip install docker-compose

Ansible for Windows

There is a video[3] from RedHat on this subject.


References

  1. Geerling, Jeff (August 5, 2020). Ansible for DevOps (2nd ed.). local page: Midwestern Mac, LLC. ISBN 978-0986393426. 
  2. Geerling, Jeff (August 5, 2020). Ansible for Kubernetes. local page: Midwestern Mac, LLC. 
  3. Davis, Matt (May 11, 2018). Manage Windows like Linux with Ansible. local page: Red Hat Summit. 

Start datetime= 11 28, 2024