From c23d0e6a8816f021d68c03fd8585865086e05ca5 Mon Sep 17 00:00:00 2001 From: Adam Miller Date: Apr 11 2017 16:09:27 +0000 Subject: add releng-shell role Signed-off-by: Adam Miller --- diff --git a/ansible/relengshelldemo.yml b/ansible/relengshelldemo.yml new file mode 100644 index 0000000..b09e35b --- /dev/null +++ b/ansible/relengshelldemo.yml @@ -0,0 +1,9 @@ +--- +- name: releng-shell demo + hosts: automator + roles: + - { + role: releng-shell, + shell_cmd: "echo true" + } + diff --git a/ansible/roles/releng-shell/.travis.yml b/ansible/roles/releng-shell/.travis.yml new file mode 100644 index 0000000..36bbf62 --- /dev/null +++ b/ansible/roles/releng-shell/.travis.yml @@ -0,0 +1,29 @@ +--- +language: python +python: "2.7" + +# Use the new container infrastructure +sudo: false + +# Install ansible +addons: + apt: + packages: + - python-pip + +install: + # Install ansible + - pip install ansible + + # Check ansible version + - ansible --version + + # Create ansible.cfg with correct roles_path + - printf '[defaults]\nroles_path=../' >ansible.cfg + +script: + # Basic role syntax check + - ansible-playbook tests/test.yml -i tests/inventory --syntax-check + +notifications: + webhooks: https://galaxy.ansible.com/api/v1/notifications/ \ No newline at end of file diff --git a/ansible/roles/releng-shell/README.md b/ansible/roles/releng-shell/README.md new file mode 100644 index 0000000..1e13d46 --- /dev/null +++ b/ansible/roles/releng-shell/README.md @@ -0,0 +1,28 @@ +releng-shell +============ + +This is a simple wrapper around the shell ansible module for error handling. + +Role Variables +-------------- + +`shell-cmd` - The shell command to pass to ansible's shell module + +Example Playbook +---------------- + +Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too: + + - hosts: servers + roles: + - { + role: releng-shell, + shell-cmd: "echo true" + } + + +License +------- + +MIT + diff --git a/ansible/roles/releng-shell/tasks/main.yml b/ansible/roles/releng-shell/tasks/main.yml new file mode 100644 index 0000000..03fe96f --- /dev/null +++ b/ansible/roles/releng-shell/tasks/main.yml @@ -0,0 +1,15 @@ +--- +# tasks file for releng-shell +# + +- name: Run releng-shell command via shell + shell: "{{ shell_cmd }}" + ignore_errors: True + changed_when: False + register: shell_result + +- debug: var=shell_result + +- name: Verify releng-shell command exit code + fail: msg="FAILURE - {{shell_result}}" + when: "shell_result.rc != 0"