constrict0r.aptitude

aptitude


这是一个Ansible角色,用于作为apt <https://wiki.debian.org/Apt>_的包装器来管理软件包。

完整文档在Readthedocs <https://aptitude.readthedocs.io>_上。

源代码在:

Github <https://github.com/constrict0r/aptitude>_。

Gitlab <https://gitlab.com/constrict0r/aptitude>_。

组成部分:https://gitlab.com/explore/projects?tag=doombot

成分

内容


  • 描述 <#Description>_
  • 使用方法 <#Usage>_
  • 变量 <#Variables>_
    • packages <#packages>_
    • packages_purge <#packages-purge>_
    • configuration <#configuration>_
  • YAML <#YAML>_
  • 属性 <#Attributes>_
    • item_expand <#item-expand>_
    • item_path <#item-path>_
  • 要求 <#Requirements>_
  • 兼容性 <#Compatibility>_
  • 许可证 <#License>_
  • 链接 <#Links>_
  • UML <#UML>_
    • 部署 <#deployment>_
    • 主要 <#main>_
  • 作者 <#Author>_

描述


Ansible角色,作为apt的包装器来管理软件包。

该角色执行以下操作:

  • 确保已安装所需的依赖项。
  • 确保当前用户可以获得管理(root)权限。
  • 更新apt缓存。
  • 如果定义了packages_purge变量,则删除该变量中列出的软件包。
  • 如果定义了configuration变量,则删除该变量中列出的packages_purge
  • 如果定义了packages变量,则安装该变量中列出的软件包。
  • 如果定义了configuration变量,则安装该变量中列出的软件包。

使用方法


  • 安装和执行:

    ::

    ansible-galaxy install constrict0r.aptitude
    ansible localhost -m include_role -a name=constrict0r.aptitude -K
    
  • 传递变量:

    ::

    ansible localhost -m include_role -a name=constrict0r.aptitude -K \
        -e "{packages: [gedit, rolldice]}"
    
  • 在剧本中包含角色:

    ::

    - hosts: servers
      roles:
          - {role: constrict0r.aptitude}
    
  • 将角色作为依赖关系包含在另一个角色中:

    ::

    dependencies:
      - role: constrict0r.aptitude
        packages: [gedit, rolldice]
    
  • 从任务中使用角色:

    ::

    - name: 执行角色任务。
      import_role:
        name: constrict0r.aptitude
      vars:
        packages: [gedit, rolldice]
    

运行测试:

::

cd aptitude chmod +x testme.sh ./testme.sh

某些测试可能需要使用sudo才能成功。

变量


支持以下变量:

packages

通过apt安装的软件包列表。

可以通过在剧本中包含角色时传递packages数组或通过终端的–extra-vars来修改此列表。

默认情况下此变量为空。

packages_purge

使用apt删除的软件包列表。

可以通过在剧本中包含角色时传递packages_purge数组或通过终端的–extra-vars来修改此列表。

默认情况下此变量为空。

configuration

指向包含角色支持的所有或部分变量的*.yml*文件的绝对路径或URL。

建议使用*.yml.yaml*扩展名作为configuration文件。

默认情况下此变量为空。

YAML


当将配置文件作为参数传递给此角色时,建议为每个文件添加*.yml.yaml*扩展名。

建议在每个文件顶部添加三个破折号:


您可以在文件中包含任务所需的变量:


packages: - [gedit, rolldice]

如果希望此角色从文件和URL中加载项目列表,可以将expand变量设置为true


packages: /home/username/my-config.yml

expand: true

如果expand变量为false,则任何发现的文件路径或URL将被视为纯文本。

属性


在项目级别,您可以使用属性来配置此角色如何处理项目数据。

此角色支持的属性有:

item_expand

布尔值,指示如何处理此项目,是作为文件路径或URL,还是仅作为纯文本。

item_path

指向*.yml*文件的绝对路径或URL。

要求


  • Ansible <https://www.ansible.com>_ >= 2.8。
  • Jinja2 <https://palletsprojects.com/p/jinja/>_。
  • Pip <https://pypi.org/project/pip/>_。
  • Python <https://www.python.org/>_。
  • PyYAML <https://pyyaml.org/>_。
  • Requests <https://2.python-requests.org/en/master/>_。

如果要运行测试,还需要:

  • Docker <https://www.docker.com/>_。
  • Molecule <https://molecule.readthedocs.io/>_。
  • Setuptools <https://pypi.org/project/setuptools/>_。

兼容性


  • Debian Buster <https://wiki.debian.org/DebianBuster>_。
  • Debian Raspbian <https://raspbian.org/>_。
  • Debian Stretch <https://wiki.debian.org/DebianStretch>_。
  • Ubuntu Xenial <http://releases.ubuntu.com/16.04/>_。

许可证


MIT许可证。更多细节请参见许可证文件。

链接


  • Github <https://github.com/constrict0r/aptitude>_。
  • Gitlab <https://gitlab.com/constrict0r/aptitude>_。
  • Gitlab CI <https://gitlab.com/constrict0r/aptitude/pipelines>_。
  • Readthedocs <https://aptitude.readthedocs.io>_。
  • Travis CI <https://travis-ci.com/constrict0r/aptitude>_。

UML


部署

完整项目结构如下所示:

主要

项目数据流如下所示:

作者


流浪的杂耍恶棍。

享受吧!!!

关于项目

Wrapper for apt to install Debian packages.

安装
ansible-galaxy install constrict0r.aptitude
许可证
mit
下载
2.2k
拥有者
The Traveling Vaudeville Villain Gitlab: gitlab.com/constrict0r - Blog: geekl0g.wordpress.com - Twitter: twitter.com/constrict0r - Functional Café: is.gd/YDqy