Skip to content

Commit

Permalink
Merge pull request #1 from jctanner/ADD_SIMPLE_MODULES
Browse files Browse the repository at this point in the history
Add simple modules
  • Loading branch information
Chris Houseknecht committed Sep 7, 2018
2 parents 75969ff + 2942dfa commit 436b376
Show file tree
Hide file tree
Showing 4 changed files with 126 additions and 0 deletions.
23 changes: 23 additions & 0 deletions module_utils/newutil.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#
# Copyright 2018 Red Hat | Ansible
#
# This file is part of Ansible
#
# Ansible is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Ansible is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.

from __future__ import absolute_import, division, print_function


def get_stuff():
return True
29 changes: 29 additions & 0 deletions modules/newmodule.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-

# Copyright: Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)

from __future__ import absolute_import, division, print_function
__metaclass__ = type

import json
import sys

from ansible.module_utils.newutil import get_stuff


def main():

res = {
'success': True,
'changed': True,
'lolcats': 50000,
'stuff': get_stuff()
}
print(json.dumps(res))
sys.exit(0)


if __name__ == "__main__":
main()
43 changes: 43 additions & 0 deletions plugins/filter/newfilter.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# (c) 2015, Filipe Niero Felisbino <filipenf@gmail.com>
#
# This file is part of Ansible
#
# Ansible is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Ansible is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.

from __future__ import (absolute_import, division, print_function)
__metaclass__ = type

from ansible.errors import AnsibleError, AnsibleFilterError

try:
import jmespath
HAS_LIB = True
except ImportError:
HAS_LIB = False


def newfilter(data):
'''Query data using jmespath query language ( http://jmespath.org ). Example:
- debug: msg="{{ instance | json_query(tagged_instances[*].block_device_mapping.*.volume_id') }}"
'''
return True


class FilterModule(object):
''' Query filter '''

def filters(self):
return {
'newfilter': newfilter
}
31 changes: 31 additions & 0 deletions plugins/lookup/newlookup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#
# Copyright 2018 Red Hat | Ansible
#
# This file is part of Ansible
#
# Ansible is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Ansible is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.

from __future__ import (absolute_import, division, print_function)

__metaclass__ = type


from ansible.plugins.lookup import LookupBase


class LookupModule(LookupBase):

def run(self, terms, variables=None, **kwargs):
#return KubernetesLookup().run(terms, variables=variables, **kwargs)
return ['a', 'b', 'c']

0 comments on commit 436b376

Please sign in to comment.