跳转到主要内容

验证框架的通用库

项目描述

https://governance.openstack.org/tc/badges/validations-libs.svg

验证框架的Python库集合

验证可以帮助在部署过程中早期发现问题,并防止现场工程师在他们环境中浪费时间在错误的配置或硬件问题上。

开发环境设置

提供CentOS和Ubuntu的Vagrantfile,以便方便使用;只需将其中一个复制到您希望的位置,并将其重命名为Vagrantfile,然后运行

vagrant up

完成后,您将拥有一个干净的开发环境,可以用于验证框架的工作。

podman 快速入门

在Validations Library项目的根目录中提供了一个Dockerfile,以便快速设置和修改验证框架,在单机环境下进行。通过运行Dockerfile构建容器:

podman build -t "vf:dockerfile" .

从validations-libs存储库目录。

由于Podman构建使用来自buildah项目的代码来构建容器镜像。您还可以使用以下方式构建镜像:

buildah bud -t "vf:dockerfile" .

然后您可以运行容器并开始运行一些内置的验证。

podman run -ti vf:dockerfile /bin/bash

然后运行验证。

validation.py run --validation check-ftype,512e --inventory /etc/ansible/hosts

跳过列表。

您可以通过run命令提供一个包含要跳过的验证列表的文件。

validation.py run --validation check-ftype,512e --inventory /etc/ansible/hosts --skiplist my-skip-list.yaml

此文件应格式如下:

validation-name:
  hosts: targeted_hostname
  reason: reason to ignore the file
  lp: bug number

框架将跳过与hosts键的验证。为了在所有主机上跳过验证,您可以设置all值,例如:

hosts: all

如果某个验证没有提供hosts键,则将其视为hosts: all

社区验证

社区验证允许系统管理员通过validation CLI创建和执行其环境特有的验证。

社区验证将在CLI运行的非root用户的主目录中的唯一、标准化且已知位置创建和存储,称为'community-validations/'

必需结构的第一个级别将是以下内容(假设操作员使用pennywise用户):

/home/pennywise/community-validations
├── library
├── lookup_plugins
├── playbooks
└── roles

如何创建新的社区验证

[pennywise@localhost]$ validation init my-new-validation
Validation config file found: /etc/validation.cfg
New role created successfully in /home/pennywise/community-validations/roles/my_new_validation
New playbook created successfully in /home/pennywise/community-validations/playbooks/my-new-validation.yaml

community-validations/目录应在pennywise用户的主目录中创建。

[pennywise@localhost ~]$ cd && tree community-validations/
community-validations/
├── library
├── lookup_plugins
├── playbooks
│   └── my-new-validation.yaml
└── roles
    └── my_new_validation
        ├── defaults
        │   └── main.yml
        ├── files
        ├── handlers
        │   └── main.yml
        ├── meta
        │   └── main.yml
        ├── README.md
        ├── tasks
        │   └── main.yml
        ├── templates
        ├── tests
        │   ├── inventory
        │   └── test.yml
        └── vars
            └── main.yml

13 directories, 9 files

您的新社区验证也应该在列出系统上可用的所有验证时可用。

[pennywise@localhost ~]$ validation list
Validation config file found: /etc/validation.cfg
+-------------------------------+--------------------------------+--------------------------------+-----------------------------------+---------------+
| ID                            | Name                           | Groups                         | Categories                        | Products      |
+-------------------------------+--------------------------------+--------------------------------+-----------------------------------+---------------+
| 512e                          | Advanced Format 512e Support   | ['prep', 'pre-deployment']     | ['storage', 'disk', 'system']     | ['common']    |
| check-cpu                     | Verify if the server fits the  | ['prep', 'backup-and-restore', | ['system', 'cpu', 'core', 'os']   | ['common']    |
|                               | CPU core requirements          | 'pre-introspection']           |                                   |               |
| check-disk-space-pre-upgrade  | Verify server fits the disk    | ['pre-upgrade']                | ['system', 'disk', 'upgrade']     | ['common']    |
|                               | space requirements to perform  |                                |                                   |               |
|                               | an upgrade                     |                                |                                   |               |
| check-disk-space              | Verify server fits the disk    | ['prep', 'pre-introspection']  | ['system', 'disk', 'upgrade']     | ['common']    |
|                               | space requirements             |                                |                                   |               |
| check-ftype                   | XFS ftype check                | ['pre-upgrade']                | ['storage', 'xfs', 'disk']        | ['common']    |
| check-latest-packages-version | Check if latest version of     | ['pre-upgrade']                | ['packages', 'rpm', 'upgrade']    | ['common']    |
|                               | packages is installed          |                                |                                   |               |
| check-ram                     | Verify the server fits the RAM | ['prep', 'pre-introspection',  | ['system', 'ram', 'memory', 'os'] | ['common']    |
|                               | requirements                   | 'pre-upgrade']                 |                                   |               |
| check-selinux-mode            | SELinux Enforcing Mode Check   | ['prep', 'pre-introspection']  | ['security', 'selinux']           | ['common']    |
| dns                           | Verify DNS                     | ['pre-deployment']             | ['networking', 'dns']             | ['common']    |
| no-op                         | NO-OP validation               | ['no-op']                      | ['noop', 'dummy', 'test']         | ['common']    |
| ntp                           | Verify all deployed servers    | ['post-deployment']            | ['networking', 'time', 'os']      | ['common']    |
|                               | have their clock synchronised  |                                |                                   |               |
| service-status                | Ensure services state          | ['prep', 'backup-and-restore', | ['systemd', 'container',          | ['common']    |
|                               |                                | 'pre-deployment', 'pre-        | 'docker', 'podman']               |               |
|                               |                                | upgrade', 'post-deployment',   |                                   |               |
|                               |                                | 'post-upgrade']                |                                   |               |
| validate-selinux              | validate-selinux               | ['backup-and-restore', 'pre-   | ['security', 'selinux', 'audit']  | ['common']    |
|                               |                                | deployment', 'post-            |                                   |               |
|                               |                                | deployment', 'pre-upgrade',    |                                   |               |
|                               |                                | 'post-upgrade']                |                                   |               |
| my-new-validation             | Brief and general description  | ['prep', 'pre-deployment']     | ['networking', 'security', 'os',  | ['community'] |
|                               | of the validation              |                                | 'system']                         |               |
+-------------------------------+--------------------------------+--------------------------------+-----------------------------------+---------------+

要仅获取您的社区验证列表,您可以通过产品进行筛选

[pennywise@localhost]$ validation list --product community
Validation config file found: /etc/validation.cfg
+-------------------+------------------------------------------+----------------------------+------------------------------------------+---------------+
| ID                | Name                                     | Groups                     | Categories                               | Products      |
+-------------------+------------------------------------------+----------------------------+------------------------------------------+---------------+
| my-new-validation | Brief and general description of the     | ['prep', 'pre-deployment'] | ['networking', 'security', 'os',         | ['community'] |
|                   | validation                               |                            | 'system']                                |               |
+-------------------+------------------------------------------+----------------------------+------------------------------------------+---------------+

如何开发您的新社区验证

如您上图所示,validation init CLI子命令已通过使用ansible-galaxycommunity-validations/目录中生成新的Ansible角色和新的Ansible playbooks。

您现在可以通过编辑生成的playbook并添加到相关角色中的Ansible任务来实现自己的验证。

对于不熟悉如何编写验证的人,可以从这份文档开始。

项目详情


下载文件

下载您平台对应的文件。如果您不确定选择哪个,请了解更多关于 安装包 的信息。

源代码分发

validations-libs-1.9.0.tar.gz (118.8 kB 查看哈希值)

上传时间 源代码

构建分发

validations_libs-1.9.0-py3-none-any.whl (144.6 kB 查看哈希值)

上传时间 Python 3

由以下支持

AWSAWS云计算和安全赞助商DatadogDatadog监控FastlyFastlyCDNGoogleGoogle下载分析MicrosoftMicrosoftPSF赞助商PingdomPingdom监控SentrySentry错误日志StatusPageStatusPage状态页面