Files
IaC/ansible/deploy_all.yml

52 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: false
tasks:
- name: Create terraform mirror config locally
copy:
dest: "{{ playbook_dir }}/../terraform/.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:
# Указываем Terraform искать конфиг именно здесь
TF_CLI_CONFIG_FILE: "{{ playbook_dir }}/../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