diff options
author | Toshio Kuratomi <a.badger@gmail.com> | 2016-08-26 04:14:06 -0700 |
---|---|---|
committer | Ryan Brown <sb@ryansb.com> | 2016-08-26 07:14:06 -0400 |
commit | 6f1753cccd4574b26708ed87cc6422de5a4d58fa (patch) | |
tree | daedf8020dd2e64bb97521b5d13e7b3e1c69c6c5 /system | |
parent | f29efb56264a9ad95b97765e367ef5b7915ab877 (diff) | |
download | ansible-modules-extras-6f1753cccd4574b26708ed87cc6422de5a4d58fa.tar.gz |
Moved the atomic modules to cloud/atomic. (#2784)
Similar category to docker and lxd
Diffstat (limited to 'system')
-rw-r--r-- | system/atomic_host.py | 105 | ||||
-rw-r--r-- | system/atomic_image.py | 137 |
2 files changed, 0 insertions, 242 deletions
diff --git a/system/atomic_host.py b/system/atomic_host.py deleted file mode 100644 index dc098e67..00000000 --- a/system/atomic_host.py +++ /dev/null @@ -1,105 +0,0 @@ -#!/usr/bin/python -# -*- coding: utf-8 -*- - -# 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 licenses -# along with Ansible. If not, see <http://www.gnu.org/licenses/>. - -DOCUMENTATION=''' ---- -module: atomic_host -short_description: Manage the atomic host platform -description: - - Manage the atomic host platform - - Rebooting of Atomic host platform should be done outside this module -version_added: "2.2" -author: "Saravanan KR @krsacme" -notes: - - Host should be an atomic platform (verified by existence of '/run/ostree-booted' file) -requirements: - - atomic - - "python >= 2.6" -options: - revision: - description: - - The version number of the atomic host to be deployed. Providing ```latest``` will upgrade to the latest available version. - required: false - default: latest - aliases: ["version"] -''' - -EXAMPLES = ''' - -# Upgrade the atomic host platform to the latest version (atomic host upgrade) -- atomic_host: revision=latest - -# Deploy a specific revision as the atomic host (atomic host deploy 23.130) -- atomic_host: revision=23.130 - -''' - -RETURN = ''' -msg: - description: The command standard output - returned: always - type: string - sample: 'Already on latest' -''' - -def core(module): - revision = module.params['revision'] - args = [] - - module.run_command_environ_update = dict(LANG='C', LC_ALL='C', LC_MESSAGES='C') - - if revision == 'latest': - args = ['atomic', 'host', 'upgrade'] - else: - args = ['atomic', 'host', 'deploy', revision] - - out = {} - err = {} - rc = 0 - - rc, out, err = module.run_command(args, check_rc=False) - - if rc == 77 and revision == 'latest': - module.exit_json(msg="Already on latest", changed=False) - elif rc != 0: - module.fail_json(rc=rc, msg=err) - else: - module.exit_json(msg=out, changed=True) - - -def main(): - module = AnsibleModule( - argument_spec = dict( - revision = dict(default='latest', required=False, aliases=["version"]), - ), - ) - - # Verify that the platform is atomic host - if not os.path.exists("/run/ostree-booted"): - module.fail_json(msg="Module atomic_host is applicable for Atomic Host Platforms only") - - try: - core(module) - except Exception as e: - module.fail_json(msg=str(e)) - - -# import module snippets -from ansible.module_utils.basic import * -if __name__ == '__main__': - main() diff --git a/system/atomic_image.py b/system/atomic_image.py deleted file mode 100644 index cebd97a7..00000000 --- a/system/atomic_image.py +++ /dev/null @@ -1,137 +0,0 @@ -#!/usr/bin/python -# -*- coding: utf-8 -*- - -# 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/>. - -DOCUMENTATION=''' ---- -module: atomic_image -short_description: Manage the container images on the atomic host platform -description: - - Manage the container images on the atomic host platform - - Allows to execute the commands on the container images -version_added: "2.2" -author: "Saravanan KR @krsacme" -notes: - - Host should be support ```atomic``` command -requirements: - - atomic - - "python >= 2.6" -options: - name: - description: - - Name of the container image - required: True - default: null - state: - description: - - The state of the container image. - - The state ```latest``` will ensure container image is upgraded to the latest version and forcefully restart container, if running. - required: False - choices: ["present", "absent", "latest"] - default: latest - started: - description: - - Start or Stop the continer - required: False - choices: ["yes", "no"] - default: yes -''' - -EXAMPLES = ''' - -# Execute the run command on rsyslog container image (atomic run rhel7/rsyslog) -- atomic_image: name=rhel7/rsyslog state=latest - -''' - -RETURN = ''' -msg: - description: The command standard output - returned: always - type: string - sample: [u'Using default tag: latest ...'] -''' - -def do_upgrade(module, image): - args = ['atomic', 'update', '--force', image] - rc, out, err = module.run_command(args, check_rc=False) - if rc != 0: # something went wrong emit the msg - module.fail_json(rc=rc, msg=err) - elif 'Image is up to date' in out: - return False - - return True - - -def core(module): - image = module.params['name'] - state = module.params['state'] - started = module.params['started'] - is_upgraded = False - - module.run_command_environ_update = dict(LANG='C', LC_ALL='C', LC_MESSAGES='C') - - if state == 'present' or state == 'latest': - if state == 'latest': - is_upgraded = do_upgrade(module, image) - - if started: - args = ['atomic', 'run', image] - else: - args = ['atomic', 'install', image] - elif state == 'absent': - args = ['atomic', 'uninstall', image] - - out = {} - err = {} - rc = 0 - rc, out, err = module.run_command(args, check_rc=False) - - if rc < 0: - module.fail_json(rc=rc, msg=err) - elif rc == 1 and 'already present' in err: - module.exit_json(restult=err, changed=is_upgraded) - elif started and 'Container is running' in out: - module.exit_json(result=out, changed=is_upgraded) - else: - module.exit_json(msg=out, changed=True) - - -def main(): - module = AnsibleModule( - argument_spec = dict( - name = dict(default=None, required=True), - state = dict(default='latest', choices=['present', 'absent', 'latest']), - started = dict(default='yes', type='bool'), - ), - ) - - # Verify that the platform supports atomic command - rc, out, err = module.run_command('atomic -v', check_rc=False) - if rc != 0: - module.fail_json(msg="Error in running atomic command", err=err) - - try: - core(module) - except Exception as e: - module.fail_json(msg=str(e)) - - -# import module snippets -from ansible.module_utils.basic import * -if __name__ == '__main__': - main() |