Nic Acton
  • My Gitbook
  • My Favorite Things
    • Podcasts
    • Newsletters
  • Monthly Summaries
    • May 2019
    • June 2019
  • Cloud Computing
    • Cloud Concepts
    • AWS
      • Certified Solutions Architect
      • Well Architected Framework
        • Operational Excellence
        • Reliability
        • Performance Efficiency
        • Cost Optimization
        • Security
      • Analytics
        • Elasticsearch Service
        • Kinesis
        • Elastic MapReduce (EMR)
      • Compute Services
        • Elastic Beanstalk
        • Elastic Container Service (ECS)
      • Deployment
        • CloudFormation
      • Application Services
        • Key Management Service (KMS)
        • Simple Queue Service (SQS)
        • API Gateway
        • Simple Work Flow (SWF)
        • Amazon MQ
        • Simple Notification Service (SNS)
      • Simple Storage Service (S3)
        • Macie
      • Databases
        • RDS
        • DynamoDB
        • ElastiCache
        • Neptune
        • Redshift
      • Cloudfront
      • IAM
      • Monitoring
        • Trusted Advisor
        • Amazon Inspector
        • AWS Config
        • AWS Shield
        • CloudWatch
          • VPC Flow Logs
        • CloudTrail
        • Guard Duty
      • Route53
      • Serverless Architectures
        • Lambda
      • VPC
        • Highly Available & Fault Tolerant VPCs
        • Hybrid Environments
          • VPC Peering
          • Direct Connect
        • Cloud HSM
    • GCP
    • Azure
    • HashiCorp
    • Red Hat
      • RHEL
        • Basics
        • Grep & Regex
        • SSH
      • Ansible
    • Tutorials/Guides
      • Linux
        • Admin
  • Software Engineering
    • Machine Learning
      • Deep Learning
        • Tensorflow
      • Training and Loss
    • Programming
      • APIs
    • Security
    • Web Development
      • OSI 7 Layer Model
    • Tutorials/Guides
      • Apache Server
    • Virtualization
      • Virtual Machines
      • Containers
      • Serverless
  • Fitness
    • Nutrition
      • Diets
      • Macronutrients
      • Supplements
      • Miscellaneous
    • Strength Training
    • BodyBuilding
  • Miscellaneous
    • Technology Ethics
      • Education
    • Interesting Concepts
      • Libertarian Paternalism
Powered by GitBook
On this page
  • Setup
  • Inventory
  • Playbooks

Was this helpful?

  1. Cloud Computing
  2. Red Hat

Ansible

IT and Infrastructure automation

Setup

Install the EPEL repository and Ansible (or just Ansible directly)

$ sudo yum install -y epel-release
$ sudo yum install -y ansible

In its simplest form, Ansible works by workstations controlled by a control host. On both, you will need a consistent ansible user:

$ sudo useradd ansible
$ sudo passwd ansible # set a password for the user

Configure a shared key that will allow the user to log in from the control host to the workstation without password prompts:

# On the control host
$ sudo su - ansible
$ ssh-keygen
$ ssh-copy-id <workstation> # provide your ansible password here
$ logout

Configure the ansible user on the workstation host so that the ansible control host user can sudo without a password:

$ sudo visudo
# At the bottom of the file add:
ansible ALL=(ALL) NOPASSWD: ALL

Inventory

The inventory is just a list of hosts available to you in a file called inventory. Inventories will look like this:

[group_name]
node1_local_name
node2_local_name

Playbooks

Ansible playbooks are configuration files that define what you're doing to your workstation nodes in simple YAML or JSON. The following is a good playbook model for installing git on the workstation:

git-setup.yml
  --- # install git on target host
  - hosts: workstation
    become: yes
    tasks:
    - name: install git
      yum:
        name: git
        state: latest

Execute

Execute the playbook with:

$ ansible-playbook -i /home/ansible/inventory /home/ansible/git-setup.yml

Pings

Check health of a node by pinging it (you can redirect or tail output to a log):

$ ansible -i /home/ansible/inventory node2 -m ping > /home/ansible/output
PreviousSSHNextTutorials/Guides

Last updated 6 years ago

Was this helpful?