Skip to content

Commit

Permalink
mega commit
Browse files Browse the repository at this point in the history
this commit
- adds remainder of spanish language links to all readmes for ansible_rhel workshop_type
- changes all curls from IP addresses to DNS
- adds solution for 1.7
  • Loading branch information
IPvSean committed May 14, 2020
1 parent 58bf3d8 commit ea680b6
Show file tree
Hide file tree
Showing 37 changed files with 157 additions and 55 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ ansible/
demos/servicenow/private.yml
*.html
!exercises/ansible_rhel/1.3-playbook/web.html
!exercises/ansible_rhel/1.7-role/roles/apache_vhost/files/web.html
!exercises/ansible_rhel/1.4-variables/files/dev_web.html
!exercises/ansible_rhel/1.4-variables/files/prod_web.html
demos/servicenow/closed_loop_incident_mgmt/input_vars.yaml
Expand Down
24 changes: 15 additions & 9 deletions exercises/ansible_rhel/1.4-variables/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,22 +135,28 @@ Create a new Playbook called `deploy_index_html.yml` in the `~/ansible-files/` d

## Step 4 - Test the Result

The Playbook should copy different files as index.html to the hosts, use `curl` to test it. Check the inventory again if you forgot the IP addresses of your nodes.
The Ansible Playbook copies different files as index.html to the hosts, use `curl` to test it.

```bash
[student<X>@ansible ansible-files]$ grep node ~/lab_inventory/hosts
node1 ansible_host=11.22.33.44
node2 ansible_host=22.33.44.55
node3 ansible_host=33.44.55.66
[student<X>@ansible ansible-files]$ curl http://11.22.33.44
For node1:
```
[student<X>@ansible ansible-files]$ curl http://node1
<body>
<h1>This is a development webserver, have fun!</h1>
</body>
[student1@ansible ansible-files]$ curl http://22.33.44.55
```

For node2:

```
[student1@ansible ansible-files]$ curl http://node2
<body>
<h1>This is a production webserver, take care!</h1>
</body>
[student1@ansible ansible-files]$ curl http://33.44.55.66
```

For node3:
```
[student1@ansible ansible-files]$ curl http://node3
<body>
<h1>This is a development webserver, have fun!</h1>
</body>
Expand Down
6 changes: 3 additions & 3 deletions exercises/ansible_rhel/1.5-handlers/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ So what’s new here?

Run the Playbook. We didn’t change anything in the file yet so there should not be any `changed` lines in the output and of course the handler shouldn’t have fired.

- Now change the `Listen 80` line in `/etc/httpd/conf/httpd.conf` to:
- Now change the `Listen 80` line in `~/ansible-files/files/httpd.conf` to:

```ini
Listen 8080
Expand All @@ -154,9 +154,9 @@ Listen 8080
Apache should now listen on port 8080. Easy enough to verify:

```bash
[student1@ansible ansible-files]$ curl http://22.33.44.55
[student1@ansible ansible-files]$ curl http://node1
curl: (7) Failed connect to 22.33.44.55:80; Connection refused
[student1@ansible ansible-files]$ curl http://22.33.44.55:8080
[student1@ansible ansible-files]$ curl http://node1:8080
<body>
<h1>This is a production webserver, take care!</h1>
</body>
Expand Down
2 changes: 1 addition & 1 deletion exercises/ansible_rhel/1.7-role/README.es.md
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ Ahora ya estás listo para ejecutar tu playbook:
Ejecute un comando curl contra `node2` para confirmar que el role funcionó:

```bash
[student<X>@ansible ansible-files]$ curl -s http://22.33.44.55:8080
[student<X>@ansible ansible-files]$ curl -s http://node2:8080
simple vhost index
```

Expand Down
2 changes: 1 addition & 1 deletion exercises/ansible_rhel/1.7-role/README.fr.md
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ Vous êtes maintenant prêt à exécuter votre playbook:
Exécutez une commande curl contre `node2` pour confirmer que le rôle a fonctionné:

```bash
[student<X>@ansible ansible-files]$ curl -s http://22.33.44.55:8080
[student<X>@ansible ansible-files]$ curl -s http://node2:8080
simple vhost index
```

Expand Down
2 changes: 1 addition & 1 deletion exercises/ansible_rhel/1.7-role/README.ja.md
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ Playbook を実行する準備が整いましたので、実行してみまし
`node2` に対して curl コマンドを実行して、 Roles が機能していることを確認します。バーチャルホストのポートは8080です。

```bash
[student<X>@ansible ansible-files]$ curl -s http://<node2>:8080
[student<X>@ansible ansible-files]$ curl -s http://node2:8080
simple vhost index
```

Expand Down
43 changes: 32 additions & 11 deletions exercises/ansible_rhel/1.7-role/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ This exercise will cover:

## Step 1 - Understanding the Ansible Role Structure

Roles are basically automation built around *include* directives and really don’t contain much additional magic beyond some improvements to search path handling for referenced files.

Roles follow a defined directory structure; a role is named by the top level directory. Some of the subdirectories contain YAML files, named `main.yml`. The files and templates subdirectories can contain objects referenced by the YAML files.

An example project structure could look like this, the name of the role would be "apache":
Expand Down Expand Up @@ -96,6 +94,27 @@ Have a look at the role directories and their content:
[student<X>@ansible ansible-files]$ tree roles
```

```
roles/
└── apache_vhost
├── defaults
│   └── main.yml
├── files
├── handlers
│   └── main.yml
├── meta
│   └── main.yml
├── README.md
├── tasks
│   └── main.yml
├── templates
├── tests
│   ├── inventory
│   └── test.yml
└── vars
└── main.yml
```
## Step 3 - Create the Tasks File
The `main.yml` file in the tasks subdirectory of the role should do the following:
Expand All @@ -110,9 +129,9 @@ The `main.yml` file in the tasks subdirectory of the role should do the followin
> **WARNING**
>
> **The `main.yml` (and other files possibly included by main.yml) can only contain tasks, *not* complete Playbooks!**
> **The `main.yml` (and other files possibly included by main.yml) can only contain tasks, *not* complete playbooks!**
Change into the `roles/apache_vhost` directory. Edit the `tasks/main.yml` file:
Edit the `roles/apache_vhost/tasks/main.yml` file:
```yaml
---
Expand Down Expand Up @@ -193,7 +212,7 @@ The full `tasks/main.yml` file is:
- name: deliver html content
copy:
src: web.html
dest: "/var/www/vhosts/{{ ansible_hostname }}"
dest: "/var/www/vhosts/{{ ansible_hostname }}/index.html"
- name: template vhost file
template:
Expand All @@ -210,7 +229,7 @@ The full `tasks/main.yml` file is:

## Step 4 - Create the handler

Create the handler in the file `handlers/main.yml` to restart httpd when notified by the template task:
Create the handler in the file `roles/apache_vhost/handlers/main.yml` to restart httpd when notified by the template task:

```yaml
---
Expand All @@ -225,14 +244,16 @@ Create the handler in the file `handlers/main.yml` to restart httpd when notifie

Create the HTML content that will be served by the webserver.

- Create the `web.html` file in the "src" directory of the role, `files`:
- Create an web.html file in the "src" directory of the role, `files`:

```bash
[student<X>@ansible ansible-files]$ echo 'simple vhost index' > ~/ansible-files/roles/apache_vhost/files/web.html
```
$ echo 'simple vhost index' > ~/ansible-files/roles/apache_vhost/files/web.html
```
- Create the `vhost.conf.j2` template file in the role's `templates` subdirectory.
`$ cat roles/apache_vhost/templates/vhost.conf.j2`
<!-- {% raw %} -->
```
# {{ ansible_managed }}
Expand Down Expand Up @@ -286,11 +307,11 @@ Now you are ready to run your playbook:
Run a curl command against `node2` to confirm that the role worked:

```bash
[student<X>@ansible ansible-files]$ curl -s http://22.33.44.55:8080
[student<X>@ansible ansible-files]$ curl -s http://node2:8080
simple vhost index
```

All looking good? Congratulations! You have successfully completed the Ansible Engine Workshop Exercises!
Congratulations! You have successfully completed this exercise!

----
**Navigation**
Expand Down
2 changes: 1 addition & 1 deletion exercises/ansible_rhel/1.7-role/README.pt-br.md
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ Agora você está pronto para executar seu playbook:
Execute um comando curl no `node2` para confirmar que a role funcionou:

```bash
[student<X>@ansible ansible-files]$ curl -s http://22.33.44.55:8080
[student<X>@ansible ansible-files]$ curl -s http://node2:8080
vhost index
```

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
simple vhost index
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
# handlers file for roles/apache_vhost
- name: restart_httpd
service:
name: httpd
state: restarted
32 changes: 32 additions & 0 deletions exercises/ansible_rhel/1.7-role/roles/apache_vhost/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
---
# tasks file for roles/apache_vhost
- name: install httpd
yum:
name: httpd
state: latest

- name: start and enable httpd service
service:
name: httpd
state: started
enabled: true

- name: ensure vhost directory is present
file:
path: "/var/www/vhosts/{{ ansible_hostname }}"
state: directory

- name: deliver html content
copy:
src: web.html
dest: "/var/www/vhosts/{{ ansible_hostname }}/index.html"

- name: template vhost file
template:
src: vhost.conf.j2
dest: /etc/httpd/conf.d/vhost.conf
owner: root
group: root
mode: 0644
notify:
- restart_httpd
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# {{ ansible_managed }}

<VirtualHost *:8080>
ServerAdmin webmaster@{{ ansible_fqdn }}
ServerName {{ ansible_fqdn }}
ErrorLog logs/{{ ansible_hostname }}-error.log
CustomLog logs/{{ ansible_hostname }}-common.log common
DocumentRoot /var/www/vhosts/{{ ansible_hostname }}/

<Directory /var/www/vhosts/{{ ansible_hostname }}/>
Options +Indexes +FollowSymlinks +Includes
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
15 changes: 15 additions & 0 deletions exercises/ansible_rhel/1.7-role/test_apache_role.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
- name: use apache_vhost role playbook
hosts: node2
become: yes

pre_tasks:
- debug:
msg: 'Beginning web server configuration.'

roles:
- apache_vhost

post_tasks:
- debug:
msg: 'Web server has been configured.'
4 changes: 2 additions & 2 deletions exercises/ansible_rhel/2.3-projects/README.es.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Workshop - Proyectos y plantillas de trabajo

**Lee esto en otros idiomas***:
<br>![uk](../../../images/uk.png) [English](README.md), ![japan](../../../images/japan.png)[日本語](README.ja.md), ![brazil](../../../images/brazil.png) [Portugues do Brasil](README.pt-br.md), ![france](../../../images/fr.png)[Française](README.fr.md),![Español](../../../images/col.png)[Español](README.es.md)
<br>![uk](../../../images/uk.png) [English](README.md), ![japan](../../../images/japan.png)[日本語](README.ja.md), ![brazil](../../../images/brazil.png) [Portugues do Brasil](README.pt-br.md), ![france](../../../images/fr.png) [Française](README.fr.md), ![Español](../../../images/col.png) [Español](README.es.md).

## Tabla de contenidos

Expand Down Expand Up @@ -77,7 +77,7 @@ Para configurar y utilizar este repositorio como un **Sistema de Control de Cód
## Crear el proyecto

- Ir a **RESOURCES → Projects** en la vista de menú lateral haga clic en el botón verde **+**. Rellene el formulario

<table>
<tr>
<th>Parámetro</th>
Expand Down
3 changes: 2 additions & 1 deletion exercises/ansible_rhel/2.3-projects/README.fr.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#Atelier - Les projets & modèles

**Lisez ceci dans d'autres langues**: <br>![uk](../../../images/uk.png) [English](README.md), ![japan](../../../images/japan.png)[日本語](README.ja.md), ![brazil](../../../images/brazil.png) [Portugues do Brasil](README.pt-br.md), ![france](../../../images/fr.png)[Française](README.fr.md).
**Lisez ceci dans d'autres langues**:
<br>![uk](../../../images/uk.png) [English](README.md), ![japan](../../../images/japan.png)[日本語](README.ja.md), ![brazil](../../../images/brazil.png) [Portugues do Brasil](README.pt-br.md), ![france](../../../images/fr.png) [Française](README.fr.md), ![Español](../../../images/col.png) [Español](README.es.md).

## Table des matières

Expand Down
3 changes: 2 additions & 1 deletion exercises/ansible_rhel/2.3-projects/README.ja.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# 演習 - プロジェクトとジョブテンプレート

**Read this in other languages**:
<br>![uk](../../../images/uk.png) [English](README.md), ![japan](../../../images/japan.png)[日本語](README.ja.md), ![brazil](../../../images/brazil.png) [Portugues do Brasil](README.pt-br.md), ![france](../../../images/fr.png)[Française](README.fr.md).
<br>![uk](../../../images/uk.png) [English](README.md), ![japan](../../../images/japan.png)[日本語](README.ja.md), ![brazil](../../../images/brazil.png) [Portugues do Brasil](README.pt-br.md), ![france](../../../images/fr.png) [Française](README.fr.md), ![Español](../../../images/col.png) [Español](README.es.md).


* [Git リポジトリのセットアップ](#git-リポジトリのセットアップ)
* [プロジェクトの作成](#プロジェクトの作成)
Expand Down
2 changes: 1 addition & 1 deletion exercises/ansible_rhel/2.3-projects/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Workshop Exercise - Projects & job templates

**Read this in other languages**:
<br>![uk](../../../images/uk.png) [English](README.md), ![japan](../../../images/japan.png)[日本語](README.ja.md), ![brazil](../../../images/brazil.png) [Portugues do Brasil](README.pt-br.md), ![france](../../../images/fr.png) [Française](README.fr.md),![Español](../../../images/col.png) [Español](README.es.md).
<br>![uk](../../../images/uk.png) [English](README.md), ![japan](../../../images/japan.png)[日本語](README.ja.md), ![brazil](../../../images/brazil.png) [Portugues do Brasil](README.pt-br.md), ![france](../../../images/fr.png) [Française](README.fr.md), ![Español](../../../images/col.png) [Español](README.es.md).

## Table Contents

Expand Down
2 changes: 1 addition & 1 deletion exercises/ansible_rhel/2.3-projects/README.pt-br.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Exercício - Projects & job templates

**Leia em outras linguagens**:
<br>![uk](../../../images/uk.png) [English](README.md), ![japan](../../../images/japan.png)[日本語](README.ja.md), ![brazil](../../../images/brazil.png) [Portugues do Brasil](README.pt-br.md), ![france](../../../images/fr.png)[Française](README.fr.md).
<br>![uk](../../../images/uk.png) [English](README.md), ![japan](../../../images/japan.png)[日本語](README.ja.md), ![brazil](../../../images/brazil.png) [Portugues do Brasil](README.pt-br.md), ![france](../../../images/fr.png) [Française](README.fr.md), ![Español](../../../images/col.png) [Español](README.es.md).

* [Configurando o repositório Git](#configurando-o-repositório-git)
* [Criando o projeto](#criando-o-projeto)
Expand Down
2 changes: 1 addition & 1 deletion exercises/ansible_rhel/2.4-surveys/README.es.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Workshop - Encuestas

**Lee esto en otros idiomas**:
<br>![uk](../../../images/uk.png) [English](README.md), ![japan](../../../images/japan.png)[日本語](README.ja.md), ![brazil](../../../images/brazil.png) [Portugues do Brasil](README.pt-br.md), ![france](../../../images/fr.png)[Française](README.fr.md),![Español](../../../images/col.png)[Español](README.es.md)
<br>![uk](../../../images/uk.png) [English](README.md), ![japan](../../../images/japan.png)[日本語](README.ja.md), ![brazil](../../../images/brazil.png) [Portugues do Brasil](README.pt-br.md), ![france](../../../images/fr.png) [Française](README.fr.md), ![Español](../../../images/col.png) [Español](README.es.md).

## Tabla de contenidos

Expand Down
3 changes: 2 additions & 1 deletion exercises/ansible_rhel/2.4-surveys/README.fr.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Atelier - Les questionnaires

**Lisez ceci dans d'autres langues**: <br>![uk](../../../images/uk.png) [English](README.md), ![japan](../../../images/japan.png)[日本語](README.ja.md), ![brazil](../../../images/brazil.png) [Portugues do Brasil](README.pt-br.md), ![france](../../../images/fr.png)[Française](README.fr.md).
**Lisez ceci dans d'autres langues**:
<br>![uk](../../../images/uk.png) [English](README.md), ![japan](../../../images/japan.png)[日本語](README.ja.md), ![brazil](../../../images/brazil.png) [Portugues do Brasil](README.pt-br.md), ![france](../../../images/fr.png) [Française](README.fr.md), ![Español](../../../images/col.png) [Español](README.es.md).

## Table des matières

Expand Down
2 changes: 1 addition & 1 deletion exercises/ansible_rhel/2.4-surveys/README.ja.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# 演習 - Survey 機能

**Read this in other languages**:
<br>![uk](../../../images/uk.png) [English](README.md), ![japan](../../../images/japan.png)[日本語](README.ja.md), ![brazil](../../../images/brazil.png) [Portugues do Brasil](README.pt-br.md), ![france](../../../images/fr.png)[Française](README.fr.md).
<br>![uk](../../../images/uk.png) [English](README.md), ![japan](../../../images/japan.png)[日本語](README.ja.md), ![brazil](../../../images/brazil.png) [Portugues do Brasil](README.pt-br.md), ![france](../../../images/fr.png) [Française](README.fr.md), ![Español](../../../images/col.png) [Español](README.es.md).

* [プロジェクトを作成する](#プロジェクトを作成する)
* [Survey 付きのテンプレートを作成](#survey-付きのテンプレートを作成)
Expand Down
2 changes: 1 addition & 1 deletion exercises/ansible_rhel/2.4-surveys/README.pt-br.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Exercise - Surveys

**Leia em outras linguagens**:
<br>![uk](../../../images/uk.png) [English](README.md), ![japan](../../../images/japan.png)[日本語](README.ja.md), ![brazil](../../../images/brazil.png) [Portugues do Brasil](README.pt-br.md), ![france](../../../images/fr.png)[Française](README.fr.md).
<br>![uk](../../../images/uk.png) [English](README.md), ![japan](../../../images/japan.png)[日本語](README.ja.md), ![brazil](../../../images/brazil.png) [Portugues do Brasil](README.pt-br.md), ![france](../../../images/fr.png) [Française](README.fr.md), ![Español](../../../images/col.png) [Español](README.es.md).

* [Criando o projeto](#criando-o-projeto)
* [Criando um template com uma Survey](#criando-um-template-com-uma-survey)
Expand Down
4 changes: 2 additions & 2 deletions exercises/ansible_rhel/2.5-rbac/README.es.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Workshop - Control de acceso basado en roles

**Lee esto en otros idiomas**:
<br>![uk](../../../images/uk.png) [English](README.md), ![japan](../../../images/japan.png)[日本語](README.ja.md), ![brazil](../../../images/brazil.png) [Portugues do Brasil](README.pt-br.md), ![france](../../../images/fr.png)[Française](README.fr.md),![Español](../../../images/col.png)[Español](README.es.md).
<br>![uk](../../../images/uk.png) [English](README.md), ![japan](../../../images/japan.png)[日本語](README.ja.md), ![brazil](../../../images/brazil.png) [Portugues do Brasil](README.pt-br.md), ![france](../../../images/fr.png) [Française](README.fr.md), ![Español](../../../images/col.png) [Español](README.es.md).

## Tabla de contenidos:

Expand Down Expand Up @@ -146,7 +146,7 @@ Compruebe el resultado: ejecute `curl` de nuevo en el host de control para extra
$ curl http://22.33.44.55
```

Sólo recuerda lo que acabas de hacer: has habilitado a un usuario restringido para ejecutar un Playbook de Ansible
Sólo recuerda lo que acabas de hacer: has habilitado a un usuario restringido para ejecutar un Playbook de Ansible

- Sin tener acceso a las credenciales

Expand Down
2 changes: 1 addition & 1 deletion exercises/ansible_rhel/2.5-rbac/README.fr.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Atelier - Les contrôles d'accès

**Lisez ceci dans d'autres langues**:
<br>![uk](../../../images/uk.png) [English](README.md), ![japan](../../../images/japan.png)[日本語](README.ja.md), ![brazil](../../../images/brazil.png) [Portugues do Brasil](README.pt-br.md), ![france](../../../images/fr.png)[Française](README.fr.md).
<br>![uk](../../../images/uk.png) [English](README.md), ![japan](../../../images/japan.png)[日本語](README.ja.md), ![brazil](../../../images/brazil.png) [Portugues do Brasil](README.pt-br.md), ![france](../../../images/fr.png) [Française](README.fr.md), ![Español](../../../images/col.png) [Español](README.es.md).

## Table des matières

Expand Down
Loading

0 comments on commit ea680b6

Please sign in to comment.