From 55537f87083a72a4fbb36412e8a809362d780401 Mon Sep 17 00:00:00 2001 From: svs1370 <34687689+svs1370@users.noreply.github.com> Date: Wed, 13 May 2020 17:00:13 +0300 Subject: [PATCH] =?UTF-8?q?Created=2002.=20=D0=9A=D0=BE=D1=80=D0=BE=D1=87?= =?UTF-8?q?=D0=B5,=20=D0=A1=D0=BA=D0=BB=D0=B8=D1=84=D0=BE=D1=81=D0=BE?= =?UTF-8?q?=D1=84=D1=81=D0=BA=D0=B8=D0=B9!=20(markdown)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...ороче,-Склифософский!.md | 77 +++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 02.-Короче,-Склифософский!.md diff --git a/02.-Короче,-Склифософский!.md b/02.-Короче,-Склифософский!.md new file mode 100644 index 0000000..d73c56d --- /dev/null +++ b/02.-Короче,-Склифософский!.md @@ -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 +... +``` \ No newline at end of file