ansible-module

Example:

# Run the 'debug' module.
- ansible-module:
    module_vars:
      var: ansible_env.USER

Description

This is a generic task to execute any of the officially supported, available Ansible modules.

Currently only a few basic metadata keys are supported: become &become_user. The other ones will be added shortly.

Variables

Name Type Default Description

name

string --

The module name. Required

become

boolean --

Whether to become another user.

become_user

string --

The user to become.

module_vars

dict ordereddict()

The parameters for the module.

Examples

Example 1

Run the 'debug' module.

Code
- ansible-module:
    module_vars:
      var: ansible_env.USER
Description

Executes the Ansible debug module, to print an (Ansible-internal) variable value, in this case the username that runs the current playbook. This is useful for debugging.

Code

doc:
  short_help: Execute an arbitrary Ansible module.
  help: |
    This is a generic task to execute any of the officially supported, [available Ansible modules](https://docs.ansible.com/ansible/latest/modules/list_of_all_modules.html).

    Currently only a few basic metadata keys are supported: ``become`` &``become_user``. The other ones will be added
    shortly.
  examples:
  - title: Run the 'debug' module.
    desc: |
      Executes the Ansible [debug](https://docs.ansible.com/ansible/latest/modules/debug_module.html) module, to print an (Ansible-internal) variable value, in this case the username that runs the current playbook. This is useful for debugging.
    vars:
      module_vars:
        var: ansible_env.USER
args:
  name:
    doc:
      short_help: The module name.
    type: string
    required: true
    cli:
      param_type: argument
  become:
    doc:
      short_help: Whether to become another user.
    type: boolean
    required: false
  become_user:
    doc:
      short_help: The user to become.
    type: string
    empty: false
    required: false
  module_vars:
    doc:
      short_help: The parameters for the module.
    type: dict
    required: false
    empty: true
    default: {}
frecklets:
- frecklet:
    name: ansible-module
    type: ansible-meta
    properties:
      elevated: '{{:: become ::}}'
  task:
    become: '{{:: become ::}}'
    become_user: '{{:: become_user ::}}'
  vars:
    name: '{{:: name ::}}'
    become: '{{:: become ::}}'
    become_user: '{{:: become_user ::}}'
    vars: '{{:: module_vars ::}}'
frecklecute ansible-module --help

Usage: frecklecute ansible-module [OPTIONS] NAME

  This is a generic task to execute any of the officially supported,
  [available Ansible modules](https://docs.ansible.com/ansible/latest/module
  s/list_of_all_modules.html).

  Currently only a few basic metadata keys are supported: ``become``
  &``become_user``. The other ones will be added shortly.

Options:
  --become / --no-become     Whether to become another user.
  --become-user BECOME_USER  The user to become.
  --module-vars MODULE_VARS  The parameters for the module.
  --help                     Show this message and exit.
# -*- coding: utf-8 -*-


#
# module path: pycklets.ansible_module.AnsibleModule
#


from dataclasses import dataclass
from pyckles import AutoPycklet
from typing import *    # noqa

@dataclass
class AnsibleModule(AutoPycklet):
    """This is a generic task to execute any of the officially supported, [available Ansible modules](https://docs.ansible.com/ansible/latest/modules/list_of_all_modules.html).

     Currently only a few basic metadata keys are supported: ``become`` &``become_user``. The other ones will be added
     shortly.

       Args:
         become: Whether to become another user.
         become_user: The user to become.
         module_vars: The parameters for the module.
         name: The module name.

    """

    FRECKLET_ID = "ansible-module"

    become: bool = None
    become_user: str = None
    module_vars: Dict = None
    name: str = None


    def __post_init__(self):
        super(AnsibleModule, self).__init__(var_names=["become", "become_user", "module_vars", "name"])


frecklet_class = AnsibleModule
# -*- coding: utf-8 -*-


#
# module path: pycklets.ansible_module.AnsibleModule
#


from pyckles import AutoPycklet

class AnsibleModule(AutoPycklet):
    """This is a generic task to execute any of the officially supported, [available Ansible modules](https://docs.ansible.com/ansible/latest/modules/list_of_all_modules.html).

     Currently only a few basic metadata keys are supported: ``become`` &``become_user``. The other ones will be added
     shortly.

       Args:
         become: Whether to become another user.
         become_user: The user to become.
         module_vars: The parameters for the module.
         name: The module name.

    """

    FRECKLET_ID = "ansible-module"

    def __init__(self, become=None, become_user=None, module_vars=None, name=None):

        super(AnsibleModule, self).__init__(var_names=["become", "become_user", "module_vars", "name"])
        self._become = become
        self._become_user = become_user
        self._module_vars = module_vars
        self._name = name

    @property
    def become(self):
        return self._become

    @become.setter
    def become(self, become):
        self._become = become

    @property
    def become_user(self):
        return self._become_user

    @become_user.setter
    def become_user(self, become_user):
        self._become_user = become_user

    @property
    def module_vars(self):
        return self._module_vars

    @module_vars.setter
    def module_vars(self, module_vars):
        self._module_vars = module_vars

    @property
    def name(self):
        return self._name

    @name.setter
    def name(self, name):
        self._name = name



frecklet_class = AnsibleModule