Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing Render and Headers of the Docs #2113

Merged
merged 4 commits into from
Feb 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions exercises/ansible_rhel/1.4-variables/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ Variables in Ansible are powerful tools for making your playbooks flexible and r
### Step 1 - Understanding Variables
A variable in Ansible is a named representation of some data. Variables can contain simple values like strings and numbers, or more complex data like lists and dictionaries.

<!-- {% raw %} -->
### Step 2 - Variable Syntax and Creation
The creation and usage of variables involve a specific syntax:

Expand All @@ -31,9 +32,12 @@ The creation and usage of variables involve a specific syntax:
* Starting with a letter or underscore.
* Containing only letters, numbers, and underscores.
3. Using Variables: Variables are referenced in tasks using the double curly braces in quotes `"{{ variable_name }}"`. This syntax tells Ansible to replace it with the variable's value at runtime.
<!-- {% raw %} -->


Update the `system_setup.yml` playbook to include and use a variable:

<!-- {% raw %} -->
```yaml
---
- name: Basic System Setup
Expand All @@ -54,6 +58,7 @@ Update the `system_setup.yml` playbook to include and use a variable:
state: present
create_home: true
```
<!-- {% raw %} -->

Run this playbook with `ansible-navigator`.

Expand Down Expand Up @@ -97,6 +102,8 @@ The register keyword in Ansible is used to capture the output of a task and save

Update the `system_checks.yml` playbook:

<!-- {% raw %} -->

```yaml
---
- name: System Configuration Checks
Expand All @@ -115,6 +122,7 @@ Update the `system_checks.yml` playbook:
msg: "User {{ user_name }} exists."
when: user_check.rc == 0
```
<!-- {% raw %} -->

Playbook Details:

Expand Down
11 changes: 10 additions & 1 deletion exercises/ansible_rhel/1.5-handlers/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ Let's add to the system_setup.yml playbook the ability to install the Apache HTT

> NOTE: Previous examples had hosts set to node1 but now it is set to all. This means when you run this updated Ansible playbook you will notice updates for the new systems being automated against, the user Roger created on all new systems and the Apache web server package httpd installed on all the hosts within the web group.

<!-- {% raw %} -->

```yaml
---
- name: Basic System Setup
Expand Down Expand Up @@ -64,6 +66,8 @@ Let's add to the system_setup.yml playbook the ability to install the Apache HTT
when: inventory_hostname in groups['web']
```

<!-- {% raw %} -->

In this example, `inventory_hostname in groups['web']` is the conditional statement. `inventory_hostname` refers to the name of the current host that Ansible is working on in the playbook. The condition checks if this host is part of the `web` group defined in your inventory file. If true, the task will execute and install Apache on that host.

### Step 3 - Handlers
Expand Down Expand Up @@ -175,7 +179,7 @@ node3 : ok=8 changed=4 unreachable=0 failed=0 s
Loops in Ansible allow you to perform a task multiple times with different values. This feature is particularly useful for tasks like creating multiple user accounts in our given example.
In the original system_setup.yml playbook from Exercise 1.4, we had a task for creating a single user:


<!-- {% raw %} -->
```yaml
- name: Create a new user
ansible.builtin.user:
Expand All @@ -184,9 +188,11 @@ In the original system_setup.yml playbook from Exercise 1.4, we had a task for c
create_home: true

```
<!-- {% raw %} -->

Now, let's modify this task to create multiple users using a loop:

<!-- {% raw %} -->
```yaml
- name: Create a new user
ansible.builtin.user:
Expand All @@ -198,12 +204,15 @@ Now, let's modify this task to create multiple users using a loop:
- bob
- carol
```
<!-- {% raw %} -->

<!-- {% raw %} -->
What Changed?

1. Loop Directive: The loop keyword is used to iterate over a list of items. In this case, the list contains the names of users we want to create: alice, bob, and carol.

2. User Creation with Loop: Instead of creating a single user, the modified task now iterates over each item in the loop list. The `{{ item }}` placeholder is dynamically replaced with each username in the list, so the ansible.builtin.user module creates each user in turn.
<!-- {% raw %} -->

When you run the updated playbook, this task is executed three times, once for each user specified in the loop. It's an efficient way to handle repetitive tasks with varying input data.

Expand Down
6 changes: 6 additions & 0 deletions exercises/ansible_rhel/1.6-templates/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ Ansible leverages Jinja2, a widely-used templating language for Python, allowing

### Step 2 - Crafting Your First Template

<!-- {% raw %} -->
Templates end with a `.j2` extension and mix static content with dynamic placeholders enclosed in `{{ }}`.
<!-- {% raw %} -->

In the following example, let's create a template for the Message of the Day (MOTD) that includes dynamic host information.

Expand All @@ -41,12 +43,16 @@ mkdir -p ~/lab_inventory/templates

Create a file named `motd.j2` in the templates directory with the following content:

<!-- {% raw %} -->

```jinja
Welcome to {{ ansible_hostname }}.
OS: {{ ansible_distribution }} {{ ansible_distribution_version }}
Architecture: {{ ansible_architecture }}
```

<!-- {% raw %} -->

This template dynamically displays the hostname, OS distribution, version, and architecture of each managed host.

### Step 3 - Deploying the Template with a Playbook
Expand Down
12 changes: 12 additions & 0 deletions exercises/ansible_rhel/1.7-role/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ Building on our previous work with Apache configuration, let's craft an Ansible

Run the following Ansible playbook to clean the environment:

<!-- {% raw %} -->

```yaml
---
- name: Cleanup Environment
Expand Down Expand Up @@ -66,6 +68,8 @@ Run the following Ansible playbook to clean the environment:
content: ''
```

<!-- {% raw %} -->

### Step 3 - Building the Apache Role

We'll develop a role named `apache` to install, configure, and manage Apache.
Expand Down Expand Up @@ -94,6 +98,8 @@ apache_service_name: httpd

Adjust `/home/student/lab_inventory/roles/apache/tasks/main.yml` to include tasks for Apache installation and service management:

<!-- {% raw %} -->

```yaml
---
# tasks file for ansible-files/roles/apache
Expand Down Expand Up @@ -128,6 +134,8 @@ Adjust `/home/student/lab_inventory/roles/apache/tasks/main.yml` to include task
notify: Reload Firewall
```

<!-- {% raw %} -->

4. Implement Handlers:

In `/home/student/lab_inventory/roles/apache/handlers/main.yml`, create a handler to restart firewalld if its configuration changes:
Expand All @@ -145,6 +153,8 @@ In `/home/student/lab_inventory/roles/apache/handlers/main.yml`, create a handle

Use a Jinja2 template for a custom `index.html`. Store the template in `templates/index.html.j2`:

<!-- {% raw %} -->

```html
<html>
<head>
Expand All @@ -156,6 +166,8 @@ Use a Jinja2 template for a custom `index.html`. Store the template in `template
</html>
```

<!-- {% raw %} -->

6. Update `tasks/main.yml` to deploy this `index.html` template:

```yaml
Expand Down
8 changes: 8 additions & 0 deletions exercises/ansible_rhel/1.8-troubleshoot/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ In this example, add debug tasks to your Apache role in the `tasks/main.yml` to

Insert debug tasks to display the values of variables or custom messages for troubleshooting:

<!-- {% raw %} -->

```yaml
- name: Display Variable Value
ansible.builtin.debug:
Expand All @@ -44,6 +46,8 @@ Insert debug tasks to display the values of variables or custom messages for tro
msg: "Apache service name is {{ apache_service_name }}"
```

<!-- {% raw %} -->

### Step 3 - Error Handling with Blocks

Ansible allows grouping tasks using `block` and handling errors with `rescue` sections, similar to try-catch in traditional programming.
Expand All @@ -54,6 +58,8 @@ In this example, add a block to handle potential errors during the Apache config

Wrap tasks that could potentially fail in a block and define a rescue section to handle errors:

<!-- {% raw %} -->

```yaml
- name: Apache Configuration with Potential Failure Point
block:
Expand All @@ -67,6 +73,8 @@ Wrap tasks that could potentially fail in a block and define a rescue section to
msg: "Missing Apache configuration file '{{ apache_conf_src }}'. Using default settings."
```

<!-- {% raw %} -->

2. Add an `apache_conf_src` variable within `vars/main.yml` of the apache role.

```yaml
Expand Down
4 changes: 2 additions & 2 deletions exercises/ansible_rhel/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ Having said that, the exercises themselves should take roughly 4-5 hours. The fi

## Section 2 - Ansible Automation Platform Exercises

* [Exercise 2.1 - Introduction to automation controller](2.1-intro)
* [Exercise 2.2 - Inventories, credentials and ad hoc commands](2.2-cred)
* [Exercise 2.1 - Introduction to Ansible automation controller](2.1-intro)
* [Exercise 2.2 - Inventories and Credentials in Ansible Automation Controller](2.2-cred)
* [Exercise 2.3 - Projects & job templates](2.3-projects)
* [Exercise 2.4 - Surveys](2.4-surveys)
* [Exercise 2.5 - Role based access control](2.5-rbac)
Expand Down