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"