red hat
Rather than going super hard on ansible, I’m taking it a section at a time. It’s easy for me to get really excited about a new topic, not see any progress, burnout, and never see or use it again.
I currently have 3 VMs:
Here’s me doing the initial setup. You need to:
Now, in the video, you’ll see me repeatedly use ssh-copy-id HOSTNAME, because I forgot that when I installed the VMs, I left the option to ssh as root unchecked. Here’s how to unblock yourself: Enable root login over SSH. I’ll also admit that when I first made the change in the sshd-config file, I didn’t restart sshd.service. So, take it from me, DON’T SKIM… READ!
Ok, so after you finally get the SSH setup. You’ll build your inventory. This is basically the list of nodes you want to be managed by Ansible. It’s not so much of a mistake, but I made my myhosts from the root user, so I needed to change the permissions so that I could edit it as jarvis. Now, I used chmod 777 because this is a test environment and I’m learning, but if this were real, I’d either remake it as jarvis or make a group for Ansible users that myhosts could be edited by. I go and separate my nodes into two groups, test and prod, and display the results.
For this final clip - it’s lengthy. I start by creating the configuration file. From what I read about the /etc/ansible/ folder, it’s not something you tinker with, but rather it’s something you use as a reference. So initially, Ansible is using its own config file, but we want it to change to our own. It’s not difficult, you just create your file, add a defaults and privilege_escalation section and fill out your information. I screwed up here because (I was skimming again, lol) although I made the correct files, I needed to make them with the appropriate user. So, right after you’ve created your Ansible user and granted them sudo privileges, log into that user and create your SSH keys, copy them to the other nodes, and create your play folder, myhosts and ansible.cfg files.
A good chunk of the video is me trying to redirect the location of the default ansible.cfg file. I wanted to leave it in the video as a reminder of what could happen if you think you’re following along, but really going in your own direction. I’ll be going through that chapter again, but once I get my config file in order, I run into issues with my ssh key not working. But, because you’ve listened to me, you won’t have to worry about that part.
And finally, after I retrace my steps and correct everything, I can check for uptime and ping all of my nodes. I’m off to take a break and go get some ice cream.
I’m following Learn Ansible Quickly by Ahmed Alkabary.