diff --git a/08/grep_einfach.yml b/08/grep_einfach.yml new file mode 100644 index 0000000..eecc86f --- /dev/null +++ b/08/grep_einfach.yml @@ -0,0 +1,12 @@ +--- +- hosts: localhost + gather_facts: no + + tasks: + - name: grep aufrufen + command: grep root /etc/passwd + register: output + + - name: Rückgabe ausgeben + debug: var=output + diff --git a/08/grep_einfach_fehler.yml b/08/grep_einfach_fehler.yml new file mode 100644 index 0000000..50d5cbb --- /dev/null +++ b/08/grep_einfach_fehler.yml @@ -0,0 +1,13 @@ +--- +- hosts: localhost + gather_facts: no + + tasks: + - name: grep aufrufen + command: grep toor /etc/passwd + register: output + ignore_errors: true + + - name: Rückgabe ausgeben + debug: var=output + diff --git a/08/grep_username.yml b/08/grep_username.yml new file mode 100644 index 0000000..d09ba8e --- /dev/null +++ b/08/grep_username.yml @@ -0,0 +1,25 @@ +--- +- hosts: localhost + gather_facts: no + + tasks: + - name: Variable muss definiert sein + assert: + that: + - username is defined + + - name: Rufe grep auf + command: 'grep {{ username }} /etc/passwd' + register: result + ignore_errors: True + + - name: "{{ username }} existiert" + debug: + msg: '{{ username }} exists' + when: result is success + + - name: "{{ username }} existiert nicht" + debug: + msg: '{{ username }} does not exist' + when: result is failed + diff --git a/08/template-loop.yml b/08/template-loop.yml new file mode 100644 index 0000000..cd1bdce --- /dev/null +++ b/08/template-loop.yml @@ -0,0 +1,7 @@ +--- +- hosts: localhost + gather_facts: no + + roles: + - template-loop + diff --git a/08/var_definiert_oder_nicht.yml b/08/var_definiert_oder_nicht.yml new file mode 100644 index 0000000..e987797 --- /dev/null +++ b/08/var_definiert_oder_nicht.yml @@ -0,0 +1,18 @@ +--- +- hosts: localhost + gather_facts: no + + tasks: + - debug: + msg: "{{ inhalt }}" + when: inhalt|default(False) + + - debug: + msg: "Variable nicht definiert" + when: inhalt is not defined + + - debug: + msg: + - "inhalt|default(False) → {{ inhalt|default(False) }} → {{ inhalt|default(False)|bool }}" + - "inhalt is not defined → {{ inhalt is not defined }} → {{ inhalt is not defined|bool }}" + diff --git a/08/weiteres/debug1.yml b/08/weiteres/debug1.yml new file mode 100644 index 0000000..37cf14a --- /dev/null +++ b/08/weiteres/debug1.yml @@ -0,0 +1,13 @@ +--- +- hosts: localhost + + tasks: + - command: grep root /etc/passwd + register: output + + - debug: + var: output + + - debug: + var: output.stdout + diff --git a/08/weiteres/debug2.yml b/08/weiteres/debug2.yml new file mode 100644 index 0000000..bf77aed --- /dev/null +++ b/08/weiteres/debug2.yml @@ -0,0 +1,14 @@ +--- +- hosts: localhost + + tasks: + - command: grep toor /etc/passwd + register: output + ignore_errors: yes + + - debug: + var: output + + - debug: + var: output.stdout + diff --git a/08/weiteres/debug_folie.yml b/08/weiteres/debug_folie.yml new file mode 100644 index 0000000..80b55fc --- /dev/null +++ b/08/weiteres/debug_folie.yml @@ -0,0 +1,9 @@ +--- +- hosts: localhost + tasks: + - command: grep root2 /etc/passwd + register: output + ignore_errors: True + + - debug: var=output + diff --git a/08/weiteres/debug_zusammen.yml b/08/weiteres/debug_zusammen.yml new file mode 100644 index 0000000..44a92a2 --- /dev/null +++ b/08/weiteres/debug_zusammen.yml @@ -0,0 +1,18 @@ +--- +- hosts: localhost + + tasks: + - command: grep root /etc/passwd + register: abc1 + ignore_errors: yes + + - command: grep toor /etc/passwd + register: abc2 + ignore_errors: yes + + - debug: + msg: "{{ abc1.failed }} --- {{ abc2.failed }}" + + - debug: + msg: "{{ abc1 is failed }} --- {{ abc2 is failed }}" +