apt-repository-added

Description

Ensures an apt repository is available and activated.

Variables

Name Type Default Description

repo_url

string --

The url of the apt repository. Required

codename

string --

Override the distribution codename to use for PPA repositories. Should usually only be set when working with a PPA on a non-Ubuntu target (e.g. Debian or Mint).

components

list --

List of components for this repo (e.g. ['main', 'non-free']

is_src_repo

boolean False

Whether the repository should be added into the sources list.

repo_alias

string --

When provided, the repo will be added in a separate file under '/etc/apt/sources.d', using the value of this argument as filename.

update_cache

boolean True

Run the equivalent of apt-get update when a change occurs. Cache updates are run after making changes.

Code

doc:
  short_help: Ensures an apt repository is available and activated.

args:
  repo_url:
    doc:
      short_help: The url of the apt repository.
    type: string
    required: true
    cli:
      param_type: argument
  update_cache:
    doc:
      short_help: Run the equivalent of apt-get update when a change occurs. Cache
        updates are run after making changes.
    type: boolean
    required: false
    default: true
  repo_alias:
    doc:
      short_help: When provided, the repo will be added in a separate file under '/etc/apt/sources.d',
        using the value of this argument as filename.
    type: string
    required: false
  codename:
    doc:
      short_help: Override the distribution codename to use for PPA repositories.
        Should usually only be set when working with a PPA on a non-Ubuntu target
        (e.g. Debian or Mint).
    type: string
    required: false
  components:
    doc:
      short_help: List of components for this repo (e.g. ['main', 'non-free']
    type: list
    schema:
      type: string
    required: false
  is_src_repo:
    doc:
      short_help: Whether the repository should be added into the sources list.
    type: boolean
    default: false
    required: false
    cli:
      param_decls:
      - --is-src-repo

frecklets:
- frecklet:
    name: apt_repository
    type: ansible-module
    properties:
      elevated: true
      idempotent: true
      internet: true
    desc:
      short: 'add apt repo: {{:: repo_url ::}}'
  task:
    become: true
  vars:
    repo: "{%:: if not repo_url.startswith('ppa:') ::%}{%:: if is_src_repo is defined\
      \ and is_src_repo ::%}deb-src {%:: else ::%}deb {%:: endif ::%}{%:: endif ::%}{{::\
      \ repo_url ::}}{%:: if codename is defined and codename ::%} {{:: codename ::}}{%::\
      \ endif ::%}{%:: if components is defined and components ::%} {{:: components\
      \ | join(' ') ::}}{%:: endif ::%}"
    update_cache: '{{:: update_cache ::}}'
    state: present
    filename: '{{:: repo_alias ::}}'
    codename: '{{:: codename ::}}'
frecklecute apt-repository-added --help

Usage: frecklecute apt-repository-added [OPTIONS] REPO_URL

  Ensures an apt repository is available and activated.

Options:
  --codename CODENAME             Override the distribution codename to use
                                  for PPA repositories. Should usually only be
                                  set when working with a PPA on a non-Ubuntu
                                  target (e.g. Debian or Mint).
  --components COMPONENTS         List of components for this repo (e.g.
                                  ['main', 'non-free']
  --is-src-repo                   Whether the repository should be added into
                                  the sources list.
  --repo-alias REPO_ALIAS         When provided, the repo will be added in a
                                  separate file under '/etc/apt/sources.d',
                                  using the value of this argument as
                                  filename.
  --update-cache / --no-update-cache
                                  Run the equivalent of apt-get update when a
                                  change occurs. Cache updates are run after
                                  making changes.
  --help                          Show this message and exit.
# -*- coding: utf-8 -*-


#
# module path: pycklets.apt_repository_added.AptRepositoryAdded
#


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

@dataclass
class AptRepositoryAdded(AutoPycklet):
    """Ensures an apt repository is available and activated.

       Args:
         codename: Override the distribution codename to use for PPA repositories. Should usually only be set when working with a PPA on a non-Ubuntu target (e.g. Debian or Mint).
         components: List of components for this repo (e.g. ['main', 'non-free']
         is_src_repo: Whether the repository should be added into the sources list.
         repo_alias: When provided, the repo will be added in a separate file under '/etc/apt/sources.d', using the value of this argument as filename.
         repo_url: The url of the apt repository.
         update_cache: Run the equivalent of apt-get update when a change occurs. Cache updates are run after making changes.

    """

    FRECKLET_ID = "apt-repository-added"

    codename: str = None
    components: List = None
    is_src_repo: bool = None
    repo_alias: str = None
    repo_url: str = None
    update_cache: bool = None


    def __post_init__(self):
        super(AptRepositoryAdded, self).__init__(var_names=["codename", "components", "is_src_repo", "repo_alias", "repo_url", "update_cache"])


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


#
# module path: pycklets.apt_repository_added.AptRepositoryAdded
#


from pyckles import AutoPycklet

class AptRepositoryAdded(AutoPycklet):
    """Ensures an apt repository is available and activated.

       Args:
         codename: Override the distribution codename to use for PPA repositories. Should usually only be set when working with a PPA on a non-Ubuntu target (e.g. Debian or Mint).
         components: List of components for this repo (e.g. ['main', 'non-free']
         is_src_repo: Whether the repository should be added into the sources list.
         repo_alias: When provided, the repo will be added in a separate file under '/etc/apt/sources.d', using the value of this argument as filename.
         repo_url: The url of the apt repository.
         update_cache: Run the equivalent of apt-get update when a change occurs. Cache updates are run after making changes.

    """

    FRECKLET_ID = "apt-repository-added"

    def __init__(self, codename=None, components=None, is_src_repo=None, repo_alias=None, repo_url=None, update_cache=True):

        super(AptRepositoryAdded, self).__init__(var_names=["codename", "components", "is_src_repo", "repo_alias", "repo_url", "update_cache"])
        self._codename = codename
        self._components = components
        self._is_src_repo = is_src_repo
        self._repo_alias = repo_alias
        self._repo_url = repo_url
        self._update_cache = update_cache

    @property
    def codename(self):
        return self._codename

    @codename.setter
    def codename(self, codename):
        self._codename = codename

    @property
    def components(self):
        return self._components

    @components.setter
    def components(self, components):
        self._components = components

    @property
    def is_src_repo(self):
        return self._is_src_repo

    @is_src_repo.setter
    def is_src_repo(self, is_src_repo):
        self._is_src_repo = is_src_repo

    @property
    def repo_alias(self):
        return self._repo_alias

    @repo_alias.setter
    def repo_alias(self, repo_alias):
        self._repo_alias = repo_alias

    @property
    def repo_url(self):
        return self._repo_url

    @repo_url.setter
    def repo_url(self, repo_url):
        self._repo_url = repo_url

    @property
    def update_cache(self):
        return self._update_cache

    @update_cache.setter
    def update_cache(self, update_cache):
        self._update_cache = update_cache



frecklet_class = AptRepositoryAdded