Files
DevOpsLab/molecule/default/run.yml
Сергей Антропов 2ce450215b feat: убран подробный вывод установки пакетов в run.yml
- Добавлен no_log: true для всех задач установки common tools
- Добавлен no_log: true для всех задач установки Python
- Теперь задачи показывают 'censored' вместо подробного вывода
- Улучшена читаемость логов тестирования

Автор: Сергей Антропов
Сайт: https://devops.org.ru
2025-10-29 18:59:57 +03:00

249 lines
7.1 KiB
YAML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
# =============================================================================
# SITE - Основной playbook для тестирования Ansible ролей
# =============================================================================
# Универсальный playbook для тестирования Ansible ролей
# Автор: Сергей Антропов
# Сайт: https://devops.org.ru
#
# Этот файл отвечает за:
# 1. Обновление пакетов в контейнерах при запуске тестов
# 2. Установку common tools для корректной работы тестов
# 3. Подготовку окружения для тестирования ролей
# 4. Запуск всех ролей из директории roles/
- name: Подготовка окружения для тестирования
hosts: all
become: true
tasks:
# Сброс цветовых кодов ANSI для корректного отображения
- name: Reset ANSI color codes
debug:
msg: "\033[0m"
changed_when: false
tags:
- setup
- color-reset
# Отладочная информация о vault переменных (передаются из converge.yml)
- name: Проверка vault переменных
debug:
msg: |
Vault переменные на {{ ansible_hostname }}:
- vault_devops_password: {{ vault_devops_password | default('НЕ ОПРЕДЕЛЕНА') | length }} символов
- vault_devops_ssh_public_key: {{ vault_devops_ssh_public_key | default('НЕ ОПРЕДЕЛЕНА') | length }} символов
tags:
- setup
- vault
- debug
# Создание tmp директории для Ansible
- name: Create Ansible tmp directory
file:
path: /tmp/.ansible-tmp
state: directory
mode: '0755'
owner: root
group: root
tags:
- setup
- tmp
# Создание vault директории
- name: Create vault directory
file:
path: /workspace/vault
state: directory
mode: '0755'
owner: root
group: root
tags:
- setup
- vault
# Обновление кеша пакетов для Debian/Ubuntu
- name: Update package cache (Debian/Ubuntu)
apt:
update_cache: true
cache_valid_time: 3600
when: ansible_os_family == 'Debian'
changed_when: false
tags:
- setup
- update
# Обновление кеша пакетов для RHEL/CentOS/AlmaLinux/Rocky
- name: Update package cache (RHEL/CentOS/AlmaLinux/Rocky)
yum:
update_cache: true
when: ansible_os_family == 'RedHat'
changed_when: false
tags:
- setup
- update
# Обновление кеша пакетов для Alt Linux
- name: Update package cache (Alt Linux)
command: apt-get update
when: ansible_os_family == 'Altlinux'
changed_when: false
failed_when: false
tags:
- setup
- update
# Обновление кеша пакетов для Astra Linux
- name: Update package cache (Astra Linux)
command: apt-get update
when: ansible_os_family == 'Astra Linux'
changed_when: false
failed_when: false
tags:
- setup
- update
# Установка common tools для всех ОС
- name: Install common tools (Debian/Ubuntu)
apt:
name:
- curl
- jq
- ca-certificates
- iproute2
- iputils-ping
- procps
- net-tools
- vim
- wget
- unzip
- git
- sudo
state: present
update_cache: false
when: ansible_os_family == 'Debian'
no_log: true
tags:
- setup
- tools
- name: Install common tools (RHEL/CentOS/AlmaLinux/Rocky)
yum:
name:
- curl
- jq
- ca-certificates
- iproute
- iputils
- procps-ng
- net-tools
- vim
- wget
- unzip
- git
- sudo
state: present
when: ansible_os_family == 'RedHat'
no_log: true
tags:
- setup
- tools
- name: Install common tools (Alt Linux)
command: apt-get install -y curl jq ca-certificates iproute2 iputils procps net-tools vim wget unzip git sudo
when: ansible_os_family == 'Altlinux'
changed_when: false
failed_when: false
no_log: true
tags:
- setup
- tools
- name: Install common tools (Astra Linux)
command: apt-get install -y curl jq ca-certificates iproute2 iputils procps net-tools vim wget unzip git sudo
when: ansible_os_family == 'Astra Linux'
changed_when: false
failed_when: false
no_log: true
tags:
- setup
- tools
# Установка Python для Ansible (если не установлен)
- name: Install Python (Debian/Ubuntu)
apt:
name:
- python3
- python3-pip
- python3-venv
state: present
when: ansible_os_family == 'Debian'
no_log: true
tags:
- setup
- python
- name: Install Python (RHEL/CentOS/AlmaLinux/Rocky)
yum:
name:
- python3
- python3-pip
state: present
when: ansible_os_family == 'RedHat'
no_log: true
tags:
- setup
- python
- name: Install Python (Alt Linux)
command: apt-get install -y python3 python3-pip
when: ansible_os_family == 'Altlinux'
changed_when: false
failed_when: false
no_log: true
tags:
- setup
- python
- name: Install Python (Astra Linux)
command: apt-get install -y python3 python3-pip
when: ansible_os_family == 'Astra Linux'
changed_when: false
failed_when: false
no_log: true
tags:
- setup
- python
# Создание пользователя для тестирования (ЗАКОММЕНТИРОВАНО)
# - name: Create test user
# user:
# name: testuser
# shell: /bin/bash
# create_home: yes
# state: present
# tags:
# - setup
# - user
# Настройка sudo для тестового пользователя (ЗАКОММЕНТИРОВАНО)
# - name: Configure sudo for test user
# lineinfile:
# path: /etc/sudoers
# line: "testuser ALL=(ALL) NOPASSWD:ALL"
# state: present
# validate: 'visudo -cf %s'
# tags:
# - setup
# - sudo
# Создание директории для тестов (ЗАКОММЕНТИРОВАНО)
# - name: Create test directory
# file:
# path: /tmp/ansible-test
# state: directory
# mode: '0755'
# owner: testuser
# group: testuser
# tags:
# - setup
# - directory