Some checks failed
		
		
	
	Ansible Testing / lint (push) Has been cancelled
				
			Ansible Testing / test (default) (push) Has been cancelled
				
			Ansible Testing / test (minimal) (push) Has been cancelled
				
			Ansible Testing / test (performance) (push) Has been cancelled
				
			Ansible Testing / deploy-check (push) Has been cancelled
				
			
		
			
				
	
	
		
			154 lines
		
	
	
		
			3.7 KiB
		
	
	
	
		
			YAML
		
	
	
	
	
	
			
		
		
	
	
			154 lines
		
	
	
		
			3.7 KiB
		
	
	
	
		
			YAML
		
	
	
	
	
	
| # GitLab CI Pipeline для DevOpsLab
 | ||
| # Автор: Сергей Антропов
 | ||
| # Сайт: https://devops.org.ru
 | ||
| 
 | ||
| stages:
 | ||
|   - lint
 | ||
|   - test
 | ||
|   - deploy
 | ||
| 
 | ||
| variables:
 | ||
|   ANSIBLE_FORCE_COLOR: "true"
 | ||
|   DOCKER_TLS_CERTDIR: ""
 | ||
| 
 | ||
| # Стадия 1: Lint проверка
 | ||
| lint:
 | ||
|   stage: lint
 | ||
|   image: python:3.11
 | ||
|   before_script:
 | ||
|     - pip install --upgrade pip
 | ||
|     - pip install ansible ansible-lint
 | ||
|     - ansible-galaxy collection install -r requirements.yml
 | ||
|   script:
 | ||
|     - echo "🔍 Проверка синтаксиса ролей..."
 | ||
|     - make role lint
 | ||
|   artifacts:
 | ||
|     reports:
 | ||
|       junit: .ansible-lint
 | ||
|     paths:
 | ||
|       - .ansible-lint
 | ||
|     expire_in: 1 week
 | ||
| 
 | ||
| # Стадия 2: Тестирование
 | ||
| test_minimal:
 | ||
|   stage: test
 | ||
|   image: docker:latest
 | ||
|   services:
 | ||
|     - docker:dind
 | ||
|   variables:
 | ||
|     DOCKER_TLS_CERTDIR: ""
 | ||
|   before_script:
 | ||
|     - apk add --no-cache make python3 py3-pip
 | ||
|     - pip install --upgrade pip
 | ||
|     - pip install ansible ansible-lint
 | ||
|     - ansible-galaxy collection install -r requirements.yml
 | ||
|     - make docker setup-builder
 | ||
|     - make docker build
 | ||
|   script:
 | ||
|     - echo "🧪 Тестирование с preset: minimal"
 | ||
|     - make role test minimal
 | ||
|   artifacts:
 | ||
|     reports:
 | ||
|       junit: molecule/default/.molecule/reports/junit.xml
 | ||
|     paths:
 | ||
|       - molecule/default/.molecule/
 | ||
|     expire_in: 1 week
 | ||
| 
 | ||
| test_default:
 | ||
|   stage: test
 | ||
|   image: docker:latest
 | ||
|   services:
 | ||
|     - docker:dind
 | ||
|   variables:
 | ||
|     DOCKER_TLS_CERTDIR: ""
 | ||
|   before_script:
 | ||
|     - apk add --no-cache make python3 py3-pip
 | ||
|     - pip install --upgrade pip
 | ||
|     - pip install ansible ansible-lint
 | ||
|     - ansible-galaxy collection install -r requirements.yml
 | ||
|     - make docker setup-builder
 | ||
|     - make docker build
 | ||
|   script:
 | ||
|     - echo "🧪 Тестирование с preset: default"
 | ||
|     - make role test default
 | ||
|   artifacts:
 | ||
|     reports:
 | ||
|       junit: molecule/default/.molecule/reports/junit.xml
 | ||
|     paths:
 | ||
|       - molecule/default/.molecule/
 | ||
|     expire_in: 1 week
 | ||
| 
 | ||
| test_performance:
 | ||
|   stage: test
 | ||
|   image: docker:latest
 | ||
|   services:
 | ||
|     - docker:dind
 | ||
|   variables:
 | ||
|     DOCKER_TLS_CERTDIR: ""
 | ||
|   before_script:
 | ||
|     - apk add --no-cache make python3 py3-pip
 | ||
|     - pip install --upgrade pip
 | ||
|     - pip install ansible ansible-lint
 | ||
|     - ansible-galaxy collection install -r requirements.yml
 | ||
|     - make docker setup-builder
 | ||
|     - make docker build
 | ||
|   script:
 | ||
|     - echo "🧪 Тестирование с preset: performance"
 | ||
|     - make role test performance
 | ||
|   artifacts:
 | ||
|     reports:
 | ||
|       junit: molecule/default/.molecule/reports/junit.xml
 | ||
|     paths:
 | ||
|       - molecule/default/.molecule/
 | ||
|     expire_in: 1 week
 | ||
| 
 | ||
| # Стадия 3: Деплой (только для main ветки)
 | ||
| deploy:
 | ||
|   stage: deploy
 | ||
|   image: python:3.11
 | ||
|   only:
 | ||
|     - main
 | ||
|   before_script:
 | ||
|     - pip install --upgrade pip
 | ||
|     - pip install ansible ansible-lint
 | ||
|     - ansible-galaxy collection install -r requirements.yml
 | ||
|   script:
 | ||
|     - echo "🚀 Проверка развертывания (dry-run)..."
 | ||
|     - mkdir -p inventory
 | ||
|     - |
 | ||
|       cat > inventory/hosts.ini << EOF
 | ||
|       [test_servers]
 | ||
|       localhost ansible_connection=local
 | ||
|       
 | ||
|       [all:vars]
 | ||
|       ansible_python_interpreter=python3
 | ||
|       EOF
 | ||
|     - make role deploy
 | ||
|   artifacts:
 | ||
|     paths:
 | ||
|       - deployment.log
 | ||
|     expire_in: 1 week
 | ||
| 
 | ||
| # Уведомления
 | ||
| notify_success:
 | ||
|   stage: deploy
 | ||
|   image: python:3.11
 | ||
|   only:
 | ||
|     - main
 | ||
|   when: on_success
 | ||
|   script:
 | ||
|     - echo "✅ Все проверки пройдены успешно!"
 | ||
|     - echo "🔍 Lint: Success"
 | ||
|     - echo "🧪 Test: Success"
 | ||
|     - echo "🚀 Deploy: Success"
 | ||
| 
 | ||
| notify_failure:
 | ||
|   stage: deploy
 | ||
|   image: python:3.11
 | ||
|   when: on_failure
 | ||
|   script:
 | ||
|     - echo "❌ Проверки не пройдены!"
 | ||
|     - echo "🔍 Lint: Failed"
 | ||
|     - echo "🧪 Test: Failed"
 | ||
|     - echo "🚀 Deploy: Failed"
 |