Обновить ansible/deploy_all.yml
This commit is contained in:
@@ -3,11 +3,12 @@
|
|||||||
hosts: localhost
|
hosts: localhost
|
||||||
connection: local
|
connection: local
|
||||||
gather_facts: true
|
gather_facts: true
|
||||||
|
vars:
|
||||||
|
tf_dir: "{{ playbook_dir }}/../terraform"
|
||||||
tasks:
|
tasks:
|
||||||
- name: Create terraform mirror config in HOME
|
- name: Create terraform mirror config
|
||||||
copy:
|
copy:
|
||||||
dest: "{{ ansible_user_dir }}/.terraformrc"
|
dest: "{{ ansible_user_dir }}/.terraformrc"
|
||||||
mode: '0644'
|
|
||||||
content: |
|
content: |
|
||||||
provider_installation {
|
provider_installation {
|
||||||
network_mirror {
|
network_mirror {
|
||||||
@@ -20,35 +21,43 @@
|
|||||||
|
|
||||||
- name: Cleanup old terraform data
|
- name: Cleanup old terraform data
|
||||||
file:
|
file:
|
||||||
path: "{{ playbook_dir }}/../terraform/.terraform"
|
path: "{{ tf_dir }}/.terraform"
|
||||||
state: absent
|
state: absent
|
||||||
|
|
||||||
- name: Run Terraform Apply
|
- name: Terraform Init
|
||||||
community.general.terraform:
|
shell: terraform init -reconfigure -no-color
|
||||||
project_path: "{{ playbook_dir }}/../terraform"
|
args:
|
||||||
state: present
|
chdir: "{{ tf_dir }}"
|
||||||
force_init: true
|
environment:
|
||||||
|
TF_CLI_CONFIG_FILE: "{{ ansible_user_dir }}/.terraformrc"
|
||||||
|
# Эти переменные Semaphore должен передать в Ansible
|
||||||
|
TF_HTTP_USERNAME: "{{ lookup('env', 'TF_HTTP_USERNAME') }}"
|
||||||
|
TF_HTTP_PASSWORD: "{{ lookup('env', 'TF_HTTP_PASSWORD') }}"
|
||||||
|
|
||||||
|
- name: Terraform Apply
|
||||||
|
shell: terraform apply -auto-approve -no-color
|
||||||
|
args:
|
||||||
|
chdir: "{{ tf_dir }}"
|
||||||
|
environment:
|
||||||
|
TF_CLI_CONFIG_FILE: "{{ ansible_user_dir }}/.terraformrc"
|
||||||
|
# Передаем токены Proxmox в Terraform
|
||||||
|
TF_VAR_proxmox_api_token_id: "{{ lookup('env', 'TF_VAR_proxmox_api_token_id') }}"
|
||||||
|
TF_VAR_proxmox_api_token_secret: "{{ lookup('env', 'TF_VAR_proxmox_api_token_secret') }}"
|
||||||
|
|
||||||
- name: Wait for SSH to be ready
|
- name: Wait for SSH to be ready
|
||||||
wait_for:
|
wait_for:
|
||||||
host: "{{ item }}"
|
host: "{{ item.value.ip }}"
|
||||||
port: 22
|
port: 22
|
||||||
state: started
|
state: started
|
||||||
timeout: 300
|
timeout: 300
|
||||||
loop:
|
loop: "{{ lookup('dict', vm_nodes | default({})) }}" # Используем переменные из TF если нужно
|
||||||
- 10.33.33.201
|
|
||||||
- 10.33.33.202
|
|
||||||
- 10.33.33.203
|
|
||||||
|
|
||||||
- name: Step 2 - Install Kubernetes
|
- name: Step 2 - Install Kubernetes
|
||||||
hosts: all
|
hosts: all
|
||||||
# Теперь мы переключаемся на реальные сервера.
|
|
||||||
# Чтобы это сработало в одном шаблоне,
|
|
||||||
# в Semaphore должен быть выбран Inventory со всеми хостами,
|
|
||||||
# НО в первом Play мы принудительно используем localhost.
|
|
||||||
become: true
|
become: true
|
||||||
tasks:
|
tasks:
|
||||||
- name: Install base packages
|
- name: Install base packages
|
||||||
apt:
|
apt:
|
||||||
name: [curl, apt-transport-https]
|
name: [curl, apt-transport-https, qemu-guest-agent]
|
||||||
state: present
|
state: present
|
||||||
|
update_cache: yes
|
||||||
Reference in New Issue
Block a user