ControlVM: sudo apt-get install -y ansible mkdir ansible vim ~/bin/main.tf data "template_file" "inventory" {
template = file("./_templates/inventory.tpl")
vars = {
user = "altlinux"
web1 = join("", [yandex_compute_instance.web1.name, " ansible_host=", yandex_compute_instance.web1.network_interface.0.nat_ip_address])
web2 = join("", [yandex_compute_instance.web2.name, " ansible_host=", yandex_compute_instance.web2.network_interface.0.nat_ip_address])
}
}
resource "local_file" "save_inventory" {
content = data.template_file.inventory.rendered
filename = "/home/altlinux/ansible/inventory"
} mkdir ~/bin/_templates/ vim ~/bin/_templates/inventory.tpl ${web1}
${web2}
[all:vars]
ansible_user = ${user}
ansible_ssh_extra_args = '-o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no'
ansible_python_interpreter = /usr/bin/python3 vim ~/ansible/playbook.yml ---
- hosts: all
remote_user: altlinux
become: true
tasks:
- name: Install d