From 311411122bedd9cc616e99e77405611028a8efda Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Andr=C3=A9?= Date: Mon, 20 Feb 2017 16:54:06 -0500 Subject: [PATCH] Add a 'warn' ansible module This module simply adds the provided string to the `warnings` ansible output. Change-Id: Ia0046b284228a5da7257921bc5446266c4c3c0d8 --- .../add-warn-helper-a586ba13c7e8b43b.yaml | 5 +++ validations/library/warn.py | 32 +++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 releasenotes/notes/add-warn-helper-a586ba13c7e8b43b.yaml create mode 100644 validations/library/warn.py diff --git a/releasenotes/notes/add-warn-helper-a586ba13c7e8b43b.yaml b/releasenotes/notes/add-warn-helper-a586ba13c7e8b43b.yaml new file mode 100644 index 000000000..d7c2d53f4 --- /dev/null +++ b/releasenotes/notes/add-warn-helper-a586ba13c7e8b43b.yaml @@ -0,0 +1,5 @@ +--- +features: + - | + Add a new `warn` ansible module that simply adds a string to the 'warnings' + ansible output. diff --git a/validations/library/warn.py b/validations/library/warn.py new file mode 100644 index 000000000..d46952869 --- /dev/null +++ b/validations/library/warn.py @@ -0,0 +1,32 @@ +#!/usr/bin/env python +# Copyright 2017 Red Hat, Inc. +# All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +from ansible.module_utils.basic import * # noqa + + +def main(): + module = AnsibleModule(argument_spec=dict( + msg=dict(required=True, type='str'), + )) + + msg = module.params.get('msg') + + module.exit_json(changed=False, + warnings=[msg]) + + +if __name__ == '__main__': + main()