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.

How to see the directory size in Linux with command line

In this Video we cover the du command. du estimate’s the file space usage

First we look at the du mange page and then we cover some real world examples

Use du to list files size

du [file]

Make du human readable

du -h

Use du to list directory size (summarize)

du -sh /home

Use du to summarize directory’s under a parent

du -h –max-depth=1 /etc

Du one file system

du -sxh /mnt

Exclude files from du

du –exclude=’*.gz’

How to see file system disk usage from command line in Linux

In this video we cover the df command. DF reports file system disk space usage. DF differs from du because it looks at the file system and not files or directories.

We look at the man page for df and then we do some examples and what the output means

List disk usage on all file systems

df -a

Df human readable

df -h /

Use DF to check inodes

df -i

Show only local filesystems

df -hl

Linux Filesystem Hierarchy

In this video I cover Linux file system hierarchy.  The somewhat loosely followed systems give some standardization to Linux distributions.

Lets look at $ man hier.

You will notice / root which is a must,  proc which is a pseudo file systems and some things missing like /dev/shm or shared memory system which is a tmpfs

 

Strip metadata from images command line

In this video I use Linux and ImageMagic to strip the location, camera information and other metadata from a jpg image file.

First we look at the image exif and other metadata with strings and identify

Next we strip the date with mogrify strip and diff the identify -verbose between the new and a backup.

Finally I go over mogrify -strip -auto-orient which will keep the proper photo geometry and orientation and we diff the strip difference.

 

Fedora 29 Mate spin post install

In this video I cover some of the things I do post install on a Fedora system.

OS update
$ dnf update

#install chrome

Set sudo wheel no password

$ sudo visudo

Block root on ssh
Disable dns lookups in sshd
Start and enable sshd
$ sudo systemctl start sshd
$ sudo systemctl enable sshd

Fix my bashrc
bind ‘”\e[A”: history-search-backward’
bind ‘”\e[B”: history-search-forward’

export HISTCONTROL=ignoreboth
export HISTSIZE=100000

Set up https://rpmfusion.org/

Disable ipv6

Disable screen saver password and power magnet for virtual guest

Tuned set virtual guest

Linux ls command

In this video I go over the most important command in Linux which is the ls command. Ls is how to list directory content.

 

First we look at the ls man page.  then we go over some ls examples

Ls show hidden file (all)

ls -a

Ls long listing

ls -l

Ls recursive

ls -lR

Ls human readable file sizes

ls -hs

Sorting by size with ls

ls -AlhS

Shoring by size in reverse

ls -AlhSr

Sorting by modified time with ls

ls -Alt