package-installed

Example:

# Install the 'htop' package.
- package-installed:
    package: htop

Description

Install a single package, including the package manager that that was chosen, if necessary.

More information and examples to come, for now please refer to the freckfrackery.install-pkgs Ansible role for more information.

Variables

Name Type Default Description

package

['string', 'dict'] --

The package name. Required

become

boolean True

Whether to use root permissions to install the package.

no_pkg_mgr

boolean False

Don't try to install a necessary package manager.

Examples

Example 1

Install the 'htop' package.

Code
- package-installed:
    package: htop
Description

This uses the system package manager to install the 'htop' package. If the package is named differently on a platform, this won't work.

Example 2

Install the 'fortunes' package using the proper package name for a platform.

Code
- package-installed:
    package:
      name: fortune
      pkgs:
        debian: fortune-mod
        redhat: fortune
        darwin: fortune
Description

This uses the default system package manager to install the 'fortune' package. As the 'fortunes' package is named differently on different platforms, this is how to specify platform-dependent package names.

The 'name' property is not important here (except as a fall-back if so configured), but needs to be specified nonetheless.

Example 3

Install the 'fortune' package using a special package name for one platform.

Code
- package-installed:
    package:
      name: fortune
      pkgs:
        debian: fortune-mod
        default: fortune
Description

This is similar to the example above, except that we assume that the 'fortune' package name will always be 'fortune', except for the platforms we specify.

Example 4

Install the 'htop' package using the 'nix' package manager.

Code
- package-installed:
    package:
      name: htop
      pkg_mgr: nix
Description

This installs the 'nix' package manager itself if it isn't available yet.

Code

doc:
  short_help: Install a single packages.
  help: |
    Install a single package, including the package manager that that was chosen, if necessary.

    More information and examples to come, for now please refer to the [freckfrackery.install-pkgs Ansible role](https://gitlab.com/freckfrackery/freckfrackery.install-pkgs/blob/master/README.md) for more information.
  examples:
  - title: Install the 'htop' package.
    desc: |
      This uses the system package manager to install the 'htop' package. If the package is named differently on a platform, this won't work.
    vars:
      package: htop
  - title: Install the 'fortunes' package using the proper package name for a platform.
    desc: |
      This uses the default system package manager to install the 'fortune' package. As the ['fortunes'](https://en.wikipedia.org/wiki/Fortune_(Unix)) package is named differently on different platforms, this is how to specify platform-dependent package names.

      The 'name' property is not important here (except as a fall-back if so configured), but needs to be specified nonetheless.
    vars:
      package:
        name: fortune
        pkgs:
          debian: fortune-mod
          redhat: fortune
          darwin: fortune
  - title: Install the 'fortune' package using a special package name for one platform.
    desc: |
      This is similar to the example above, except that we assume that the 'fortune' package name will always be 'fortune', except for the platforms we specify.
    vars:
      package:
        name: fortune
        pkgs:
          debian: fortune-mod
          default: fortune
  - title: Install the 'htop' package using the 'nix' package manager.
    desc: |
      This installs the 'nix' package manager itself if it isn't available yet.
    vars:
      package:
        name: htop
        pkg_mgr: nix

args:
  package:
    doc:
      short_help: The package name.
    required: true
    type:
    - string
    - dict
    cli:
      param_type: argument
  no_pkg_mgr:
    required: false
    type: boolean
    cli:
      is_flag: true
    default: false
    doc:
      short_help: Don't try to install a necessary package manager.
  become:
    doc:
      short_help: Whether to use root permissions to install the package.
    type: boolean
    default: true
    required: false

meta:
  tags:
  - install
  - package-management
  - package-manager

frecklets:
- packages-installed:
    frecklet::desc:
      long: |
        Install the '{{:: package ::}}' package.

        # TODO details
    no_pkg_mgrs: '{{:: no_pkg_mgr ::}}'
    become: '{{:: become ::}}'
    packages:
    - '{{:: package ::}}'
frecklecute package-installed --help

Usage: frecklecute package-installed [OPTIONS] PACKAGE

  Install a single package, including the package manager that that was
  chosen, if necessary.

  More information and examples to come, for now please refer to the
  [freckfrackery.install-pkgs Ansible
  role](https://gitlab.com/freckfrackery/freckfrackery.install-
  pkgs/blob/master/README.md) for more information.

Options:
  --become / --no-become          Whether to use root permissions to install
                                  the package.
  --no-pkg-mgr / --no-no-pkg-mgr  Don't try to install a necessary package
                                  manager.
  --help                          Show this message and exit.
# -*- coding: utf-8 -*-


#
# module path: pycklets.package_installed.PackageInstalled
#


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

@dataclass
class PackageInstalled(AutoPycklet):
    """Install a single package, including the package manager that that was chosen, if necessary.

     More information and examples to come, for now please refer to the [freckfrackery.install-pkgs Ansible role](https://gitlab.com/freckfrackery/freckfrackery.install-pkgs/blob/master/README.md) for more information.

       Args:
         become: Whether to use root permissions to install the package.
         no_pkg_mgr: Don't try to install a necessary package manager.
         package: The package name.

    """

    FRECKLET_ID = "package-installed"

    become: bool = None
    no_pkg_mgr: bool = None
    package: Any = None


    def __post_init__(self):
        super(PackageInstalled, self).__init__(var_names=["become", "no_pkg_mgr", "package"])


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


#
# module path: pycklets.package_installed.PackageInstalled
#


from pyckles import AutoPycklet

class PackageInstalled(AutoPycklet):
    """Install a single package, including the package manager that that was chosen, if necessary.

     More information and examples to come, for now please refer to the [freckfrackery.install-pkgs Ansible role](https://gitlab.com/freckfrackery/freckfrackery.install-pkgs/blob/master/README.md) for more information.

       Args:
         become: Whether to use root permissions to install the package.
         no_pkg_mgr: Don't try to install a necessary package manager.
         package: The package name.

    """

    FRECKLET_ID = "package-installed"

    def __init__(self, become=True, no_pkg_mgr=None, package=None):

        super(PackageInstalled, self).__init__(var_names=["become", "no_pkg_mgr", "package"])
        self._become = become
        self._no_pkg_mgr = no_pkg_mgr
        self._package = package

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

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

    @property
    def no_pkg_mgr(self):
        return self._no_pkg_mgr

    @no_pkg_mgr.setter
    def no_pkg_mgr(self, no_pkg_mgr):
        self._no_pkg_mgr = no_pkg_mgr

    @property
    def package(self):
        return self._package

    @package.setter
    def package(self, package):
        self._package = package



frecklet_class = PackageInstalled