Files
IaC/ansible/deploy_all.yml

51 lines
1.7 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 # Это важно, чтобы получить путь к HOME
tasks:
- name: Create terraform mirror config in HOME
copy:
dest: "{{ ansible_user_dir }}/.terraformrc"
mode: '0644'
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 # Это уберет ошибку "Backend initialization required"
# Environment больше не нужен, Terraform сам найдет ~/.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