Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[process_checker]: Add the process_checker playbook #349

Merged
merged 1 commit into from
Nov 17, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions ansible/roles/test/tasks/process_checker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Common process checker
#
# Parameters:
# process - the process to check
# running - yes/no (optional default:yes)
#
# Example:
# - include: process_checker.yml
# vars:
# process: {{ item }}
# with_items:
# - orchagent
# - portsyncd
# - intfsyncd
# - neighsyncd
# - routesyncd

- fail: msg="Please provide the process name"
when: process is not defined

# In Ansible the option line is always a string
- set_fact:
expect_rc={{ 0 if running is not defined or running == "yes" else 1 }}

- name: Check {{ process }} is running or not
shell: pidof {{ process }}
register: output
ignore_errors: yes

- name: Verify {{ process }} state is {{ "not running" if expect_rc else "running" }}
assert:
that:
- output.rc == {{ expect_rc | int }}