BrokeDBA

KVM_terraform_plan

May 10th, 2020
187
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 10.16 KB | None | 0 0
  1. ============================================
  2.                  CONFIG
  3. ===========================================
  4. [root@localhost terraform]# terraform -v
  5. Terraform v0.12.24
  6. + provider.libvirt (unversioned)
  7. + provider.template v2.1.2
  8. [root@localhost terraform]# /usr/libexec/qemu-kvm --version
  9. QEMU emulator version 1.5.3 (qemu-kvm-1.5.3-173.el7_8.1), Copyright (c) 2003-2008 Fabrice Bellard
  10.  
  11. ==================================================================================================
  12.  
  13. [root@localhost terraform]# virsh pool-list
  14.  Name                 State      Autostart
  15. -------------------------------------------
  16.  default              active     yes
  17.                                                                                                                                                                                  [root@localhost terraform]# virsh net-list
  18.  Name                 State      Autostart     Persistent
  19. ----------------------------------------------------------
  20.  default              active     yes           yes
  21.  test1                active     yes           yes
  22. ==================================================================================================
  23.                                     TERRAFORM PLAN
  24. ==================================================================================================
  25. [root@localhost terraform]# terraform plan
  26. Refreshing Terraform state in-memory prior to plan...
  27. The refreshed state will be used to calculate this plan, but will not be
  28. persisted to local or remote state storage.
  29.  
  30. data.template_file.user_data: Refreshing state...
  31. data.template_file.network_config: Refreshing state...
  32.  
  33. ------------------------------------------------------------------------
  34.  
  35. An execution plan has been generated and is shown below.
  36. Resource actions are indicated with the following symbols:
  37.   + create
  38.  
  39. Terraform will perform the following actions:
  40.  
  41.   # libvirt_cloudinit_disk.commoninit will be created
  42.   + resource "libvirt_cloudinit_disk" "commoninit" {
  43.       + id             = (known after apply)
  44.       + name           = "commoninit.iso"
  45.       + network_config = <<~EOT
  46.             version: 2
  47.             ethernets:
  48.               ens3:
  49.                  dhcp4: true
  50.         EOT
  51.       + pool           = "default"
  52.       + user_data      = <<~EOT
  53.             # cloud-config
  54.             users:
  55.               - name: ubuntu
  56.                 sudo: ALL=(ALL) NOPASSWD:ALL
  57.                 groups: users, admin
  58.                 home: /home/ubuntu
  59.                 shell: /bin/bash
  60.                 ssh-authorized-keys:
  61.                   - ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDYnZmg #CHANGE_ME
  62.             ssh_pwauth: True
  63.             disable_root: false
  64.             chpasswd:
  65.               list: |
  66.                  ubuntu:linux
  67.               expire: False
  68.             package_update: true
  69.             packages:
  70.                 - qemu-guest-agent
  71.             growpart:
  72.               mode: auto
  73.               devices: ['/']
  74.         EOT
  75.     }
  76.  
  77.   # libvirt_domain.domain-ubuntu will be created
  78.   + resource "libvirt_domain" "domain-ubuntu" {
  79.       + arch        = (known after apply)
  80.       + cloudinit   = (known after apply)
  81.       + disk        = [
  82.           + {
  83.               + block_device = null
  84.               + file         = null
  85.               + scsi         = null
  86.               + url          = null
  87.               + volume_id    = (known after apply)
  88.               + wwn          = null
  89.             },
  90.         ]
  91.       + emulator    = (known after apply)
  92.       + fw_cfg_name = "opt/com.coreos/config"
  93.       + id          = (known after apply)
  94.       + machine     = (known after apply)
  95.       + memory      = 512
  96.       + name        = "terraform-db2"
  97.       + qemu_agent  = false
  98.       + running     = true
  99.       + vcpu        = 1
  100.  
  101.       + console {
  102.           + source_host    = "127.0.0.1"
  103.           + source_service = "0"
  104.           + target_port    = "0"
  105.           + target_type    = "serial"
  106.           + type           = "pty"
  107.         }
  108.       + console {
  109.           + source_host    = "127.0.0.1"
  110.           + source_service = "0"
  111.           + target_port    = "1"
  112.           + target_type    = "virtio"
  113.           + type           = "pty"
  114.         }
  115.  
  116.       + graphics {
  117.           + autoport       = true
  118.           + listen_address = "127.0.0.1"
  119.           + listen_type    = "address"
  120.           + type           = "spice"
  121.         }
  122.  
  123.       + network_interface {
  124.           + addresses    = (known after apply)
  125.           + hostname     = (known after apply)
  126.           + mac          = (known after apply)
  127.           + network_id   = (known after apply)
  128.           + network_name = "terranet"
  129.         }
  130.     }
  131.  
  132.   # libvirt_network.terranet will be created
  133.   + resource "libvirt_network" "terranet" {
  134.       + addresses = [
  135.           + "192.168.78.0/24",
  136.         ]
  137.       + bridge    = (known after apply)
  138.       + id        = (known after apply)
  139.       + mode      = "nat"
  140.       + name      = "terranet"
  141.  
  142.       + dhcp {
  143.           + enabled = true
  144.         }
  145.     }
  146.  
  147.   # libvirt_volume.ubuntu-qcow2 will be created
  148.   + resource "libvirt_volume" "ubuntu-qcow2" {
  149.       + format = "qcow2"
  150.       + id     = (known after apply)
  151.       + name   = "ubuntu-qcow2"
  152.       + pool   = "default"
  153.       + size   = (known after apply)
  154.       + source = "https://cloud-images.ubuntu.com/releases/xenial/release/ubuntu-16.04-server-cloudimg-amd64-disk1.img"
  155.     }
  156.  
  157. Plan: 4 to add, 0 to change, 0 to destroy.
  158.  
  159. ------------------------------------------------------------------------
  160. [root@localhost terraform]# terraform apply
  161. data.template_file.user_data: Refreshing state...
  162. data.template_file.network_config: Refreshing state...
  163.  Enter a value: yes
  164.  
  165. libvirt_volume.ubuntu-qcow2: Creating...
  166. libvirt_network.terranet: Creating...
  167. libvirt_cloudinit_disk.commoninit: Creating...
  168. libvirt_network.terranet: Creation complete after 5s [id=2a48d708-ffd4-4f18-8d2a-2e4ded29b1c7]
  169. libvirt_volume.ubuntu-qcow2: Still creating... [10s elapsed]
  170. libvirt_cloudinit_disk.commoninit: Still creating... [10s elapsed]
  171. libvirt_volume.ubuntu-qcow2: Still creating... [20s elapsed]
  172. libvirt_cloudinit_disk.commoninit: Still creating... [20s elapsed]
  173. libvirt_volume.ubuntu-qcow2: Still creating... [30s elapsed]
  174. libvirt_cloudinit_disk.commoninit: Still creating... [30s elapsed]
  175. libvirt_volume.ubuntu-qcow2: Still creating... [40s elapsed]
  176. libvirt_cloudinit_disk.commoninit: Still creating... [40s elapsed]
  177. libvirt_volume.ubuntu-qcow2: Still creating... [50s elapsed]
  178. libvirt_cloudinit_disk.commoninit: Still creating... [50s elapsed]
  179. libvirt_volume.ubuntu-qcow2: Still creating... [1m0s elapsed]
  180. libvirt_cloudinit_disk.commoninit: Still creating... [1m0s elapsed]
  181. libvirt_volume.ubuntu-qcow2: Still creating... [1m10s elapsed]
  182. libvirt_cloudinit_disk.commoninit: Still creating... [1m10s elapsed]
  183. libvirt_volume.ubuntu-qcow2: Still creating... [1m20s elapsed]
  184. libvirt_cloudinit_disk.commoninit: Still creating... [1m20s elapsed]
  185. libvirt_volume.ubuntu-qcow2: Still creating... [1m30s elapsed]
  186. libvirt_cloudinit_disk.commoninit: Still creating... [1m30s elapsed]
  187. libvirt_volume.ubuntu-qcow2: Still creating... [1m40s elapsed]
  188. libvirt_cloudinit_disk.commoninit: Still creating... [1m40s elapsed]
  189. libvirt_volume.ubuntu-qcow2: Still creating... [1m50s elapsed]
  190. libvirt_cloudinit_disk.commoninit: Still creating... [1m50s elapsed]
  191. libvirt_volume.ubuntu-qcow2: Still creating... [2m0s elapsed]
  192. libvirt_cloudinit_disk.commoninit: Still creating... [2m0s elapsed]
  193. libvirt_volume.ubuntu-qcow2: Still creating... [2m10s elapsed]
  194. libvirt_cloudinit_disk.commoninit: Still creating... [2m10s elapsed]
  195. libvirt_volume.ubuntu-qcow2: Still creating... [2m20s elapsed]
  196. libvirt_cloudinit_disk.commoninit: Still creating... [2m20s elapsed]
  197. libvirt_volume.ubuntu-qcow2: Still creating... [2m30s elapsed]
  198. libvirt_cloudinit_disk.commoninit: Still creating... [2m30s elapsed]
  199. libvirt_volume.ubuntu-qcow2: Still creating... [2m40s elapsed]
  200. libvirt_cloudinit_disk.commoninit: Still creating... [2m40s elapsed]
  201. libvirt_volume.ubuntu-qcow2: Still creating... [2m50s elapsed]
  202. libvirt_cloudinit_disk.commoninit: Still creating... [2m50s elapsed]
  203. libvirt_volume.ubuntu-qcow2: Still creating... [3m0s elapsed]
  204. libvirt_cloudinit_disk.commoninit: Still creating... [3m0s elapsed]
  205. libvirt_volume.ubuntu-qcow2: Creation complete after 3m8s [id=/u01/guest_images/ubuntu-qcow2]
  206. libvirt_cloudinit_disk.commoninit: Creation complete after 3m8s [id=/u01/guest_images/commoninit.iso;5eb8a180-82bc-2de5-f359-c48cba940164]
  207. libvirt_domain.domain-ubuntu: Creating...
  208. libvirt_domain.domain-ubuntu: Creation complete after 1s [id=cf3355ed-ff43-40de-9a5f-318d54b2f5c8]
  209.  
  210. Apply complete! Resources: 4 added, 0 changed, 0 destroyed.
  211. [root@localhost terraform]# kcli list vm
  212. +---------------+--------+----------------+----------------------------------+----------------------+------------+--------+
  213. |      Name     | Status |      Ips       |              Source              |         Plan         |  Profile   | Report |
  214. +---------------+--------+----------------+----------------------------------+----------------------+------------+--------+
  215. |      db2      |   up   | 192.168.122.63 | bionic-server-cloudimg-amd64.img |        kvirt         | ubuntu1804 |        |
  216. | terraform-db2 |  down  |                |                                  |                      |            |        |
  217. |      vm2      |  down  |                |                                  | condescending-jmayer |   kvirt    |        |
  218. +---------------+--------+----------------+----------------------------------+----------------------+------------+--------+
  219. [root@localhost terraform]# kcli list image
  220. +--------------------------------------------------------------------------+
  221. | Images                                                                   |
  222. +--------------------------------------------------------------------------+
  223. | /u01/guest_images/bionic-server-cloudimg-amd64.img                       |
  224. | /u01/guest_images/CentOS-8-GenericCloud-8.1.1911-20200113.3.x86_64.qcow2 |
  225. | /u01/guest_images/ubuntu-qcow2                                           |
  226. +--------------------------------------------------------------------------+
Add Comment
Please, Sign In to add comment