Ansible Homebrew



Windows Podman is a tool for running Linux containers. You can do this from a Windows desktop as long as you have access to a linux box either running inside of a VM on the host, or available via the network. Jeff Geerling (geerlingguy) maintains a large variety of open source Ansible content. This website catalogs it all. About Jeff Geerling (geerlingguy) Jeff Geerling is an author and software developer from St. He started using Ansible in 2013 and maintains numerous Ansible works. Ansible将会对远程系统模块参数记录在远程的syslog中,除非一个任务或者play被标记了“nolog: True”属性,稍后解释. 在主控机上启用基本的日志功能参见 Ansible的配置文件 文档 并 在配置文件中设置’logpath’.企业用户可能也对 Ansible Tower 感兴趣. Unmaintained Ansible versions can contain unfixed security vulnerabilities (CVE). Please upgrade to a maintained version. See the latest Ansible documentation. Homebrewcask - Install/uninstall homebrew.

As mentioned in my first post, I’d like to try and build a Linux machine with Jenkins, GIT, Maven, Java and Docker.The end goal is to run Selenium WebDriver tests in dockerised containers. I have a lot to learn but I feel this is an area I need to grow my skill set.Also, as I work in test, I am also learning to use test-kitchen to execute infrastructure code.

Ansible Homebrew

The book I am learning from is Ansible From Beginner to Pro.I did encounter a few problems whilst following the book as versions of libraries have changed but I’ve managed to get past these errors so far.

This tutorial and the next few to follow have been completed on a Mac with OSX El Capitan. The steps on a Windows machine are likely to be different.

Goals

In this tutorial, we will:

  • Install VirtualBox
  • Install Vagrant
  • Install Ansible
  • Check it all works

Introduction

VirtualBox

Virtualisation allows multiple operating systems to simultaneously share your processor resources in a safe and efficient manner.VirtualBox is a provider for virtualisation and it allows your operating system to run in a special guest environment on top of your existing host operating system.In my case, the host operating system is OSX El Capitan.

Vagrant

Vagrant is an open source software for creating a portable development environment within minutes. It is useful for adevelopment team to mimic a server’s configuration locally. It can also be useful fortesting a version of Internet Explorer on a Mac for example.

Ansible

Ansible is a provisioning framework used to deploy software in a consistent manner in one or more machines.It ensures each machine is working with an identical environment.

Note:

I have used Homebrew to install the above mentioned software.Homebrew is a package managment system thatsimplifies the installation of software on the Mac operating system.

To install Homebrew, just follow the simple instructions on their website.

Step 1 - Install VirtualBox

In terminal, type in the following command

brew cask install VirtualBox

Step 2 - Install Vagrant

In terminal, type in the following command

brew cask install vagrant

Step 3 - Install Ansible

In terminal, type in the following command

brew install ansible

Step 4 - Check Installations were Successful

Type in the following commands and if the version is printed, then the installation was successful.

VBoxManage --version

vagrant --version

ansible --version

My versions respectively are:

5.2.6r120293

Vagrant 2.0.1

ansible 2.4.2.0

Step 5 - Install an Ubuntu Server with Vagrant

Before we start using Ansible, we’ll need an environment which we can use to develop our new infrastructure. This is where we use Vagrant.

a. Create a new directory which will contain all your virtual machine installations. I normally put all my projects under a directory called development.Create a directory called virtualmachines and inside this create a directory called ansible-playbook:

mkdir virtualmachines && cd virtualmachines

mkdir ansible-playbook && cd ansible-playbook

On my machine, the full path looks like this:

/Users/pateli03/development/virtualmachines/ansible-playbook

b. To create the virtual machine on which you’re going to install packages and configure with Ansible, run this command:

vagrant init ubuntu/trusty64

This will create a file called Vagrantfile. We will be editing this file in Step 6 but this is what the contents of the file should look like (but with a lot more comments):

c. Finally, get Ubuntu Trusty up and running by executing:

vagrant up

When you execute this command the first time, a few things happen. First, it will check if a box with the name ubuntu/trusty64exists on your machine. If it doesn’t, it will download it from Atlas, a platform to host and discover Vagrant boxes.It is maintained by HashiCorp, the team behind Vagrant.

This could take a few minutes as this is downloading an entire operating system.

  • Once downloaded, Vagrant uses VirtualBox to create a virtual machine and boot it.

You can check the status of this virtual machine by running the command:

vagrant status

You can also log in to the machine using:

vagrant ssh

This logs in to the machine using a known SSH key that was generated when the virtual machine was created.

To logout of this machine you can use the command exit

Step 6 - Hello Ansible

We need to let Vagrant know that we want to run Ansible on this virtual machine by adding some instructionsto the Vagrantfile. Go ahead and open the Vagrantfile in your favourite text editor but I recommend using Vim which isa text editor on Unix-like operating system. Vim has recently become important in my day-to-day life so it is another toolI would like to be more fluent in.

Open your Vagrantfile using this command:

vim Vagrantfile

Press i on your keyboard to insert text. You will see the bottom of the terminal window change to -- INSERT --

before the last end statement, add the following configuration:

It should look similar to this:

To save the changes:

press ESC on the keyboard to come back to command mode

then Shift + :

then w + q

then Enter to finish saving your changes.

(Note: Don’t enter the + symbol)

Step 7 - Creating the playbook

An Ansible playbook is a YAML file which contains a set of instructions to manage the configuration of remote machines.We will create a playbook now as using the same path specified in our Vagrantfile above – in a directory called provisioning.

mkdir provisioning && cd provisioning

touch playbook.yml

vim playbook.yml

press i on the keyboard to insert text

Copy and paste the below configuration code which will ping you virtual machine to confirm you can connect to it.

I’ll go into more detail on the configuration format in subsequent posts but be aware YAML syntax is whitespace sensitive.Tabs and whitespaces mean different things. YAML uses spaces and the suggested indentation is 2 spaces.

To save the changes:

press ESC on the keyboard to come back to command mode

then Shift + :

then w + q

then Enter to finish saving your changes.

Step 8 - Running the playbook

You should now be able to run Ansible on your machine. Change directory one level up to the location of your Vagrantfile:

cd ..

Ansible Homebrew Interview

vagrant provision

You should see something quite similar to the image below. Notice the ping task was successfully executed.

Boom! You’ve just provisioned your first virtual machine using Ansible and Vagrant.

Step 9 - Let’s look at VirtualBox

As mentioned earlier, VirtualBox provides us with virtualisation and although it seems like we haven’t done anything with it,let’s have a look. Open the VirtualBox application (You can easily do this with Spotlight - cmd + space and type VirtualBox)

You should have something similar to this:

This is letting us know that Ubuntu Trusty is running properly. Happy days.

Summary

VirtualBox is the software which runs the Operating System and Vagrant acts as a wrapper around VirtualBox to manage it.Together, they can be used to create a local environment that matches your production environment or an environment toexecute Selenium Tests.

With our foundations in place - the next post will focus on using test-kitchen, a test harness used for testing infrastructure codeon isolated platforms. This is quite exciting, a TDD method to design infrastructure.


Ansible Homebrew

Commands used in this post

CommandDescription
brew cask install VirtualBoxInstalls VirtualBox using Homebrew
brew cask install vagrantInstalls Vagrant using Homebrew
brew install ansibleInstalls Ansible using Homebrew
VBoxManage --versionVersion of VirtualBox installed
vagrant --versionVersion of Vagrant installed
ansible --versionVersion of Ansible installed
vagrant init ubuntu/trusty64Initialise a virtual machine with Ubuntu Trusty
vagrant upStart a virtual machine
vagrant statusStatus of virtual machine
vagrant sshSSH into the virtual machine
vagrant provisionRun a playbook to provision the virtual machine
vim VagrantfileOpen a file called Vagrantfile with Vim text editor
touch playbook.ymlCreate a new file called playbook.yml


HomebrewPlease enable JavaScript to view the comments powered by Disqus.

Ansible Homebrew Pro

Jeff Geerling (geerlingguy) maintains a large variety of open source Ansible content. This website catalogs it all.

About Jeff Geerling (geerlingguy)

Jeff Geerling is an author and software developer from St. Louis, MO. He started using Ansible in 2013 and maintains numerous Ansible works.

Ansible Books

Ansible for DevOpsAnsible for Kubernetes

Project Maintenance Status

I maintain over 250 open source projects and two bestselling books, and without some level of automation (and maybe a little sleep from time to time), it would be impossible for me to keep all the projects relevant.

I use a stale issue bot to clean up repository issues and PRs, and I also sometimes informally put a project into ‘maintenance only’ mode. That is indicated in the listings below using the following conventions:

IconDescription
Actively used and maintained.
!Maintenance and bugfixes only.
Not maintained.

Table of Contents

Ansible-based Operators

Brew Install Ansible Specific Version

NameTest StatusMaintained?Repository
Drupal OperatorGitHub
MariaDB OperatorGitHub
Mcrouter Operator!GitHub
Ansible Tower/AWX OperatorGitHub

Container Images Built with Ansible

NameTest StatusMaintained?Repository
geerlingguy/drupalGitHub
geerlingguy/fathomGitHub
geerlingguy/php-apacheGitHub
geerlingguy/solrGitHub

Container Images for Ansible Testing

NameTest StatusMaintained?Repository
geerlingguy/docker-ubuntu2004-ansibleGitHub
geerlingguy/docker-ubuntu1804-ansibleGitHub
geerlingguy/docker-ubuntu1604-ansibleGitHub
geerlingguy/docker-ubuntu1404-ansibleGitHub
geerlingguy/docker-ubuntu1204-ansibleGitHub
geerlingguy/docker-centos8-ansibleGitHub
geerlingguy/docker-centos7-ansibleGitHub
geerlingguy/docker-centos6-ansibleGitHub
geerlingguy/docker-debian10-ansibleGitHub
geerlingguy/docker-debian9-ansibleGitHub
geerlingguy/docker-debian8-ansibleGitHub
geerlingguy/docker-ubi8-ansibleGitHub
geerlingguy/docker-amazonlinux2-ansibleGitHub
geerlingguy/docker-fedora33-ansibleGitHub
geerlingguy/docker-fedora32-ansibleGitHub
geerlingguy/docker-fedora31-ansibleGitHub
geerlingguy/docker-fedora30-ansibleGitHub
geerlingguy/docker-fedora29-ansibleGitHub
geerlingguy/docker-fedora27-ansibleGitHub
geerlingguy/docker-fedora24-ansibleGitHub

See also: Testing your roles with Molecule

Ansible Collections

Ansible Package Module

NameTest StatusMaintained?Repository
geerlingguy.k8sGitHub
geerlingguy.php_rolesGitHub

Ansible Roles

NameTest StatusMaintained?Repository
geerlingguy.adminerGitHub
geerlingguy.ansibleGitHub
geerlingguy.apacheGitHub
geerlingguy.apache-php-fpmGitHub
geerlingguy.aws-inspectorGitHub
geerlingguy.awxGitHub
geerlingguy.backupGitHub
geerlingguy.bad_judgementGitHub
geerlingguy.blackfireGitHub
geerlingguy.certbotGitHub
geerlingguy.clamavGitHub
geerlingguy.collectd-signalfxGitHub
geerlingguy.composerGitHub
geerlingguy.daemonizeGitHub
geerlingguy.dockerGitHub
geerlingguy.docker_armGitHub
geerlingguy.dotfilesGitHub
geerlingguy.drupalGitHub
geerlingguy.drushGitHub
geerlingguy.ecr_container_buildGitHub
geerlingguy.elasticsearchGitHub
geerlingguy.elasticsearch-curatorGitHub
geerlingguy.eximGitHub
geerlingguy.fathomGitHub
geerlingguy.filebeatGitHub
geerlingguy.firewallGitHub
geerlingguy.fluentdGitHub
geerlingguy.gitGitHub
geerlingguy.github-usersGitHub
geerlingguy.gitlabGitHub
geerlingguy.glusterfsGitHub
geerlingguy.gogsGitHub
geerlingguy.haproxyGitHub
geerlingguy.hdparmGitHub
geerlingguy.helmGitHub
geerlingguy.homebrewGitHub
geerlingguy.htpasswdGitHub
geerlingguy.javaGitHub
geerlingguy.jenkinsGitHub
geerlingguy.k8s_manifestsGitHub
geerlingguy.kibanaGitHub
geerlingguy.kubernetesGitHub
geerlingguy.logstashGitHub
geerlingguy.mailhogGitHub
geerlingguy.masGitHub
geerlingguy.memcachedGitHub
geerlingguy.muninGitHub
geerlingguy.munin-nodeGitHub
geerlingguy.mysqlGitHub
geerlingguy.nfsGitHub
geerlingguy.nginxGitHub
geerlingguy.nodejsGitHub
geerlingguy.ntpGitHub
geerlingguy.packerGitHub
geerlingguy.packer-debianGitHub
geerlingguy.packer_rhelGitHub
geerlingguy.passengerGitHub
geerlingguy.phpGitHub
geerlingguy.php-memcachedGitHub
geerlingguy.phpmyadminGitHub
geerlingguy.php-mysqlGitHub
geerlingguy.php-pearGitHub
geerlingguy.php-peclGitHub
geerlingguy.php-pgsqlGitHub
geerlingguy.php-redisGitHub
geerlingguy.php-tidewaysGitHub
geerlingguy.php-versionsGitHub
geerlingguy.php-xdebugGitHub
geerlingguy.php-xhprofGitHub
geerlingguy.pimpmylogGitHub
geerlingguy.pipGitHub
geerlingguy.postfixGitHub
geerlingguy.postgresqlGitHub
geerlingguy.puppetGitHub
geerlingguy.rabbitmqGitHub
geerlingguy.raspberry-piGitHub
geerlingguy.redisGitHub
geerlingguy.repo-dotdebGitHub
geerlingguy.repo-epelGitHub
geerlingguy.repo-puiasGitHub
geerlingguy.repo-remiGitHub
geerlingguy.rubyGitHub
geerlingguy.sambaGitHub
geerlingguy.securityGitHub
geerlingguy.solrGitHub
geerlingguy.ssh-chroot-jailGitHub
geerlingguy.supervisorGitHub
geerlingguy.svnGitHub
geerlingguy.svn2gitGitHub
geerlingguy.swapGitHub
geerlingguy.varnishGitHub

Ansible Projects

Name and LinkTest StatusMaintained?
Ansible Requirements UpdaterN/A
Mac Development Playbook
Packer Boxes
Drupal VM
Raspberry Pi Dramble
Drupal Pi
Turing Pi Cluster!
Ansible Vagrant ExamplesN/A!

Also see all my blog posts about Ansible and all my YouTube videos about Ansible.

Ansible Videos and Presentations

Place and DateTitle
YouTube
April 2020
Ansible 101 streaming series
DrupalCon Seattle 2019
November 26, 2019
Everything I know about Kubernetes I learned from a cluster of Raspberry Pis
AnsibleFest Atlanta 2019
September 25, 2019
There’s a Role for that! How to evaluate community roles for your playbook
AnsibleFest Austin 2018
August 21, 2018
Make your Ansible playbooks flexible, maintainable, and scalable
MidCamp 2018
March 10, 2018
Jenkins or: How I learned to stop worrying and love automation
AnsibleFest SF 2016
July 28, 2016
Ansible Roles for Fun and Profit!
php[tek] 2016
May 25, 2016
Highly Available Drupal on a Raspberry Pi Cluster
YouTube
July 27, 2015
Nginx Load Balancer Visualization on a Cluster of Raspberry Pis
YouTube
July 14, 2015
Ansible 101 on a Cluster of Raspberry Pi 2s
MidCamp 2015
March 21, 2015
Ansible + Drupal: A Fortuitous DevOps Match
YouTube
March 8, 2015
Ansible serial/forks demo on a Cluster of Raspberry Pis
DrupalCon Austin
June 5, 2014
DevOps for Humans: Ansible for Drupal Deployment Victory!
Meetup
January 14, 2014
Local Dev on Virtual Machines - Vagrant, VirtualBox and Ansible

Inspiration

This site was inspired by Robert de Bock’s similar Ansible roles site.

You can view this site's source on GitHub. It is hosted on GitHub Pages and uses a theme by mattgraham.