Files
IaC/ansible/deploy_all.yml

52 lines
1.6 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.
---
- name: Step 1 - Terraform Provisioning
hosts: localhost
connection: local
gather_facts: true # Включаем сбор фактов, чтобы знать домашнюю директорию
tasks:
- name: Create terraform mirror config in /tmp
copy:
dest: "/tmp/.terraformrc"
content: |
provider_installation {
network_mirror {
url = "https://terraform-mirror.yandexcloud.net/"
}
direct {
exclude = ["registry.terraform.io/*/*"]
}
}
- name: Run Terraform Apply
community.general.terraform:
project_path: "{{ playbook_dir }}/../terraform"
state: present
force_init: true
init_reconfigure: true
environment:
# Используем жесткий абсолютный путь
TF_CLI_CONFIG_FILE: "/tmp/.terraformrc"
- name: Wait for SSH to be ready
wait_for:
host: "{{ item }}"
port: 22
state: started
timeout: 300
loop:
- 10.33.33.201
- 10.33.33.202
- 10.33.33.203
- name: Step 2 - Install Kubernetes
hosts: all
# Теперь мы переключаемся на реальные сервера.
# Чтобы это сработало в одном шаблоне,
# в Semaphore должен быть выбран Inventory со всеми хостами,
# НО в первом Play мы принудительно используем localhost.
become: true
tasks:
- name: Install base packages
apt:
name: [curl, apt-transport-https]
state: present