Geavanceerd
Zoeken inSamenvattingen
Zo zoek je
  • Woorden vinden lestitels, tekst en code. Filter op soort (gidsen, cursussen, programma's, boeken) of blijf in dit boek.
  • book:rhcsa en ch:8 maken de zoektocht kleiner; #code vindt een woord alleen in commando's van de lessen.
  • "twee woorden" vindt precies die zin.
  • Gewone woorden vinden namen, teksten en voorbeelden.
  • ↑ ↓ bewegen · Enter openen · Esc sluiten · / zoeken
Probeer:

Cursus 3Naam in de cursus: RedHat Certified Engineer (RHCE) Prep Course

Red Hat Certified Engineer (RHCE) Prep Course

Course 3 of 13 in the Alta3 Academy library. Alta3 Academy self-paced course.

Notitie

My result — Lessons read: all 60/60; Course progress: 100%.

  • 18 Lessen
  • 10 Commando's
  • 1 Labs

Dit deel is nog niet vertaald. Je ziet de Engelse tekst.

$ als gewone gebruiker# als root (of met sudo)

3.1

What the course covers

Ansible from the first lesson. What it is, the main parts, and how to run it on RHEL servers.

  • YAML, inventories, playbooks, tasks, modules, variables, facts, and loops.
  • Modules for the main RHCE jobs: packages, files, templates, users, services, firewall, and storage.
  • Roles, collections, Ansible Galaxy, and Ansible Vault.
  • Real Linux admin jobs with Ansible: cron, SELinux, SSH keys, disks, repos, and network.
  • A full mock RHCE exam with 11 tasks. It follows the EX294 exam style.
  • Terminal skills: Vim, tmux, ansible-navigator, and ansible-doc.
  • How to write playbooks that are idempotent. Run them again and the end state is the same.

3.2

Welcome and lab setup

Three short lessons show how the course works.

  • VIRGIL is an AI helper inside the lab. It knows which lab you are on.
  • The lab runs in a browser. Each command has a copy icon. Paste it in the terminal.

3.3

Required tools: Vim and tmux

Vim has modes. Press i to type. Press Esc to stop. :wq saves and quits. :q! quits and drops the changes.

  • tmux is a terminal multiplexer. It splits one window into many panes.
  • A tmux command starts with Ctrl-B. Then % makes a vertical split. You can move, zoom, and close panes.

3.4

Ansible overview

Ansible has parts that work together: modules, tasks, plays, playbooks, inventory, variables, Jinja, and handlers.

  • A module does one job. A task calls a module. A play groups tasks. A playbook groups plays.
  • The inventory says which hosts Ansible will touch.

3.5

Ansible basics

YAML is the language of playbooks. It has maps and lists. Indentation matters. # starts a comment.

  • An inventory lists hosts and groups. The course uses both INI and YAML forms.
  • ansible-playbook runs a playbook. ansible runs one ad-hoc command.
  • ansible.cfg stores defaults, so you type less. Ansible looks for it in this order: ANSIBLE_CONFIG, then ./ansible.cfg, then ~/.ansible.cfg, then /etc/ansible/ansible.cfg.
  • Loops use loop: with a list. Variables can come from vars, vars_files, host vars, -e, vars_prompt, register, and set_fact. Precedence decides which value wins.

3.6

Critical modules and keywords

copy sends a file from the control node. It can also set owner, group, and mode.

  • file makes files and folders, or removes them when state is absent. template fills a Jinja2 file and sends it.
  • get_url downloads a file with HTTP. uri sends HTTP requests, for example a GET to a protected page.
  • when runs a task only if a test is true. Tags let you run part of a playbook with --tags, --skip-tags, or --list-tasks.

Commando's in deze les

3.7

System essentials

ansible-navigator runs playbooks and reads module docs in a menu. It works well with Execution Environments.

  • dnf installs and removes packages. yum_repository adds, enables, or disables repos.
  • Facts are data Ansible collects about a host. register saves command output, and when can use it.

Commando's in deze les

3.8

Advanced Ansible

Handlers run only when a task reports a change. A notify calls a handler by name. A listener can catch many notifies.

  • block, rescue, and always group tasks and handle errors.
  • Collections and roles package content. Galaxy is the sharing site. ansible-galaxy installs and creates them.
  • Vault encrypts files. ansible-vault creates, encrypts, edits, and decrypts them.

3.9

System configuration

Add, enable, disable, and pin repos with yum_repository and dnf.

  • lineinfile changes one line. blockinfile adds or removes a block. Use stat to check a file first.
  • at runs a job one time. cron runs a job again and again for a user.

3.10

Users and security

group and user create accounts. A user can have a primary group and extra groups.

  • file and copy set owner, group, and mode. A loop makes many paths fast.
  • authorized_key puts a public key in ~/.ssh/authorized_keys. Then fix the .ssh folder permissions.
  • seboolean sets SELinux booleans and keeps them after a reboot. auditd logs denials. ausearch and audit2why help you read them.

3.11

Services and networking

systemd starts, stops, enables, and disables services. Enable means "start at boot".

  • firewalld opens ports in a zone. permanent: yes keeps the rule after a reboot.

3.12

Storage

parted makes partitions. filesystem formats them.

  • mount mounts a filesystem and writes /etc/fstab, so it comes back after a reboot.
  • Reboot and check that each mount point is still there.

Commando's in deze les

3.13

Utilities, extras, and the mock exam

json_query filters data with JMESPath. set_fact stores the result.

  • archive makes a compressed file. unarchive extracts it. stat plus when avoids repeat work.
  • A challenge asks you to turn three shell scripts into playbooks.
  • The mock exam has 11 tasks: LVM storage, users and backups, a network bond, managed nodes, a script conversion, user loops, retry logic, a MOTD template, navigator use, an Apache role, and Vault.

Commando's in deze les

3.14

Key commands and tools

3.15

Key terms

The words of this course in one table. Learn them before the quiz or exam.

TermMeaning
AnsibleA tool that automates Linux admin work from one control node.
Ansible GalaxyThe public site for sharing roles and collections.
CollectionA package of modules, roles, and plugins.
Control nodeThe machine where you write and run Ansible. In this course it is bchd.
Execution EnvironmentA container image that holds Ansible and its tools.
FactData Ansible gathers about a host, like its OS or memory.
Fully qualified module nameThe long name of a module with its collection, like ansible.builtin.copy.
HandlerA task that runs only when another task notifies it.
IdempotentSafe to run again. The end state stays the same and nothing extra changes.
InventoryA list of hosts and groups. It can be INI or YAML.
Jinja2A template language. It adds variables, if, and for to text files.
ListenerA name that groups handlers, so one notify can start them all.
LoopOne task that runs again for each item in a list.
Managed nodeA server that Ansible connects to and changes.
ModuleA small program that does one job, like copy or dnf.
PlayOne part of a playbook. It maps a group of hosts to a set of tasks.
PlaybookA YAML file with plays and tasks.
RoleA folder with tasks, handlers, vars, defaults, and meta for one job.
TagA label on a task. You can run only some tags with --tags.
TaskOne step in a play. One module does the work.
TemplateA text file with Jinja2 placeholders. The template module fills it in.
VariableA named value that you reuse in a playbook.
VaultThe Ansible tool that encrypts secret files.
whenA test that decides if a task runs.
YAMLA text format with lists and maps. Indentation is important.

Commando's in deze les

3.16

Check yourself

Answer each question first, then open it to check the answer.

1What does ansible.cfg do? Name one setting you can put in it.

It stores default settings for Ansible, so you do not type them every time. You can set the default inventory, a callback for output, or default tags to run or skip.

2What is the difference between ansible and ansible-playbook?

ansible runs one ad-hoc command on hosts. ansible-playbook runs a YAML file with one or more plays and many tasks.

3When does a handler run?

A handler runs only when a task notifies it. The notify fires at the end of a block of tasks, and the handler runs once, even if many tasks call it.

4How do you keep a firewalld rule after a reboot?

Open the port with the firewalld module and set permanent: yes. Without that, the rule is only in memory and is lost at boot.

5What is the difference between a role and a collection?

A role is a folder with tasks, handlers, vars, defaults, and meta for one job, like apache_webserver. A collection is a bigger package that can hold roles, modules, and plugins, like ansible.posix.

Oefenen

Alle commando's in dit hoofdstuk