Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100755 43 lines (34 sloc) 1.312 kb
4578b17 @mpdehaan Add missing file (slurp) used by templates in non-playbook mode.
mpdehaan authored
1 #!/usr/bin/python
7e9e290 @mpdehaan Add encoding lines to python modules such that they can take unicode opt...
mpdehaan authored
2 # -*- coding: utf-8 -*-
4578b17 @mpdehaan Add missing file (slurp) used by templates in non-playbook mode.
mpdehaan authored
3
4 # (c) 2012, Michael DeHaan <michael.dehaan@gmail.com>
5 #
6 # This file is part of Ansible
7 #
8 # Ansible is free software: you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation, either version 3 of the License, or
11 # (at your option) any later version.
12 #
13 # Ansible is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
17 #
18 # You should have received a copy of the GNU General Public License
19 # along with Ansible. If not, see <http://www.gnu.org/licenses/>.
20
d69e70d @mpdehaan By defining a main function here, and including it ahead of the boilerpl...
mpdehaan authored
21 def main():
22 module = AnsibleModule(
23 argument_spec = dict(
24 src = dict(required=True),
25 )
9006d45 @mpdehaan Added code to allow insertion of boilerplate into modules to make them a...
mpdehaan authored
26 )
d69e70d @mpdehaan By defining a main function here, and including it ahead of the boilerpl...
mpdehaan authored
27 source = module.params['src']
28
29 if not os.path.exists(source):
30 module.fail_json(msg="file not found: %s" % source)
31 if not os.access(source, os.R_OK):
32 module.fail_json(msg="file is not readable: %s" % source)
4578b17 @mpdehaan Add missing file (slurp) used by templates in non-playbook mode.
mpdehaan authored
33
d69e70d @mpdehaan By defining a main function here, and including it ahead of the boilerpl...
mpdehaan authored
34 data = base64.b64encode(file(source).read())
4578b17 @mpdehaan Add missing file (slurp) used by templates in non-playbook mode.
mpdehaan authored
35
d69e70d @mpdehaan By defining a main function here, and including it ahead of the boilerpl...
mpdehaan authored
36 module.exit_json(content=data, encoding='base64')
37
38 # this is magic, see lib/ansible/module_common.py
39 #<<INCLUDE_ANSIBLE_MODULE_COMMON>>
4578b17 @mpdehaan Add missing file (slurp) used by templates in non-playbook mode.
mpdehaan authored
40
d69e70d @mpdehaan By defining a main function here, and including it ahead of the boilerpl...
mpdehaan authored
41 main()
4578b17 @mpdehaan Add missing file (slurp) used by templates in non-playbook mode.
mpdehaan authored
42
Something went wrong with that request. Please try again.