ansible-role

Example:

# Run the [geerlingguy.docker](https://github.com/geerlingguy/ansible-role-docker) role.
- ansible-role:
    name: geerlingguy.docker
    role_vars:
      docker_edition: ce
      docker_install_compose: false
      docker_users:
      - admin
      - freckles

Description

This is a generic task to execute any of the Ansible roles that are hosted on Ansible galaxy.

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

Be aware, if the role is not in the default or community resources repository, this will only work if 'allow_remote' or 'allow_remote_roles' is set to true in the context that is used.

Variables

Name Type Default Description

name

string --

The role name. Required

become

boolean --

Whether to become another user.

become_user

string --

The user to become.

include_type

string include

n/a

role_vars

dict ordereddict()

The parameters for the role.

Examples

Example 1

Run the geerlingguy.docker role.

Code
- ansible-role:
    name: geerlingguy.docker
    role_vars:
      docker_edition: ce
      docker_install_compose: false
      docker_users:
      - admin
      - freckles
Description

Runs the geerlingguy.docker role, setting a few variables which are documented in that roles README.md.

Note, any users specified in the 'docker_users' var won't be created automatically, as would be the case with the 'docker-service' frecklet (which, by the way, uses that same role under the hood).

Code

doc:
  short_help: Execute an arbitrary role from Ansible Galaxy.
  help: |
    This is a generic task to execute any of the Ansible roles that are hosted on [Ansible galaxy](https://galaxy.ansible.com).

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

    Be aware, if the role is not in the default or community resources repository, this will only work if 'allow_remote' or 'allow_remote_roles' is set to true in the context that is used.
  examples:
  - title: Run the [geerlingguy.docker](https://github.com/geerlingguy/ansible-role-docker)
      role.
    desc: |
      Runs the [geerlingguy.docker](https://github.com/geerlingguy/ansible-role-docker) role, setting a few variables which are documented in that [roles README.md](https://github.com/geerlingguy/ansible-role-docker/blob/master/README.md).

      Note, any users specified in the 'docker_users' var won't be created automatically, as would be the case with the '[docker-service](frecklet::docker-service)' frecklet (which, by the way, uses that same role under the hood).
    vars:
      name: geerlingguy.docker
      role_vars:
        docker_edition: ce
        docker_install_compose: false
        docker_users:
        - admin
        - freckles

args:
  name:
    doc:
      short_help: The role 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
  role_vars:
    doc:
      short_help: The parameters for the role.
    type: dict
    required: false
    empty: true
    default: {}
  include_type:
    doc:
      short_helop: Whether to 'include' or 'import' the role.
    type: string
    allowed:
    - include
    - import
    default: include

frecklets:
- frecklet:
    name: ansible-role
    type: ansible-meta
    properties:
      elevated: '{{:: become ::}}'
  task:
    become: '{{:: become ::}}'
    become_user: '{{:: become_user ::}}'
    include-type: '{{:: include_type ::}}'
  vars:
    name: '{{:: name ::}}'
    become: '{{:: become ::}}'
    become_user: '{{:: become_user ::}}'
    vars: '{{:: role_vars ::}}'
frecklecute ansible-role --help

Usage: frecklecute ansible-role [OPTIONS] NAME

  This is a generic task to execute any of the Ansible roles that are hosted
  on [Ansible galaxy](https://galaxy.ansible.com).

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

  Be aware, if the role is not in the default or community resources
  repository, this will only work if 'allow_remote' or 'allow_remote_roles'
  is set to true in the context that is used.

Options:
  --become / --no-become       Whether to become another user.
  --become-user BECOME_USER    The user to become.
  --include-type INCLUDE_TYPE  n/a
  --role-vars ROLE_VARS        The parameters for the role.
  --help                       Show this message and exit.
# -*- coding: utf-8 -*-


#
# module path: pycklets.ansible_role.AnsibleRole
#


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

@dataclass
class AnsibleRole(AutoPycklet):
    """This is a generic task to execute any of the Ansible roles that are hosted on [Ansible galaxy](https://galaxy.ansible.com).

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

     Be aware, if the role is not in the default or community resources repository, this will only work if 'allow_remote' or 'allow_remote_roles' is set to true in the context that is used.

       Args:
         become: Whether to become another user.
         become_user: The user to become.
         include_type: n/a
         name: The role name.
         role_vars: The parameters for the role.

    """

    FRECKLET_ID = "ansible-role"

    become: bool = None
    become_user: str = None
    include_type: str = None
    name: str = None
    role_vars: Dict = None


    def __post_init__(self):
        super(AnsibleRole, self).__init__(var_names=["become", "become_user", "include_type", "name", "role_vars"])


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


#
# module path: pycklets.ansible_role.AnsibleRole
#


from pyckles import AutoPycklet

class AnsibleRole(AutoPycklet):
    """This is a generic task to execute any of the Ansible roles that are hosted on [Ansible galaxy](https://galaxy.ansible.com).

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

     Be aware, if the role is not in the default or community resources repository, this will only work if 'allow_remote' or 'allow_remote_roles' is set to true in the context that is used.

       Args:
         become: Whether to become another user.
         become_user: The user to become.
         include_type: n/a
         name: The role name.
         role_vars: The parameters for the role.

    """

    FRECKLET_ID = "ansible-role"

    def __init__(self, become=None, become_user=None, include_type="include", name=None, role_vars=None):

        super(AnsibleRole, self).__init__(var_names=["become", "become_user", "include_type", "name", "role_vars"])
        self._become = become
        self._become_user = become_user
        self._include_type = include_type
        self._name = name
        self._role_vars = role_vars

    @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 include_type(self):
        return self._include_type

    @include_type.setter
    def include_type(self, include_type):
        self._include_type = include_type

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

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

    @property
    def role_vars(self):
        return self._role_vars

    @role_vars.setter
    def role_vars(self, role_vars):
        self._role_vars = role_vars



frecklet_class = AnsibleRole