mirror of
https://github.com/Dannecron/netology-devops.git
synced 2025-12-25 15:22:37 +03:00
add homework 8.5, complete molecule part
This commit is contained in:
@@ -39,4 +39,5 @@
|
||||
* [8.1. Введение в Ansible](/src/homework/08-ansible/8.1)
|
||||
* [8.2. Работа с Playbook](/src/homework/08-ansible/8.2)
|
||||
* [8.3. Использование Yandex Cloud](/src/homework/08-ansible/8.3)
|
||||
* [8.4 Работа с Roles](/src/homework/08-ansible/8.4)
|
||||
* [8.4. Работа с Roles](/src/homework/08-ansible/8.4)
|
||||
* [8.5. Тестирование Roles](/src/homework/08-ansible/8.5)
|
||||
|
||||
251
src/homework/08-ansible/8.5/molecule_output_clickhouse.txt
Normal file
251
src/homework/08-ansible/8.5/molecule_output_clickhouse.txt
Normal file
@@ -0,0 +1,251 @@
|
||||
INFO centos_7 scenario test matrix: dependency, lint, cleanup, destroy, syntax, create, prepare, converge, idempotence, side_effect, verify, cleanup, destroy
|
||||
INFO Performing prerun with role_name_check=0...
|
||||
INFO Set ANSIBLE_LIBRARY=~/.cache/ansible-compat/b9a93c/modules:~/.ansible/plugins/modules:/usr/share/ansible/plugins/modules
|
||||
INFO Set ANSIBLE_COLLECTIONS_PATH=~/.cache/ansible-compat/b9a93c/collections:~/.ansible/collections:/usr/share/ansible/collections
|
||||
INFO Set ANSIBLE_ROLES_PATH=~/.cache/ansible-compat/b9a93c/roles:~/.ansible/roles:/usr/share/ansible/roles:/etc/ansible/roles
|
||||
INFO Using ~/.cache/ansible-compat/b9a93c/roles/alexeysetevoi.clickhouse symlink to current repository in order to enable Ansible to find the role using its expected full name.
|
||||
INFO Inventory ~/code/libs/ansible-clickhouse/molecule/centos_7/../resources/inventory/hosts.yml linked to ~/.cache/molecule/ansible-clickhouse/centos_7/inventory/hosts
|
||||
INFO Inventory ~/code/libs/ansible-clickhouse/molecule/centos_7/../resources/inventory/group_vars/ linked to ~/.cache/molecule/ansible-clickhouse/centos_7/inventory/group_vars
|
||||
INFO Inventory ~/code/libs/ansible-clickhouse/molecule/centos_7/../resources/inventory/host_vars/ linked to ~/.cache/molecule/ansible-clickhouse/centos_7/inventory/host_vars
|
||||
INFO Running centos_7 > dependency
|
||||
INFO Running ansible-galaxy collection install -v --pre community.docker:>=3.0.0-a2
|
||||
WARNING Skipping, missing the requirements file.
|
||||
WARNING Skipping, missing the requirements file.
|
||||
INFO Inventory ~/code/libs/ansible-clickhouse/molecule/centos_7/../resources/inventory/hosts.yml linked to ~/.cache/molecule/ansible-clickhouse/centos_7/inventory/hosts
|
||||
INFO Inventory ~/code/libs/ansible-clickhouse/molecule/centos_7/../resources/inventory/group_vars/ linked to ~/.cache/molecule/ansible-clickhouse/centos_7/inventory/group_vars
|
||||
INFO Inventory ~/code/libs/ansible-clickhouse/molecule/centos_7/../resources/inventory/host_vars/ linked to ~/.cache/molecule/ansible-clickhouse/centos_7/inventory/host_vars
|
||||
INFO Running centos_7 > lint
|
||||
WARNING Listing 56 violation(s) that are fatal
|
||||
fqcn-builtins: Use FQCN for builtin actions.
|
||||
handlers/main.yml:3 Task/Handler: Restart Clickhouse Service
|
||||
|
||||
schema: 7 is not one of ['6.1', '7.1', '7.2', 'all'] (schema[meta])
|
||||
meta/main.yml:1 Returned errors will not include exact line numbers, but they will mention
|
||||
the schema name being used as a tag, like ``playbook-schema``,
|
||||
``tasks-schema``.
|
||||
|
||||
This rule is not skippable and stops further processing of the file.
|
||||
|
||||
Schema bugs should be reported towards (https://github.com/ansible/schemas) project instead of ansible-lint.
|
||||
|
||||
If incorrect schema was picked, you might want to either:
|
||||
|
||||
* move the file to standard location, so its file is detected correctly.
|
||||
* use ``kinds:`` option in linter config to help it pick correct file type.
|
||||
|
||||
|
||||
fqcn-builtins: Use FQCN for builtin actions.
|
||||
molecule/centos_7/converge.yml:5 Task/Handler: Include ansible-clickhouse
|
||||
|
||||
fqcn-builtins: Use FQCN for builtin actions.
|
||||
molecule/centos_7/verify.yml:8 Task/Handler: Example assertion
|
||||
|
||||
fqcn-builtins: Use FQCN for builtin actions.
|
||||
molecule/centos_8/converge.yml:5 Task/Handler: Include ansible-clickhouse
|
||||
|
||||
fqcn-builtins: Use FQCN for builtin actions.
|
||||
molecule/centos_8/verify.yml:8 Task/Handler: Example assertion
|
||||
|
||||
schema: None is not of type 'object' (schema[inventory])
|
||||
molecule/resources/inventory/hosts.yml:1 Returned errors will not include exact line numbers, but they will mention
|
||||
the schema name being used as a tag, like ``playbook-schema``,
|
||||
``tasks-schema``.
|
||||
|
||||
This rule is not skippable and stops further processing of the file.
|
||||
|
||||
Schema bugs should be reported towards (https://github.com/ansible/schemas) project instead of ansible-lint.
|
||||
|
||||
If incorrect schema was picked, you might want to either:
|
||||
|
||||
* move the file to standard location, so its file is detected correctly.
|
||||
* use ``kinds:`` option in linter config to help it pick correct file type.
|
||||
|
||||
|
||||
fqcn-builtins: Use FQCN for builtin actions.
|
||||
molecule/resources/playbooks/converge.yml:5 Task/Handler: Apply Clickhouse Role
|
||||
|
||||
fqcn-builtins: Use FQCN for builtin actions.
|
||||
molecule/ubuntu_focal/converge.yml:5 Task/Handler: Include ansible-clickhouse
|
||||
|
||||
fqcn-builtins: Use FQCN for builtin actions.
|
||||
molecule/ubuntu_focal/verify.yml:8 Task/Handler: Example assertion
|
||||
|
||||
fqcn-builtins: Use FQCN for builtin actions.
|
||||
tasks/configure/db.yml:2 Task/Handler: Set ClickHose Connection String
|
||||
|
||||
fqcn-builtins: Use FQCN for builtin actions.
|
||||
tasks/configure/db.yml:5 Task/Handler: Gather list of existing databases
|
||||
|
||||
fqcn-builtins: Use FQCN for builtin actions.
|
||||
tasks/configure/db.yml:11 Task/Handler: Config | Delete database config
|
||||
|
||||
fqcn-builtins: Use FQCN for builtin actions.
|
||||
tasks/configure/db.yml:20 Task/Handler: Config | Create database config
|
||||
|
||||
fqcn-builtins: Use FQCN for builtin actions.
|
||||
tasks/configure/dict.yml:2 Task/Handler: Config | Generate dictionary config
|
||||
|
||||
fqcn-builtins: Use FQCN for builtin actions.
|
||||
tasks/configure/sys.yml:2 Task/Handler: Check clickhouse config, data and logs
|
||||
|
||||
fqcn-builtins: Use FQCN for builtin actions.
|
||||
tasks/configure/sys.yml:17 Task/Handler: Config | Create config.d folder
|
||||
|
||||
fqcn-builtins: Use FQCN for builtin actions.
|
||||
tasks/configure/sys.yml:26 Task/Handler: Config | Create users.d folder
|
||||
|
||||
fqcn-builtins: Use FQCN for builtin actions.
|
||||
tasks/configure/sys.yml:35 Task/Handler: Config | Generate system config
|
||||
|
||||
fqcn-builtins: Use FQCN for builtin actions.
|
||||
tasks/configure/sys.yml:45 Task/Handler: Config | Generate users config
|
||||
|
||||
fqcn-builtins: Use FQCN for builtin actions.
|
||||
tasks/configure/sys.yml:54 Task/Handler: Config | Generate remote_servers config
|
||||
|
||||
fqcn-builtins: Use FQCN for builtin actions.
|
||||
tasks/configure/sys.yml:65 Task/Handler: Config | Generate macros config
|
||||
|
||||
fqcn-builtins: Use FQCN for builtin actions.
|
||||
tasks/configure/sys.yml:76 Task/Handler: Config | Generate zookeeper servers config
|
||||
|
||||
fqcn-builtins: Use FQCN for builtin actions.
|
||||
tasks/configure/sys.yml:87 Task/Handler: Config | Fix interserver_http_port and intersever_https_port collision
|
||||
|
||||
fqcn-builtins: Use FQCN for builtin actions.
|
||||
tasks/install/apt.yml:5 Task/Handler: Install by APT | Apt-key add repo key
|
||||
|
||||
fqcn-builtins: Use FQCN for builtin actions.
|
||||
tasks/install/apt.yml:12 Task/Handler: Install by APT | Remove old repo
|
||||
|
||||
fqcn-builtins: Use FQCN for builtin actions.
|
||||
tasks/install/apt.yml:20 Task/Handler: Install by APT | Repo installation
|
||||
|
||||
fqcn-builtins: Use FQCN for builtin actions.
|
||||
tasks/install/apt.yml:27 Task/Handler: Install by APT | Package installation
|
||||
|
||||
fqcn-builtins: Use FQCN for builtin actions.
|
||||
tasks/install/apt.yml:36 Task/Handler: Install by APT | Package installation
|
||||
|
||||
fqcn-builtins: Use FQCN for builtin actions.
|
||||
tasks/install/apt.yml:45 Task/Handler: Hold specified version during APT upgrade | Package installation
|
||||
|
||||
risky-file-permissions: File permissions unset or incorrect.
|
||||
tasks/install/apt.yml:45 Task/Handler: Hold specified version during APT upgrade | Package installation
|
||||
|
||||
fqcn-builtins: Use FQCN for builtin actions.
|
||||
tasks/install/dnf.yml:5 Task/Handler: Install by YUM | Ensure clickhouse repo GPG key imported
|
||||
|
||||
fqcn-builtins: Use FQCN for builtin actions.
|
||||
tasks/install/dnf.yml:12 Task/Handler: Install by YUM | Ensure clickhouse repo installed
|
||||
|
||||
fqcn-builtins: Use FQCN for builtin actions.
|
||||
tasks/install/dnf.yml:24 Task/Handler: Install by YUM | Ensure clickhouse package installed (latest)
|
||||
|
||||
fqcn-builtins: Use FQCN for builtin actions.
|
||||
tasks/install/dnf.yml:32 Task/Handler: Install by YUM | Ensure clickhouse package installed (version {{ clickhouse_version }})
|
||||
|
||||
fqcn-builtins: Use FQCN for builtin actions.
|
||||
tasks/install/yum.yml:5 Task/Handler: Install by YUM | Ensure clickhouse repo installed
|
||||
|
||||
fqcn-builtins: Use FQCN for builtin actions.
|
||||
tasks/install/yum.yml:16 Task/Handler: Install by YUM | Ensure clickhouse package installed (latest)
|
||||
|
||||
fqcn-builtins: Use FQCN for builtin actions.
|
||||
tasks/install/yum.yml:24 Task/Handler: Install by YUM | Ensure clickhouse package installed (version {{ clickhouse_version }})
|
||||
|
||||
fqcn-builtins: Use FQCN for builtin actions.
|
||||
tasks/main.yml:3 Task/Handler: Include OS Family Specific Variables
|
||||
|
||||
fqcn-builtins: Use FQCN for builtin actions.
|
||||
tasks/main.yml:39 Task/Handler: Notify Handlers Now
|
||||
|
||||
fqcn-builtins: Use FQCN for builtin actions.
|
||||
tasks/main.yml:45 Task/Handler: Wait for Clickhouse Server to Become Ready
|
||||
|
||||
fqcn-builtins: Use FQCN for builtin actions.
|
||||
tasks/params.yml:3 Task/Handler: Set clickhouse_service_enable
|
||||
|
||||
fqcn-builtins: Use FQCN for builtin actions.
|
||||
tasks/params.yml:7 Task/Handler: Set clickhouse_service_ensure
|
||||
|
||||
fqcn-builtins: Use FQCN for builtin actions.
|
||||
tasks/precheck.yml:1 Task/Handler: Requirements check | Checking sse4_2 support
|
||||
|
||||
fqcn-builtins: Use FQCN for builtin actions.
|
||||
tasks/precheck.yml:5 Task/Handler: Requirements check | Not supported distribution && release
|
||||
|
||||
fqcn-builtins: Use FQCN for builtin actions.
|
||||
tasks/remove.yml:3 Task/Handler: Remove clickhouse config,data and logs
|
||||
|
||||
fqcn-builtins: Use FQCN for builtin actions.
|
||||
tasks/remove/apt.yml:5 Task/Handler: Uninstall by APT | Package uninstallation
|
||||
|
||||
fqcn-builtins: Use FQCN for builtin actions.
|
||||
tasks/remove/apt.yml:12 Task/Handler: Uninstall by APT | Repo uninstallation
|
||||
|
||||
fqcn-builtins: Use FQCN for builtin actions.
|
||||
tasks/remove/apt.yml:18 Task/Handler: Uninstall by APT | Apt-key remove repo key
|
||||
|
||||
fqcn-builtins: Use FQCN for builtin actions.
|
||||
tasks/remove/dnf.yml:5 Task/Handler: Uninstall by YUM | Ensure clickhouse package uninstalled
|
||||
|
||||
fqcn-builtins: Use FQCN for builtin actions.
|
||||
tasks/remove/dnf.yml:12 Task/Handler: Uninstall by YUM | Ensure clickhouse repo uninstalled
|
||||
|
||||
fqcn-builtins: Use FQCN for builtin actions.
|
||||
tasks/remove/dnf.yml:19 Task/Handler: Uninstall by YUM | Ensure clickhouse key uninstalled
|
||||
|
||||
fqcn-builtins: Use FQCN for builtin actions.
|
||||
tasks/remove/yum.yml:5 Task/Handler: Uninstall by YUM | Ensure clickhouse package uninstalled
|
||||
|
||||
fqcn-builtins: Use FQCN for builtin actions.
|
||||
tasks/remove/yum.yml:12 Task/Handler: Uninstall by YUM | Ensure clickhouse repo uninstalled
|
||||
|
||||
fqcn-builtins: Use FQCN for builtin actions.
|
||||
tasks/service.yml:3 Task/Handler: Ensure {{ clickhouse_service }} is enabled: {{ clickhouse_service_enable }} and state: {{ clickhouse_service_ensure }}
|
||||
|
||||
var-spacing: Jinja2 variables and filters should have spaces before and after.
|
||||
vars/debian.yml:4 .clickhouse_repo_old
|
||||
|
||||
You can skip specific rules or tags by adding them to your configuration file:
|
||||
# .config/ansible-lint.yml
|
||||
warn_list: # or 'skip_list' to silence them completely
|
||||
- experimental # all rules tagged as experimental
|
||||
- fqcn-builtins # Use FQCN for builtin actions.
|
||||
- var-spacing # Jinja2 variables and filters should have spaces before and after.
|
||||
|
||||
Finished with 53 failure(s), 3 warning(s) on 56 files.
|
||||
zsh:3: command not found: flake8
|
||||
WARNING Retrying execution failure 127 of: y a m l l i n t .
|
||||
a n s i b l e - l i n t
|
||||
f l a k e 8
|
||||
|
||||
CRITICAL Lint failed with error code 127
|
||||
WARNING An error occurred during the test sequence action: 'lint'. Cleaning up.
|
||||
INFO Inventory ~/code/libs/ansible-clickhouse/molecule/centos_7/../resources/inventory/hosts.yml linked to ~/.cache/molecule/ansible-clickhouse/centos_7/inventory/hosts
|
||||
INFO Inventory ~/code/libs/ansible-clickhouse/molecule/centos_7/../resources/inventory/group_vars/ linked to ~/.cache/molecule/ansible-clickhouse/centos_7/inventory/group_vars
|
||||
INFO Inventory ~/code/libs/ansible-clickhouse/molecule/centos_7/../resources/inventory/host_vars/ linked to ~/.cache/molecule/ansible-clickhouse/centos_7/inventory/host_vars
|
||||
INFO Running centos_7 > cleanup
|
||||
WARNING Skipping, cleanup playbook not configured.
|
||||
INFO Inventory ~/code/libs/ansible-clickhouse/molecule/centos_7/../resources/inventory/hosts.yml linked to ~/.cache/molecule/ansible-clickhouse/centos_7/inventory/hosts
|
||||
INFO Inventory ~/code/libs/ansible-clickhouse/molecule/centos_7/../resources/inventory/group_vars/ linked to ~/.cache/molecule/ansible-clickhouse/centos_7/inventory/group_vars
|
||||
INFO Inventory ~/code/libs/ansible-clickhouse/molecule/centos_7/../resources/inventory/host_vars/ linked to ~/.cache/molecule/ansible-clickhouse/centos_7/inventory/host_vars
|
||||
INFO Running centos_7 > destroy
|
||||
INFO Sanity checks: 'docker'
|
||||
|
||||
PLAY [Destroy] *****************************************************************
|
||||
|
||||
TASK [Destroy molecule instance(s)] ********************************************
|
||||
changed: [localhost] => (item=centos_7)
|
||||
|
||||
TASK [Wait for instance(s) deletion to complete] *******************************
|
||||
FAILED - RETRYING: [localhost]: Wait for instance(s) deletion to complete (300 retries left).
|
||||
ok: [localhost] => (item=centos_7)
|
||||
|
||||
TASK [Delete docker networks(s)] ***********************************************
|
||||
|
||||
PLAY RECAP *********************************************************************
|
||||
localhost : ok=2 changed=1 unreachable=0 failed=0 skipped=1 rescued=0 ignored=0
|
||||
|
||||
INFO Pruning extra files from scenario ephemeral directory
|
||||
114
src/homework/08-ansible/8.5/readme.md
Normal file
114
src/homework/08-ansible/8.5/readme.md
Normal file
@@ -0,0 +1,114 @@
|
||||
Выполнение [домашнего задания](https://github.com/netology-code/mnt-homeworks/blob/MNT-13/08-ansible-05-testing/README.md)
|
||||
по теме "8.5. Тестирование Roles".
|
||||
|
||||
## Q/A
|
||||
|
||||
### Задание 1
|
||||
|
||||
> Подготовка к выполнению
|
||||
> 1. Установите `molecule`: `pip3 install "molecule==3.5.2"`
|
||||
> 2. Выполните `docker pull aragast/netology:latest` - это образ с `podman`, `tox` и несколькими пайтонами (3.7 и 3.9) внутри
|
||||
|
||||
|
||||
Установка `molecule`:
|
||||
|
||||
```shell
|
||||
pip3 install "molecule==3.5.2" --user
|
||||
```
|
||||
|
||||
```shell
|
||||
molecule --version
|
||||
```
|
||||
|
||||
```text
|
||||
molecule 3.5.2 using python 3.8
|
||||
ansible:2.13.1
|
||||
delegated:3.5.2 from molecule
|
||||
```
|
||||
|
||||
Получение образа:
|
||||
|
||||
```shell
|
||||
docker pull aragast/netology:latest
|
||||
```
|
||||
|
||||
```shell
|
||||
docker run --rm aragast/netology:latest podman --version
|
||||
```
|
||||
|
||||
```text
|
||||
podman version 4.0.2
|
||||
```
|
||||
|
||||
### Задание 2
|
||||
|
||||
> Основная часть
|
||||
> Наша основная цель - настроить тестирование наших ролей.
|
||||
> Задача: сделать сценарии тестирования для vector.
|
||||
> Ожидаемый результат: все сценарии успешно проходят тестирование ролей.
|
||||
|
||||
> #### Molecule
|
||||
> 1. Запустите `molecule test -s centos7` внутри корневой директории `clickhouse-role`, посмотрите на вывод команды.
|
||||
|
||||
```shell
|
||||
molecule test -s centos_7
|
||||
```
|
||||
|
||||
Полный вывод команды: [molecule_output_clickhouse.txt](./molecule_output_clickhouse.txt).
|
||||
|
||||
> 2. Перейдите в каталог с ролью `vector-role` и создайте сценарий тестирования по умолчанию при помощи `molecule init scenario --driver-name docker`
|
||||
|
||||
```shell
|
||||
molecule init scenario --driver-name docker
|
||||
```
|
||||
|
||||
```text
|
||||
INFO Initializing new scenario default...
|
||||
INFO Initialized scenario in /home/dannc/code/learning/netology-devops-ansible-vector/molecule/default successfully.
|
||||
```
|
||||
|
||||
> 3. Добавьте несколько разных дистрибутивов (centos:8, ubuntu:latest) для инстансов и протестируйте роль, исправьте найденные ошибки, если они есть.
|
||||
|
||||
Роль была расширена путём добавления поддержки debian-based дистрибутивов (пакетный менеджер `apt`).
|
||||
Дополнительно, в сценарий по умолчанию добавлена проверка на образе `debian:bullsyeye`.
|
||||
|
||||
> 4. Добавьте несколько assert'ов в verify.yml файл для проверки работоспособности vector-role (проверка, что конфиг валидный, проверка успешности запуска, etc).
|
||||
> Запустите тестирование роли повторно и проверьте, что оно прошло успешно.
|
||||
|
||||
В `verify.yml` была добавлена проверка на успешный запуск сервиса `vector`:
|
||||
```yaml
|
||||
- name: ensure vector service started
|
||||
ansible.builtin.service:
|
||||
name: vector
|
||||
state: started
|
||||
```
|
||||
|
||||
> 5. Добавьте новый тег на коммит с рабочим сценарием в соответствии с семантическим версионированием.
|
||||
|
||||
Так как в данном случае было расширение функционала без потери обратной совместимости, то по семантическому версионированию
|
||||
новая версия будет иметь тэг `1.1.0`.
|
||||
|
||||
Новая версия доступна по ссылке: [Dannecron/netology-devops-ansible-vector:1.1.0](https://github.com/Dannecron/netology-devops-ansible-vector/releases/tag/1.1.0)
|
||||
|
||||
> #### Tox
|
||||
> 1. Добавьте в директорию с vector-role файлы из [директории](https://github.com/netology-code/mnt-homeworks/blob/MNT-13/08-ansible-05-testing/example)
|
||||
> 2. Запустите `docker run --privileged=True -v <path_to_repo>:/opt/vector-role -w /opt/vector-role -it aragast/netology:latest /bin/bash`, где path_to_repo - путь до корня репозитория с vector-role на вашей файловой системе.
|
||||
> 3. Внутри контейнера выполните команду `tox`, посмотрите на вывод.
|
||||
|
||||
// todo
|
||||
|
||||
> 4. Создайте облегчённый сценарий для `molecule` с драйвером `molecule_podman`. Проверьте его на исполнимость.
|
||||
|
||||
// todo
|
||||
|
||||
> 5. Пропишите правильную команду в `tox.ini` для того чтобы запускался облегчённый сценарий.
|
||||
|
||||
// todo
|
||||
|
||||
> 6. Запустите команду `tox`. Убедитесь, что всё отработало успешно.
|
||||
|
||||
// todo
|
||||
|
||||
> 7. Добавьте новый тег на коммит с рабочим сценарием в соответствии с семантическим версионированием.
|
||||
|
||||
// todo
|
||||
Reference in New Issue
Block a user