# Yandex IaC solutions

## Yandex IaC solutions

<https://github.com/patsevanton/yandex-iac-ansible-example>

[yandex-iac-ansible-example](https://gitlab.com/johnmkane/tech-recipe-book/-/blob/main/Book/Architect/Infrastructure%20As%20a%20Code/Yandex%20IaC%20solutions/Yandex%20IaC%20solutions/yandex-iac-ansible-example/README.md)

## infrastructure-as-a-code-example

Examples of infrastructure as code tools include Yandex Cloud, Terraform and Ansible. Terraform code don\`t use managed service in Yandex Cloud.

### Install YC cli

```
curl https://storage.yandexcloud.net/yandexcloud-yc/install.sh | bash

```

### Init YC cli

```
yc init

```

### Get token, cloud-id, folder-id

```
yc config list

```

Output:

```
token: xxx
cloud-id: xxx
folder-id: xxxx
compute-default-zone: ru-central1-b

```

## Terraform

### Set up terraform

#### Download terraform <https://hashicorp-releases.yandexcloud.net/terraform/>

```
unzip terraform_1.2.4_linux_amd64.zip
sudo mv terraform /usr/local/bin/

```

#### Set terraform mirror

```
nano ~/.terraformrc

```

with code

```
provider_installation {
  network_mirror {
    url = "https://terraform-mirror.yandexcloud.net/"
    include = ["registry.terraform.io/*/*"]
  }
  direct {
    exclude = ["registry.terraform.io/*/*"]
  }
}

```

#### terraform fmt for private.auto.tfvars.example

```
find . -iname 'private.auto.tfvars.example' -execdir mv -i '{}' private.auto1.tfvars \;
terraform fmt -recursive
find . -iname 'private.auto1.tfvars' -execdir mv -i '{}' private.auto.tfvars.example \;

```

## Ansible

### Install Ansible

```
sudo add-apt-repository ppa:ansible/ansible
sudo apt update
sudo apt install ansible

```

### Setting for ubuntu 22.04

```
sudo apt install python3-resolvelib=0.5.4-1ppa~jammy
sudo apt-mark hold python3-resolvelib

```

## SSH

```
cat .ssh/config
Host *
    StrictHostKeyChecking no
    ServerAliveInterval 5
    HashKnownHosts no

```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://book.konstantinsecurity.com/readme/architect/infrastructure-as-a-code/yandex-iac-solutions.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
