First exercise
This commit is contained in:
parent
fb3f6e1a5b
commit
9bf14931c4
4 changed files with 56 additions and 1 deletions
23
10.Run_Playbook/10.Run_Playbook.md
Normal file
23
10.Run_Playbook/10.Run_Playbook.md
Normal file
|
@ -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"
|
||||
```
|
||||
|
10
10.Run_Playbook/ping.yml
Normal file
10
10.Run_Playbook/ping.yml
Normal file
|
@ -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:
|
|
@ -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.
|
||||
|
||||
|
||||
|
||||
|
|
15
hosts
Normal file
15
hosts
Normal file
|
@ -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:
|
Loading…
Reference in a new issue