Update variable
This commit is contained in:
@@ -2,10 +2,6 @@
|
|||||||
- name: Deploy Monitoring on general_server
|
- name: Deploy Monitoring on general_server
|
||||||
hosts: general_server
|
hosts: general_server
|
||||||
become: yes
|
become: yes
|
||||||
vars_files:
|
|
||||||
- group_vars/all/vars.yml
|
|
||||||
- group_vars/all/vault.yml
|
|
||||||
|
|
||||||
tasks:
|
tasks:
|
||||||
- name: Создание системного юзера
|
- name: Создание системного юзера
|
||||||
ansible.builtin.user:
|
ansible.builtin.user:
|
||||||
@@ -69,10 +65,6 @@
|
|||||||
- name: Deploy Exporter on other servers
|
- name: Deploy Exporter on other servers
|
||||||
hosts: all
|
hosts: all
|
||||||
become: yes
|
become: yes
|
||||||
vars_files:
|
|
||||||
- group_vars/all/vars.yml
|
|
||||||
- group_vars/all/vault.yml
|
|
||||||
|
|
||||||
tasks:
|
tasks:
|
||||||
- name: Создание системного юзера
|
- name: Создание системного юзера
|
||||||
ansible.builtin.user:
|
ansible.builtin.user:
|
||||||
@@ -80,12 +72,6 @@
|
|||||||
state: present
|
state: present
|
||||||
shell: /usr/sbin/nologin
|
shell: /usr/sbin/nologin
|
||||||
|
|
||||||
- name: Установить понятное имя хоста с индексом
|
|
||||||
ansible.builtin.hostname:
|
|
||||||
name: "node-{{ ansible_play_hosts.index(inventory_hostname) }}"
|
|
||||||
when: ansible_play_hosts.index(inventory_hostname) > 0
|
|
||||||
notify: restart node-exporter
|
|
||||||
|
|
||||||
- name: Создать директории для проекта
|
- name: Создать директории для проекта
|
||||||
ansible.builtin.file:
|
ansible.builtin.file:
|
||||||
path: "{{ monitoring_dir }}"
|
path: "{{ monitoring_dir }}"
|
||||||
|
|||||||
+11
-5
@@ -14,21 +14,21 @@ resource "yandex_vpc_subnet" "main_subnet" {
|
|||||||
}
|
}
|
||||||
|
|
||||||
resource "yandex_compute_instance" "server" {
|
resource "yandex_compute_instance" "server" {
|
||||||
count = 5
|
count = var.instance_count
|
||||||
|
|
||||||
name = "server_${count.index + 1}"
|
name = "server_${count.index + 1}"
|
||||||
platform_id = "standard-v3"
|
platform_id = "standard-v3"
|
||||||
zone = "ru-central1-a"
|
zone = "ru-central1-a"
|
||||||
|
|
||||||
resources {
|
resources {
|
||||||
cores = 2
|
cores = var.cores
|
||||||
memory = 2
|
memory = var.memory
|
||||||
}
|
}
|
||||||
|
|
||||||
boot_disk {
|
boot_disk {
|
||||||
initialize_params {
|
initialize_params {
|
||||||
image_id = data.yandex_compute_image.ubuntu.id
|
image_id = data.yandex_compute_image.ubuntu.id
|
||||||
size = 15
|
size = var.size
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -38,7 +38,12 @@ resource "yandex_compute_instance" "server" {
|
|||||||
}
|
}
|
||||||
|
|
||||||
metadata = {
|
metadata = {
|
||||||
ssh-keys = "ubuntu:${file("~/.ssh/ssh-key-1789658954721.pub")}"
|
ssh-keys = "ubuntu:${file(pathexpand(var.key))}"
|
||||||
|
user-data = <<-EOF
|
||||||
|
#!/bin/bash
|
||||||
|
echo "PasswordAuthentication no" > /etc/ssh/sshd_config.d/01-disable-pw.conf
|
||||||
|
systemctl reload ssh
|
||||||
|
EOF
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -46,3 +51,4 @@ output "public_ips" {
|
|||||||
description = "Публичные IP адреса созданных серверов"
|
description = "Публичные IP адреса созданных серверов"
|
||||||
value = yandex_compute_instance.server[*].network_interface.0.nat_ip_address
|
value = yandex_compute_instance.server[*].network_interface.0.nat_ip_address
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,25 @@
|
|||||||
|
variable "instance_count" {
|
||||||
|
type = number
|
||||||
|
description = "Количество инстансов"
|
||||||
|
default = 5
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "cores" {
|
||||||
|
type = number
|
||||||
|
default = 2
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "memory" {
|
||||||
|
type = number
|
||||||
|
default = 2
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "size" {
|
||||||
|
type = number
|
||||||
|
default = 20
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "key" {
|
||||||
|
type = string
|
||||||
|
default = "~/.ssh/ssh-key-1789658954721.pub"
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user