Ansible course
CHAPTER 02
Prerequisites
Linux, SSH, and YAML basics
12 min read3 sections
In this chapter
Linux basicsSSH basicsYAML basics
01Linux basics
Ansible runs over SSH, so you need Linux fundamentals. You don't need to be an expert, but you should know these concepts.
- ▸Shell: bash, cd, ls, cat, grep, pipes, redirection. Ansible runs these for you.
- ▸Users and permissions: sudo, chmod, chown. Ansible uses become (sudo) for privileged tasks.
- ▸Services: systemctl start/stop/enable. Ansible manages services with the service module.
- ▸Packages: apt, yum, dnf. Ansible manages packages with apt/yum modules.
- ▸Files: /etc/, /var/log/. Config files live here. Ansible edits them with template and copy modules.
02SSH basics
Ansible connects to targets over SSH. You need passwordless SSH (key-based auth) for automation.
- ▸Generate a key: ssh-keygen -t ed25519. Creates ~/.ssh/id_ed25519 (private) and ~/.ssh/id_ed25519.pub (public).
- ▸Copy the public key: ssh-copy-id user@server. Adds your public key to the server's authorized_keys.
- ▸Test: ssh user@server. If it logs in without a password, you are ready.
- ▸Ansible uses SSH: connects as the user you specify. Needs sudo access for privileged tasks.
03YAML basics
Ansible playbooks are written in YAML. YAML is human-readable. It uses indentation (spaces, not tabs) to show structure.
- ▸Indentation matters (2 spaces per level)
- ▸Lists use dashes (-)
- ▸Key-value pairs use colons (:)
- ▸Strings don't need quotes (usually)
- ▸Comments start with #
name: John age: 30 skills: - Linux - Docker - Ansible address: city: NYC zip: 10001
Check your understanding
0 / 1 correct
What does become: yes do in a playbook?