Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Обновление провайдеров и пайплайна #19

Merged
merged 14 commits into from
Dec 20, 2024
Merged
27 changes: 10 additions & 17 deletions .github/workflows/modules.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
name: 'Modules Test Run - Terraform v1.10.2'
name: 'Modules Test Run - Terraform v1.10.3'

on:
schedule:
- cron: '0 8 * * 1' # run every Monday at 11:00 MSK
- cron: '0 8 * * 2' # run every Tuesday at 11:00 MSK
workflow_dispatch:

jobs:
setup:
name: 'Modules Test Run - Terraform v1.10.2'
name: 'Modules Test Run - Terraform v1.10.3'
runs-on: self-hosted
env:
terraform_link: ${{ secrets.TERRAFORM_BINARY_LATEST }}
terraform_link: ${{ secrets.TERRAFORM_BINARY }}
TF_VAR_selectel_domain_name: ${{ secrets.SELECTEL_ID }}
TF_VAR_selectel_user_admin_user: ${{ secrets.SERVICE_USER }}
TF_VAR_selectel_user_admin_password: ${{ secrets.SERVICE_PASSWORD }}
Expand Down Expand Up @@ -62,11 +62,7 @@ jobs:
run: >
terraform init -reconfigure
-backend-config="bucket=github-terraform-state"
-backend-config="endpoint=s3.ru-1.storage.selcloud.ru"
-backend-config="key=github-infra-examples.tfstate"
-backend-config="region=ru-1"
-backend-config="skip_region_validation=true"
-backend-config="skip_credentials_validation=true"
-backend-config="access_key=${{ secrets.S3_ACCESS_KEY }}"
-backend-config="secret_key=${{ secrets.S3_SECRET_KEY }}"

Expand All @@ -76,17 +72,14 @@ jobs:
- name: Terraform destroy
run: terraform destroy -auto-approve

- name: Telegram notify if job was failed
if: ${{ failure() }}
- name: Telegram notify if failed on main branch
if: ${{ (failure()) && (github.ref == 'refs/heads/main') }}
uses: appleboy/telegram-action@master
with:
to: ${{ secrets.TELEGRAM_TO }}
token: ${{ secrets.TELEGRAM_TOKEN }}
message: |
-= GITHUB public repository selectel/selectel-infra-examples =-
Terraform modules build pipeline was failed
🚨 Critical
Не катится пайпа, необходимо принять меры, возможно внутренние пайпы с terraform так же не будут катиться.

⚡️Workflow: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
🔥 See changes: https://github.com/${{ github.repository }}/commit/${{ github.sha }}
⚙️ *GitHub repository selectel/selectel-infra-examples*

🔥 *Pipeline has failed*
➡️ *Workflow:* https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
4 changes: 0 additions & 4 deletions .github/workflows/opentofu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,7 @@ jobs:
run: >
tofu init -reconfigure
-backend-config="bucket=github-terraform-state"
-backend-config="endpoint=s3.ru-1.storage.selcloud.ru"
-backend-config="key=github-infra-examples.tfstate"
-backend-config="region=ru-1"
-backend-config="skip_region_validation=true"
-backend-config="skip_credentials_validation=true"
-backend-config="access_key=${{ secrets.S3_ACCESS_KEY }}"
-backend-config="secret_key=${{ secrets.S3_SECRET_KEY }}"

Expand Down
92 changes: 0 additions & 92 deletions .github/workflows/tf-pre-bsl.yml

This file was deleted.

52 changes: 17 additions & 35 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
# Selectel Terraform Modules Example

| Description | Pipeline Status | Version |
|-------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------|
| Terraform v1.10.2 | [![](https://github.com/selectel/selectel-infra-examples/actions/workflows/modules.yml/badge.svg)](https://github.com/selectel/selectel-infra-examples/actions/workflows/modules.yml) | [![version](https://img.shields.io/badge/Terraform-1.10.2-green.svg)](https://github.com/hashicorp/terraform/releases/tag/v1.10.2) |
| Terraform Pre-BSL | [![](https://github.com/selectel/selectel-infra-examples/actions/workflows/tf-pre-bsl.yml/badge.svg)](https://github.com/selectel/selectel-infra-examples/actions/workflows/tf-pre-bsl.yml) | [![version](https://img.shields.io/badge/Terraform-1.5.7-green.svg)](https://github.com/hashicorp/terraform/releases/tag/v1.5.7) |
| OpenTofu Latest | [![](https://github.com/selectel/selectel-infra-examples/actions/workflows/opentofu.yml/badge.svg)](https://github.com/selectel/selectel-infra-examples/actions/workflows/opentofu.yml) | [![version](https://img.shields.io/badge/OpenTofu-Latest-green.svg)](https://github.com/opentofu/opentofu/releases/latest) |
| | Pipeline Status | Version |
|-------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------|
| Terraform v1.10.3 | [![](https://github.com/selectel/selectel-infra-examples/actions/workflows/modules.yml/badge.svg)](https://github.com/selectel/selectel-infra-examples/actions/workflows/modules.yml) | [![version](https://img.shields.io/badge/Terraform-1.10.3-green.svg)](https://github.com/hashicorp/terraform/releases/tag/v1.10.3) |
| OpenTofu Latest | [![](https://github.com/selectel/selectel-infra-examples/actions/workflows/opentofu.yml/badge.svg)](https://github.com/selectel/selectel-infra-examples/actions/workflows/opentofu.yml) | [![version](https://img.shields.io/badge/OpenTofu-Latest-green.svg)](https://github.com/opentofu/opentofu/releases/latest) |

- [Selectel Terraform Modules Example](#selectel-terraform-modules-example)
- [Использование](#использование)
Expand All @@ -15,19 +14,17 @@
- [Структура репозитория](#структура-репозитория)
- [Modules](#modules)

В [данном репозитории](https://github.com/selectel/selectel-infra-examples) находятся примеры Terraform модулей, используемых для создания инфраструктуры в облаке Selectel. Также в репозитории еженедельно запускаются пайплайны с тестовым созданием ресурсов с помощью **Terraform** и **OpenTofu**.
В [данном репозитории](https://github.com/selectel/selectel-infra-examples) находятся примеры Terraform модулей, используемых для создания инфраструктуры в облаке Selectel. Также в репозитории еженедельно запускаются пайплайны с тестовым созданием ресурсов с помощью **Terraform** и **OpenTofu**.

**P.S.** Если вы не нашли пример для создания определенного ресурса - можете оставить issue и мы примем во внимание необходимость его добавления.

Перед началом работы с облачными ресурсами Selectel через Terraform/OpenTofu рекомендуем ознакомиться с [документацией по провайдеру Selectel/OpenStack](https://docs.selectel.ru/terraform/).

## Использование

> Далее все команды terraform-cli могут быть заменены на tofu. Будут работать оба варианта.
> Все последующие команды terraform-cli могут быть заменены на opentofu.
>
> Перед использованием **проверьте версию Terraform/OpenTofu**, данный репозиторий гарантирует запуск Terraform кода только на определенной версии Terraform/OpenTofu - [см. в шапке README](#selectel-terraform-modules-example). Версия Terraform 1.5.5 обусловлена переходом начиная с версии 1.6 на лицензию BSL.
>
> Также убедитесь, что в вашем env нет лишних переменных вида "OS_*", их наличие повлияет на провайдер Openstack.
> Убедитесь, что в вашем env нет лишних переменных вида "OS_*", их наличие повлияет на провайдер Openstack.

### 1. .terraformrc/.tofurc

Expand All @@ -53,41 +50,26 @@ terraform {
}
```

<details>
<summary>Пример передачи `backend` для хранения стейта в S3 через CLI:</summary>

```bash
terraform init \
-backend-config="bucket=< имя бакета s3 >" \
-backend-config="endpoint=s3.ru-1.storage.selcloud.ru" \
-backend-config="key=< имя стейт-файла >.tfstate" \
-backend-config="region=ru-1" \
-backend-config="skip_region_validation=true" \
-backend-config="skip_credentials_validation=true" \
-backend-config="access_key=< S3_ACCESS_KEY >" \
-backend-config="secret_key=< secrets.S3_SECRET_KEY >"
```
</details>

<details>
<summary>Через tf файл:</summary>
Пример передачи `backend` для хранения стейта в S3:

```terraform
terraform {
backend "s3" {
bucket = "< имя бакета s3 >"
endpoint = "s3.ru-1.storage.selcloud.ru"
key = "< имя стейт-файла >.tfstate"
bucket = "<название бакета s3>"
key = "<название стейт-файла>.tfstate"
access_key = "<access_key>"
secret_key = "<secret_key>"
endpoints = { s3 = "https://s3.ru-1.storage.selcloud.ru" }
region = "ru-1"
access_key = "< S3_ACCESS_KEY >"
secret_key = "< secrets.S3_SECRET_KEY >"


skip_region_validation = true
skip_credentials_validation = true
skip_requesting_account_id = true
skip_s3_checksum = true
skip_metadata_api_check = true
}
}
```
</details>

### 3. Init

Expand Down
11 changes: 5 additions & 6 deletions README_TF.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,15 @@

| Name | Version |
|------|---------|
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.0.0, <= 1.6.2 |
| <a name="requirement_openstack"></a> [openstack](#requirement\_openstack) | 1.53.0 |
| <a name="requirement_selectel"></a> [selectel](#requirement\_selectel) | 5.1.1 |
| <a name="requirement_openstack"></a> [openstack](#requirement\_openstack) | 3.0.0 |
| <a name="requirement_selectel"></a> [selectel](#requirement\_selectel) | 6.0.1 |

## Providers

| Name | Version |
|------|---------|
| <a name="provider_openstack"></a> [openstack](#provider\_openstack) | 1.53.0 |
| <a name="provider_selectel"></a> [selectel](#provider\_selectel) | 5.1.1 |
| <a name="provider_openstack"></a> [openstack](#provider\_openstack) | 3.0.0 |
| <a name="provider_selectel"></a> [selectel](#provider\_selectel) | 6.0.1 |

## Modules

Expand All @@ -38,7 +37,7 @@

| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| <a name="input_flavor_name"></a> [flavor\_name](#input\_flavor\_name) | Название флавора | `string` | n/a | yes |
| <a name="input_flavor_name"></a> [flavor\_name](#input\_flavor\_name) | Название флавора | `string` | `"1013"` | no |
| <a name="input_os_auth_url"></a> [os\_auth\_url](#input\_os\_auth\_url) | URL до openstack api | `string` | `"https://cloud.api.selcloud.ru/identity/v3"` | no |
| <a name="input_selectel_domain_name"></a> [selectel\_domain\_name](#input\_selectel\_domain\_name) | ID Selectel аккаунта | `string` | n/a | yes |
| <a name="input_selectel_user_admin_password"></a> [selectel\_user\_admin\_password](#input\_selectel\_user\_admin\_password) | Пароль от сервисного пользователя | `string` | n/a | yes |
Expand Down
4 changes: 2 additions & 2 deletions modules/craas/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@

| Name | Version |
|------|---------|
| <a name="requirement_selectel"></a> [selectel](#requirement\_selectel) | >=5.0.2 |
| <a name="requirement_selectel"></a> [selectel](#requirement\_selectel) | ~> 6.0.0 |

## Providers

| Name | Version |
|------|---------|
| <a name="provider_selectel"></a> [selectel](#provider\_selectel) | >=5.0.2 |
| <a name="provider_selectel"></a> [selectel](#provider\_selectel) | ~> 6.0.0 |

## Modules

Expand Down
2 changes: 1 addition & 1 deletion modules/craas/versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ terraform {
required_providers {
selectel = {
source = "registry.terraform.io/selectel/selectel"
version = ">=5.0.2"
version = "~> 6.0.0"
}
}
}
4 changes: 2 additions & 2 deletions modules/flavor/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@

| Name | Version |
|------|---------|
| <a name="requirement_openstack"></a> [openstack](#requirement\_openstack) | 1.53.0 |
| <a name="requirement_openstack"></a> [openstack](#requirement\_openstack) | ~> 3.0.0 |

## Providers

| Name | Version |
|------|---------|
| <a name="provider_openstack"></a> [openstack](#provider\_openstack) | 1.53.0 |
| <a name="provider_openstack"></a> [openstack](#provider\_openstack) | ~> 3.0.0 |

## Modules

Expand Down
2 changes: 1 addition & 1 deletion modules/flavor/versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ terraform {
required_providers {
openstack = {
source = "registry.terraform.io/terraform-provider-openstack/openstack"
version = "1.53.0"
version = "~> 3.0.0"
}
}
}
4 changes: 2 additions & 2 deletions modules/floatingip/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@

| Name | Version |
|------|---------|
| <a name="requirement_openstack"></a> [openstack](#requirement\_openstack) | 1.53.0 |
| <a name="requirement_openstack"></a> [openstack](#requirement\_openstack) | ~> 3.0.0 |

## Providers

| Name | Version |
|------|---------|
| <a name="provider_openstack"></a> [openstack](#provider\_openstack) | 1.53.0 |
| <a name="provider_openstack"></a> [openstack](#provider\_openstack) | ~> 3.0.0 |

## Modules

Expand Down
2 changes: 1 addition & 1 deletion modules/floatingip/versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ terraform {
required_providers {
openstack = {
source = "registry.terraform.io/terraform-provider-openstack/openstack"
version = "1.53.0"
version = "~> 3.0.0"
}
}
}
4 changes: 2 additions & 2 deletions modules/image_datasource/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@

| Name | Version |
|------|---------|
| <a name="requirement_openstack"></a> [openstack](#requirement\_openstack) | 1.53.0 |
| <a name="requirement_openstack"></a> [openstack](#requirement\_openstack) | ~> 3.0.0 |

## Providers

| Name | Version |
|------|---------|
| <a name="provider_openstack"></a> [openstack](#provider\_openstack) | 1.53.0 |
| <a name="provider_openstack"></a> [openstack](#provider\_openstack) | ~> 3.0.0 |

## Modules

Expand Down
2 changes: 1 addition & 1 deletion modules/image_datasource/versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ terraform {
required_providers {
openstack = {
source = "registry.terraform.io/terraform-provider-openstack/openstack"
version = "1.53.0"
version = "~> 3.0.0"
}
}
}
4 changes: 2 additions & 2 deletions modules/keypair/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@

| Name | Version |
|------|---------|
| <a name="requirement_openstack"></a> [openstack](#requirement\_openstack) | 1.53.0 |
| <a name="requirement_openstack"></a> [openstack](#requirement\_openstack) | ~> 3.0.0 |

## Providers

| Name | Version |
|------|---------|
| <a name="provider_openstack"></a> [openstack](#provider\_openstack) | 1.53.0 |
| <a name="provider_openstack"></a> [openstack](#provider\_openstack) | ~> 3.0.0 |

## Modules

Expand Down
Loading
Loading