Created 02. Короче, Склифософский! (markdown)
77
02.-Короче,-Склифософский!.md
Normal file
77
02.-Короче,-Склифософский!.md
Normal file
@@ -0,0 +1,77 @@
|
||||
# «Короче, Склифосовский!»
|
||||
Данный раздел предназначен для тех, кто хорошо знаком с системой Ansible, а также имеет представление об основных понятиях и способах авторизации в облачной платформе DECORT.
|
||||
|
||||
Ниже приведен пример Ansible playbook, который создает виртуальный сервер, дополняет _in-memory inventory_ информацией о только что созданном сервере и выполняет простейшую команду на уровне его гостевой ОС.
|
||||
|
||||
```
|
||||
---
|
||||
- hosts: ansible_master
|
||||
tasks:
|
||||
- name: obtain access token to streamline further module's execution
|
||||
decort_jwt:
|
||||
delegate_to: localhost
|
||||
|
||||
- name: obtain OS image to use for the new VM
|
||||
decort_osimage:
|
||||
delegate_to: localhost
|
||||
|
||||
- name: obtain resource group to create the new VM in
|
||||
decort_rg:
|
||||
delegate_to: localhost
|
||||
|
||||
- name: obtain virtual network segment to attach the new VM to
|
||||
decort_vins:
|
||||
delegate_to: localhost
|
||||
|
||||
- name: provision extra data disk for the new VM
|
||||
decort_disk:
|
||||
delegate_to: localhost
|
||||
|
||||
- name: provision x86 KVM VM with one extra data disk attached and connected to two networks
|
||||
decort_kvmvm:
|
||||
authenticator: oauth2
|
||||
app_id: "{{ my_app_id }}"
|
||||
app_secret: "{{ my_app_secret }}"
|
||||
oauth2_url: https://sso.digitalenergy.online
|
||||
controller_url: "https://ds1.digitalenergy.online"
|
||||
name: MyFirstVM
|
||||
arch: KVM_X86
|
||||
state: present
|
||||
cpu: 2
|
||||
ram: 4096
|
||||
boot_disk:
|
||||
size: 10
|
||||
image_name: "Ubuntu 16.04"
|
||||
data_disks:
|
||||
- id: "MyFirstVM-dd01"
|
||||
size:
|
||||
networks:
|
||||
- type: VINS
|
||||
id: 15
|
||||
- type: EXTERNAL
|
||||
id: 2
|
||||
tenant_name: "MyTenant"
|
||||
rg_name: "MyMainRG"
|
||||
annotation: "My 1st VM created and managed with DECORT KVMVM module"
|
||||
delegate_to: localhost
|
||||
register: new_vm
|
||||
|
||||
- name: add new VM to the in-memory inventory into group just_created
|
||||
add_host:
|
||||
groups: just_created
|
||||
hostname: "{{ new_vm.vm_facts.name }}"
|
||||
ansible_host: "{{ new_vm.vm_facts.vdc_ext_ip }}"
|
||||
ansible_port: 21022
|
||||
ansible_user: "{{ new_vm.vm_facts.username }}"
|
||||
ansible_password: "{{ new_vm.vm_facts.password }}"
|
||||
|
||||
- name: configure network port forward rules for the newly created VM
|
||||
decort_pfw:
|
||||
delegate_to: localhost
|
||||
|
||||
- hosts: just_created
|
||||
tasks:
|
||||
- name: check connectivity to the new VM by running a remote command on it
|
||||
command: uname –a
|
||||
...
|
||||
```
|
||||
Reference in New Issue
Block a user