├── LICENSE ├── action_plugins ├── hello.py ├── inject.py ├── logtour.py ├── pipediff.py ├── run_once.py └── sillydiff.py ├── diff.yml └── library ├── hello ├── inject ├── logtour ├── pipediff ├── run_once └── sillydiff /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Location Labs 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /action_plugins/hello.py: -------------------------------------------------------------------------------- 1 | from ansible.runner.return_data import ReturnData 2 | 3 | 4 | class ActionModule(object): 5 | def __init__(self, runner): 6 | self.runner = runner 7 | 8 | def run(self, conn, tmp, module_name, module_args, inject, complex_args=None, **kwargs): 9 | return ReturnData(conn=conn, 10 | comm_ok=True, 11 | result=dict(failed=False, changed=False, msg="Hello World")) 12 | -------------------------------------------------------------------------------- /action_plugins/inject.py: -------------------------------------------------------------------------------- 1 | from ansible.runner.return_data import ReturnData 2 | 3 | 4 | class ActionModule(object): 5 | def __init__(self, runner): 6 | self.runner = runner 7 | 8 | def run(self, conn, tmp, module_name, module_args, inject, complex_args=None, **kwargs): 9 | result = {"failed": False, "changed": False} 10 | result.update(inject) 11 | return ReturnData(conn=conn, 12 | comm_ok=True, 13 | result=result) 14 | -------------------------------------------------------------------------------- /action_plugins/logtour.py: -------------------------------------------------------------------------------- 1 | from ansible.runner.return_data import ReturnData 2 | from ansible.callbacks import vv, vvv, vvvv 3 | from ansible.callbacks import verbose 4 | 5 | 6 | def vvvvv(msg, host=None): 7 | return verbose(msg, host=host, caplevel=4) 8 | 9 | 10 | class ActionModule(object): 11 | def __init__(self, runner): 12 | self.runner = runner 13 | 14 | def run(self, conn, tmp, module_name, module_args, inject, complex_args=None, **kwargs): 15 | vv("Kind of verbose") 16 | vvv("Verbose") 17 | vvvv("Lookout!") 18 | vvvvv("Super custom verbosity") 19 | return ReturnData(conn=conn, 20 | comm_ok=True, 21 | result={"failed": False, "changed": False}) 22 | -------------------------------------------------------------------------------- /action_plugins/pipediff.py: -------------------------------------------------------------------------------- 1 | from ansible.runner.return_data import ReturnData 2 | 3 | 4 | class ActionModule(object): 5 | def __init__(self, runner): 6 | self.runner = runner 7 | 8 | def run(self, conn, tmp, module_name, module_args, inject, complex_args=None, **kwargs): 9 | response = self.runner._execute_module(conn, 10 | tmp, 11 | "pipediff", 12 | module_args, 13 | inject=inject) 14 | before = response.result.pop('before', '') 15 | after = response.result.pop('after', '') 16 | return ReturnData(conn=conn, 17 | comm_ok=response.comm_ok, 18 | result=response.result, 19 | diff=dict(before=before, 20 | after=after)) 21 | -------------------------------------------------------------------------------- /action_plugins/run_once.py: -------------------------------------------------------------------------------- 1 | from ansible.runner.return_data import ReturnData 2 | 3 | 4 | class ActionModule(object): 5 | def __init__(self, runner): 6 | self.runner = runner 7 | self.runner.run_once = True 8 | 9 | def run(self, conn, tmp, module_name, module_args, inject, complex_args=None, **kwargs): 10 | return ReturnData(conn=conn, 11 | comm_ok=True, 12 | result=dict(failed=False, changed=False, msg="YOLO")) 13 | -------------------------------------------------------------------------------- /action_plugins/sillydiff.py: -------------------------------------------------------------------------------- 1 | from ansible.runner.return_data import ReturnData 2 | 3 | 4 | class ActionModule(object): 5 | def __init__(self, runner): 6 | self.runner = runner 7 | 8 | def run(self, conn, tmp, module_name, module_args, inject, complex_args=None, **kwargs): 9 | return ReturnData(conn=conn, 10 | comm_ok=True, 11 | result=dict(failed=False), 12 | diff=dict(before="foo\nbar", 13 | after="bar")) 14 | -------------------------------------------------------------------------------- /diff.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | # Run this to see diffs in action 4 | 5 | - hosts: all 6 | gather_facts: no 7 | tasks: 8 | - run_once: 9 | - sillydiff: 10 | - pipediff: 11 | -------------------------------------------------------------------------------- /library/hello: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/locationlabs/ansible-action-plugins/4fc4d371d985919aae8c34b947f3600f327640be/library/hello -------------------------------------------------------------------------------- /library/inject: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/locationlabs/ansible-action-plugins/4fc4d371d985919aae8c34b947f3600f327640be/library/inject -------------------------------------------------------------------------------- /library/logtour: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/locationlabs/ansible-action-plugins/4fc4d371d985919aae8c34b947f3600f327640be/library/logtour -------------------------------------------------------------------------------- /library/pipediff: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | print r'{"failed": false, "changed": true, "before": "fee\nfo\nfum\n", "after": "fee\nfi\nfum\n"}' 4 | -------------------------------------------------------------------------------- /library/run_once: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/locationlabs/ansible-action-plugins/4fc4d371d985919aae8c34b947f3600f327640be/library/run_once -------------------------------------------------------------------------------- /library/sillydiff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/locationlabs/ansible-action-plugins/4fc4d371d985919aae8c34b947f3600f327640be/library/sillydiff --------------------------------------------------------------------------------