From 6e8b300a5e9151183b1a55af97d186d6c3350d04 Mon Sep 17 00:00:00 2001 From: Eamonn Travers Date: Wed, 17 Jun 2020 14:20:12 +0200 Subject: [PATCH] Add task solutions --- grep.yml | 14 ++++++++++++++ loop_include.yml | 9 +++++++++ loop_include_sub.yml | 8 ++++++++ 3 files changed, 31 insertions(+) create mode 100644 grep.yml create mode 100644 loop_include.yml create mode 100644 loop_include_sub.yml diff --git a/grep.yml b/grep.yml new file mode 100644 index 0000000..8495fb1 --- /dev/null +++ b/grep.yml @@ -0,0 +1,14 @@ +--- +- hosts: localhost + tasks: + - command: "grep {{ username }} /etc/passwd" + register: result + ignore_errors: True + + - debug: + msg: '{{ username }} exists' + when: result is success + + - debug: + msg: '{{ username }} does not exist' + when: result is failed diff --git a/loop_include.yml b/loop_include.yml new file mode 100644 index 0000000..1e5c159 --- /dev/null +++ b/loop_include.yml @@ -0,0 +1,9 @@ +--- +- hosts: localhost + tasks: + - include: loop_include_sub.yml + loop: + - A + - B + loop_control: + loop_var: outer diff --git a/loop_include_sub.yml b/loop_include_sub.yml new file mode 100644 index 0000000..bdc45c9 --- /dev/null +++ b/loop_include_sub.yml @@ -0,0 +1,8 @@ +--- +- debug: "msg='{{ my_idx }} Innen: {{ item }}, Außen: {{ outer }}'" + loop: + - 1 + - 2 + loop_control: + index_var: my_idx + label: "Testytest"