Add Puppet version check to start of role
This role relies heavily on Puppet 3 configuration paths. This patch helps get the current Puppet version which will make it easier to control behaviour based on the major version of Puppet. Change-Id: I17a8d06f842a870494bb986b8077fa6b4b4c2fc1
This commit is contained in:
parent
3fe078c070
commit
1d05ab4d23
|
@ -0,0 +1,51 @@
|
|||
#!/usr/bin/python
|
||||
|
||||
# Copyright (c) 2016 VEXXHOST, Inc.
|
||||
#
|
||||
# This module 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.
|
||||
#
|
||||
# This software 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 this software. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
DOCUMENTATION = '''
|
||||
---
|
||||
module: puppet_get_version
|
||||
short_description: Retrieve the current Puppet version
|
||||
description:
|
||||
- Retrieve the current Puppet version
|
||||
options: { }
|
||||
requirements: [ puppet ]
|
||||
author: Mohammed Naser
|
||||
'''
|
||||
|
||||
|
||||
def main():
|
||||
module = AnsibleModule(argument_spec={})
|
||||
|
||||
global PUPPET_CMD
|
||||
PUPPET_CMD = module.get_bin_path("puppet", False, ['/opt/puppetlabs/bin'])
|
||||
|
||||
if not PUPPET_CMD:
|
||||
module.fail_json(
|
||||
msg="Could not find puppet. Please ensure it is installed.")
|
||||
|
||||
# Check puppet version
|
||||
rc, stdout, stderr = module.run_command(PUPPET_CMD + " --version")
|
||||
version = stdout.strip()
|
||||
major, minor, patch = version.split('.')
|
||||
module.exit_json(full=version, major=int(major), minor=int(minor),
|
||||
patch=int(patch))
|
||||
|
||||
# import module snippets
|
||||
from ansible.module_utils.basic import *
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
|
@ -1,4 +1,8 @@
|
|||
---
|
||||
- name: check puppet version
|
||||
puppet_get_version:
|
||||
register: puppet_version
|
||||
|
||||
- block:
|
||||
- name: ensure hiera directory
|
||||
file:
|
||||
|
|
Loading…
Reference in New Issue