From 9bf14931c4f3bd009e42c1b1080ba6b1b0c9a161 Mon Sep 17 00:00:00 2001 From: Cedric Girard Date: Mon, 30 Jul 2018 13:42:10 +0200 Subject: [PATCH] First exercise --- 10.Run_Playbook/10.Run_Playbook.md | 23 +++++++++++++++++++++++ 10.Run_Playbook/ping.yml | 10 ++++++++++ README.md | 9 ++++++++- hosts | 15 +++++++++++++++ 4 files changed, 56 insertions(+), 1 deletion(-) create mode 100644 10.Run_Playbook/10.Run_Playbook.md create mode 100644 10.Run_Playbook/ping.yml create mode 100644 hosts diff --git a/10.Run_Playbook/10.Run_Playbook.md b/10.Run_Playbook/10.Run_Playbook.md new file mode 100644 index 0000000..a38e078 --- /dev/null +++ b/10.Run_Playbook/10.Run_Playbook.md @@ -0,0 +1,23 @@ +# 10 - Run Playbook + +This exercise introduces you to running playbook. The playbook is already written. + +## Visualize the playbook + +The playbook is named `ping.yml`. Open it with your favorite editor. + +## Run the playbook + +Run the playbook with the inventory file adapted to your lab setup: +```bash +ansible-playbook -i ../hosts ping.yml +``` + +## Pass args on the command line + +Now change the value of the `ping` output with overwriting the `ping_output` vars. + +```bash +ansible-playbook -v -i ../hosts ping.yml -e "ping_output=Ansible is great" +``` + diff --git a/10.Run_Playbook/ping.yml b/10.Run_Playbook/ping.yml new file mode 100644 index 0000000..c4c4542 --- /dev/null +++ b/10.Run_Playbook/ping.yml @@ -0,0 +1,10 @@ +- hosts: lab + gather_facts: no + vars: + - ping_output: pong + tasks: + - name: Test if Ansible works on host + ping: + data: "{{ ping_output }}" + +# vim: set ft=yaml sw=2 et: diff --git a/README.md b/README.md index d22771e..f21f761 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,9 @@ -# ansible-labs +# Ansible Labs + +This repository contains Ansible Labs used for training. + +## Setup +Install Ansible and clone this repo. Customize the `hosts` file to your lab setup. + + diff --git a/hosts b/hosts new file mode 100644 index 0000000..0d2c533 --- /dev/null +++ b/hosts @@ -0,0 +1,15 @@ +lab: + hosts: + vm1: + ansible_host: 192.168.122.110 + ansible_user: alpine + ansible_python_interpreter: python3 + vm2: + ansible_host: 192.168.122.111 + ansible_user: alpine + ansible_python_interpreter: python3 + vm3: + ansible_host: 192.168.122.112 + ansible_user: alpine + ansible_python_interpreter: python3 +# vim: set ft=yaml sw=2 et: