Skip to content

Commit

Permalink
ansible_rhel: Reformat md files for translation automation
Browse files Browse the repository at this point in the history
  • Loading branch information
Spredzy committed Jan 14, 2021
1 parent 1e706dc commit b61dd79
Show file tree
Hide file tree
Showing 15 changed files with 521 additions and 516 deletions.
54 changes: 30 additions & 24 deletions exercises/ansible_rhel/1.1-setup/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@
* [Step 2 - Working the Labs](#step-2---working-the-labs)
* [Step 3 - Challenge Labs](#step-3---challenge-labs)

# Objective
## Objective

- Understand the lab topology and how to access the environment.
- Understand how to work the workshop exercises
- Understand challenge labs
* Understand the lab topology and how to access the environment.
* Understand how to work the workshop exercises
* Understand challenge labs

# Guide
## Guide

## Your Lab Environment
### Your Lab Environment

In this lab you work in a pre-configured lab environment. You will have access to the following hosts:

Expand All @@ -31,68 +31,74 @@ In this lab you work in a pre-configured lab environment. You will have access t
| Managed Host 2 | node2 |
| Managed Host 3 | node3 |

## Step 1 - Access the Environment
### Step 1 - Access the Environment

Login to your control host via SSH:

> **Warning**
>
> Replace **11.22.33.44** by your **IP** provided to you, and the **X** in student**X** by the student number provided to you.
ssh [email protected]
```bash
ssh [email protected]
```

> **Tip**
>
> The password will be provided by your instructor
Then become root:

[student<X>@ansible ~]$ sudo -i
```bash
[student<X>@ansible ~]$ sudo -i
```

Most prerequisite tasks have already been done for you:

- Ansible software is installed

- SSH connection and keys are configured

- `sudo` has been configured on the managed hosts to run commands that require root privileges.
* Ansible software is installed
* SSH connection and keys are configured
* `sudo` has been configured on the managed hosts to run commands that require root privileges.

Check Ansible has been installed correctly

[root@ansible ~]# ansible --version
ansible 2.7.0
[...]
```bash
[root@ansible ~]# ansible --version
ansible 2.7.0
[...]
```

> **Note**
>
> Ansible is keeping configuration management simple. Ansible requires no database or running daemons and can run easily on a laptop. On the managed hosts it needs no running agent.
Log out of the root account again:

[root@ansible ~]# exit
logout
```bash
[root@ansible ~]# exit
logout
```

> **Note**
>
> In all subsequent exercises you should work as the student\<X\> user on the control node if not explicitly told differently.
## Step 2 - Working the Labs
### Step 2 - Working the Labs

You might have guessed by now this lab is pretty commandline-centric…​ :-)

- Don’t type everything manually, use copy & paste from the browser when appropriate. But stop to think and understand.
* Don’t type everything manually, use copy & paste from the browser when appropriate. But stop to think and understand.

- All labs were prepared using **Vim**, but we understand not everybody loves it. Feel free to use alternative editors. In the lab environment we provide **Midnight Commander** (just run **mc**, function keys can be reached via Esc-\<n\> or simply clicked with the mouse) or **Nano** (run **nano**). Here is a short [editor intro](../0.0-support-docs/editor_intro.md).
* All labs were prepared using **Vim**, but we understand not everybody loves it. Feel free to use alternative editors. In the lab environment we provide **Midnight Commander** (just run **mc**, function keys can be reached via Esc-\<n\> or simply clicked with the mouse) or **Nano** (run **nano**). Here is a short [editor intro](../0.0-support-docs/editor_intro.md).

> **Tip**
>
> In the lab guide commands you are supposed to run are shown with or without the expected output, whatever makes more sense in the context.
## Step 3 - Challenge Labs
### Step 3 - Challenge Labs

You will soon discover that many chapters in this lab guide come with a "Challenge Lab" section. These labs are meant to give you a small task to solve using what you have learned so far. The solution of the task is shown underneath a warning sign.

----
---
**Navigation**
<br>
[Next Exercise](../1.2-adhoc)
Expand Down
47 changes: 24 additions & 23 deletions exercises/ansible_rhel/1.2-adhoc/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,19 @@
* [Step 6 - The copy module and permissions](#step-6---the-copy-module-and-permissions)
* [Challenge Lab: Modules](#challenge-lab-modules)

# Objective
## Objective

For our first exercise, we are going to run some ad-hoc commands to help you get a feel for how Ansible works. Ansible Ad-Hoc commands enable you to perform tasks on remote nodes without having to write a playbook. They are very useful when you simply need to do one or two things quickly and often, to many remote nodes.

This exercise will cover
- Locating and understanding the Ansible configuration file (`ansible.cfg`)
- Locating and understanding an `ini` formatted inventory file
- Executing ad hoc commands

# Guide
* Locating and understanding the Ansible configuration file (`ansible.cfg`)
* Locating and understanding an `ini` formatted inventory file
* Executing ad hoc commands

## Step 1 - Work with your Inventory
## Guide

### Step 1 - Work with your Inventory

To use the ansible command for host management, you need to provide an inventory file which defines a list of hosts to be managed from the control node. In this lab the inventory is provided by your instructor. The inventory is an ini formatted file listing your hosts, sorted in groups, additionally providing some variables. It looks like:

Expand Down Expand Up @@ -72,7 +73,7 @@ As you see it is OK to put systems in more than one group. For instance, a serve
>
> The inventory can contain more data. E.g. if you have hosts that run on non-standard SSH ports you can put the port number after the hostname with a colon. Or you could define names specific to Ansible and have them point to the "real" IP or hostname.
## Step 2 - The Ansible Configuration Files
### Step 2 - The Ansible Configuration Files

The behavior of Ansible can be customized by modifying settings in Ansible’s ini-style configuration file. Ansible will select its configuration file from one of several possible locations on the control node, please refer to the [documentation](https://docs.ansible.com/ansible/latest/reference_appendices/config.html).

Expand Down Expand Up @@ -125,7 +126,7 @@ ansible ansible_host=44.55.66.77
>
> Note that each student has an individual lab environment. The IP addresses shown above are only an example and the IP addresses of your individual environments are different. As with the other cases, replace **\<X\>** with your actual student number.
## Step 3 - Ping a host
### Step 3 - Ping a host

> **Warning**
>
Expand Down Expand Up @@ -153,7 +154,7 @@ node2 | SUCCESS => {

As you see each node reports the successful execution and the actual result - here "pong".

## Step 4 - Listing Modules and Getting Help
### Step 4 - Listing Modules and Getting Help

Ansible comes with a lot of modules by default. To list all modules run:

Expand Down Expand Up @@ -181,7 +182,7 @@ Get help for a specific module including usage examples:
>
> Mandatory options are marked by a "=" in `ansible-doc`.
## Step 5 - Use the command module:
### Step 5 - Use the command module

Now let's see how we can run a good ol' fashioned Linux command and format the output using the `command` module. It simply executes the specified command on a managed host:

Expand All @@ -190,6 +191,7 @@ Now let's see how we can run a good ol' fashioned Linux command and format the o
node1 | CHANGED | rc=0 >>
uid=1001(student1) gid=1001(student1) Gruppen=1001(student1) Kontext=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023
```

In this case the module is called `command` and the option passed with `-a` is the actual command to run. Try to run this ad hoc command on all managed hosts using the `all` host pattern.

Another example: Have a quick look at the kernel versions your hosts are running:
Expand All @@ -208,7 +210,7 @@ Sometimes it’s desirable to have the output for a host on one line:
>
> Like many Linux commands, `ansible` allows for long-form options as well as short-form. For example `ansible web --module-name ping` is the same as running `ansible web -m ping`. We are going to be using the short-form options throughout this workshop.
## Step 6 - The copy module and permissions
### Step 6 - The copy module and permissions

Using the `copy` module, execute an ad hoc command on `node1` to change the contents of the `/etc/motd` file. **The content is handed to the module through an option in this case**.

Expand Down Expand Up @@ -245,7 +247,7 @@ For us it’s okay to connect as `student<X>` because `sudo` is set up. Change t

This time the command is a success:

```
```text
node1 | CHANGED => {
"changed": true,
"checksum": "4458b979ede3c332f8f2128385df4ba305e58c27",
Expand All @@ -272,23 +274,22 @@ Managed by Ansible

Run the `ansible node1 -m copy …​` command from above again. Note:

- The different output color (proper terminal config provided).
- The change from `"changed": true,` to `"changed": false,`.
- The first line says `SUCCESS` instead of `CHANGED`.
* The different output color (proper terminal config provided).
* The change from `"changed": true,` to `"changed": false,`.
* The first line says `SUCCESS` instead of `CHANGED`.

> **Tip**
>
> This makes it a lot easier to spot changes and what Ansible actually did.
## Challenge Lab: Modules
### Challenge Lab: Modules

- Using `ansible-doc`
* Using `ansible-doc`

- Find a module that uses Yum to manage software packages.
* Find a module that uses Yum to manage software packages.
* Look up the help examples for the module to learn how to install a package in the latest version.

- Look up the help examples for the module to learn how to install a package in the latest version.

- Run an Ansible ad hoc command to install the package "squid" in the latest version on `node1`.
* Run an Ansible ad hoc command to install the package "squid" in the latest version on `node1`.

> **Tip**
>
Expand All @@ -298,13 +299,13 @@ Run the `ansible node1 -m copy …​` command from above again. Note:
>
> **Solution below\!**
```
```bash
[student<X>@ansible ~]$ ansible-doc -l | grep -i yum
[student<X>@ansible ~]$ ansible-doc yum
[student<X>@ansible ~]$ ansible node1 -m yum -a 'name=squid state=latest' -b
```

----
---
**Navigation**
<br>
[Previous Exercise](../1.1-setup) - [Next Exercise](../1.3-playbook)
Expand Down
Loading

0 comments on commit b61dd79

Please sign in to comment.