Introduction to Ansible

In this video I will cover what is Ansible. How it works. Pros and Cons and where to find out more information.

So what is Ansible? Ansible is an agentless automation and configuration tool. Ansible can also be used for workflow automation. It can do anything from provision servers to run one off commands on many host or host groups in parallel.

Ansible is written in python and uses ssh to execute commands on different systems. Ansible uses a inventory to group and nest systems.

In Ansible you uses modules to create task that do things. You put task in playbooks which are written YAML.

An example of a one off command would be

ansible server1 -a "hostname"

Note: the default module is shell. I also already have my .ansible.cfg and inventory set up which Ill cover in a future video.


Now an example of a playbook I have written todo the same thing

nathan@thenathan:~$ cat ansible/hostname.yml


– name: Get Hostname
gather_facts: False
hosts: all
tasks:
– name: Run Shell command hostname
shell: “hostname”

nathan@thenathan:~$ ansible-playbook ansible/hostname.yml
server1 | SUCCESS | rc=0 >>
server1.thenathan.net

Lets cover some of the pros and cons. A pro and a con is its againtless. Its nice that you can use ssh and not have to for the most part install software or make firewall changes for off ports. Thats also a con because if a system is down or times out the change or command wont be applied unless you rerun it.

Ansible inventory is fantastic. Its very powerfull in the way you can group and nest systems which makes it a great tool if you want to run adhock shell commands. Which also makes Ansible a good fit for running along side other tools like chef.

Ansible does a good job of gathering information (AKA Facts) off systems which you can use to customize commands or configs.

Playbooks use yaml. Its up to you if that’s a pro or con.

Ansible has great documentation which is another pro. I find the documentation and examples better then salt stack and chef. You can find the documentation at https://docs.ansible.com/ This is the first in a series of videos I want to do on Ansible. For the code and command I used in this video check out my blog post on thenathan.net Pleas like, share and subscribe.

SSH Keys Simplified

In this video I try to simplify ssh keys, ssh login with/without a password and ssh agent.

.bashrc

#check thats its not sftp
if [ “$SSH_TTY” ]; then
#set up ssh agent for keys.
if [ -z “$SSH_AUTH_SOCK” ] ; then
eval `ssh-agent -s`
ssh-add
fi
fi

.bash_logout

eval $(ssh-agent -k)

CentOS 7 Minimal Install

In this video I install CentOS 7 Minimal from ISO in QEMU/KVM.

After the install I configure the network to start on boot, bring up the network interface do a OS update and install some necessary packages like bind-utils, net-tools and bash-completion.

I also config tuned with the virtual-guest profile, enable sshd at boot and set sudo no password.