Last active
September 19, 2016 20:17
-
-
Save steenzout/69647371458c7e15a775 to your computer and use it in GitHub Desktop.
Compilation of ansible tasks useful to setup testing.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- name: is X package installed? | |
command: dpkg-query -W -f='${Status}\n' X | |
register: test | |
changed_when: no | |
failed_when: test.stdout.find('install ok installed') == -1 | |
- name: file is present? | |
command: test -e path_to_file | |
changed_when: no | |
- name: file content contains X? | |
command: grep 'X' path_to_file | |
changed_when: no | |
- name: directory(ies) are present? | |
command: "test -d {{ item }}" | |
with_items: | |
- /home/ubuntu | |
changed_when: no | |
- name: file content contains line X? | |
command: grep '^X$' path_to_file | |
changed_when: no | |
- name: user(s) are present? | |
command: "getent passwd {{ item }}" | |
with_items: | |
- ubuntu | |
changed_when: no | |
- name: is command installed? | |
shell: which command | |
changed_when: no | |
- name: verify command version | |
shell: command --version | |
register: test | |
changed_when: no | |
failed_when: test is defined and test.stdout.find("command {{ command_version }} from") == -1 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment