Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ============================================
- CONFIG
- ===========================================
- [root@localhost terraform]# terraform -v
- Terraform v0.12.24
- + provider.libvirt (unversioned)
- + provider.template v2.1.2
- [root@localhost terraform]# /usr/libexec/qemu-kvm --version
- QEMU emulator version 1.5.3 (qemu-kvm-1.5.3-173.el7_8.1), Copyright (c) 2003-2008 Fabrice Bellard
- ==================================================================================================
- [root@localhost terraform]# virsh pool-list
- Name State Autostart
- -------------------------------------------
- default active yes
- [root@localhost terraform]# virsh net-list
- Name State Autostart Persistent
- ----------------------------------------------------------
- default active yes yes
- test1 active yes yes
- ==================================================================================================
- TERRAFORM PLAN
- ==================================================================================================
- [root@localhost terraform]# terraform plan
- Refreshing Terraform state in-memory prior to plan...
- The refreshed state will be used to calculate this plan, but will not be
- persisted to local or remote state storage.
- data.template_file.user_data: Refreshing state...
- data.template_file.network_config: Refreshing state...
- ------------------------------------------------------------------------
- An execution plan has been generated and is shown below.
- Resource actions are indicated with the following symbols:
- + create
- Terraform will perform the following actions:
- # libvirt_cloudinit_disk.commoninit will be created
- + resource "libvirt_cloudinit_disk" "commoninit" {
- + id = (known after apply)
- + name = "commoninit.iso"
- + network_config = <<~EOT
- version: 2
- ethernets:
- ens3:
- dhcp4: true
- EOT
- + pool = "default"
- + user_data = <<~EOT
- # cloud-config
- users:
- - name: ubuntu
- sudo: ALL=(ALL) NOPASSWD:ALL
- groups: users, admin
- home: /home/ubuntu
- shell: /bin/bash
- ssh-authorized-keys:
- - ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDYnZmg #CHANGE_ME
- ssh_pwauth: True
- disable_root: false
- chpasswd:
- list: |
- ubuntu:linux
- expire: False
- package_update: true
- packages:
- - qemu-guest-agent
- growpart:
- mode: auto
- devices: ['/']
- EOT
- }
- # libvirt_domain.domain-ubuntu will be created
- + resource "libvirt_domain" "domain-ubuntu" {
- + arch = (known after apply)
- + cloudinit = (known after apply)
- + disk = [
- + {
- + block_device = null
- + file = null
- + scsi = null
- + url = null
- + volume_id = (known after apply)
- + wwn = null
- },
- ]
- + emulator = (known after apply)
- + fw_cfg_name = "opt/com.coreos/config"
- + id = (known after apply)
- + machine = (known after apply)
- + memory = 512
- + name = "terraform-db2"
- + qemu_agent = false
- + running = true
- + vcpu = 1
- + console {
- + source_host = "127.0.0.1"
- + source_service = "0"
- + target_port = "0"
- + target_type = "serial"
- + type = "pty"
- }
- + console {
- + source_host = "127.0.0.1"
- + source_service = "0"
- + target_port = "1"
- + target_type = "virtio"
- + type = "pty"
- }
- + graphics {
- + autoport = true
- + listen_address = "127.0.0.1"
- + listen_type = "address"
- + type = "spice"
- }
- + network_interface {
- + addresses = (known after apply)
- + hostname = (known after apply)
- + mac = (known after apply)
- + network_id = (known after apply)
- + network_name = "terranet"
- }
- }
- # libvirt_network.terranet will be created
- + resource "libvirt_network" "terranet" {
- + addresses = [
- + "192.168.78.0/24",
- ]
- + bridge = (known after apply)
- + id = (known after apply)
- + mode = "nat"
- + name = "terranet"
- + dhcp {
- + enabled = true
- }
- }
- # libvirt_volume.ubuntu-qcow2 will be created
- + resource "libvirt_volume" "ubuntu-qcow2" {
- + format = "qcow2"
- + id = (known after apply)
- + name = "ubuntu-qcow2"
- + pool = "default"
- + size = (known after apply)
- + source = "https://cloud-images.ubuntu.com/releases/xenial/release/ubuntu-16.04-server-cloudimg-amd64-disk1.img"
- }
- Plan: 4 to add, 0 to change, 0 to destroy.
- ------------------------------------------------------------------------
- [root@localhost terraform]# terraform apply
- data.template_file.user_data: Refreshing state...
- data.template_file.network_config: Refreshing state...
- Enter a value: yes
- libvirt_volume.ubuntu-qcow2: Creating...
- libvirt_network.terranet: Creating...
- libvirt_cloudinit_disk.commoninit: Creating...
- libvirt_network.terranet: Creation complete after 5s [id=2a48d708-ffd4-4f18-8d2a-2e4ded29b1c7]
- libvirt_volume.ubuntu-qcow2: Still creating... [10s elapsed]
- libvirt_cloudinit_disk.commoninit: Still creating... [10s elapsed]
- libvirt_volume.ubuntu-qcow2: Still creating... [20s elapsed]
- libvirt_cloudinit_disk.commoninit: Still creating... [20s elapsed]
- libvirt_volume.ubuntu-qcow2: Still creating... [30s elapsed]
- libvirt_cloudinit_disk.commoninit: Still creating... [30s elapsed]
- libvirt_volume.ubuntu-qcow2: Still creating... [40s elapsed]
- libvirt_cloudinit_disk.commoninit: Still creating... [40s elapsed]
- libvirt_volume.ubuntu-qcow2: Still creating... [50s elapsed]
- libvirt_cloudinit_disk.commoninit: Still creating... [50s elapsed]
- libvirt_volume.ubuntu-qcow2: Still creating... [1m0s elapsed]
- libvirt_cloudinit_disk.commoninit: Still creating... [1m0s elapsed]
- libvirt_volume.ubuntu-qcow2: Still creating... [1m10s elapsed]
- libvirt_cloudinit_disk.commoninit: Still creating... [1m10s elapsed]
- libvirt_volume.ubuntu-qcow2: Still creating... [1m20s elapsed]
- libvirt_cloudinit_disk.commoninit: Still creating... [1m20s elapsed]
- libvirt_volume.ubuntu-qcow2: Still creating... [1m30s elapsed]
- libvirt_cloudinit_disk.commoninit: Still creating... [1m30s elapsed]
- libvirt_volume.ubuntu-qcow2: Still creating... [1m40s elapsed]
- libvirt_cloudinit_disk.commoninit: Still creating... [1m40s elapsed]
- libvirt_volume.ubuntu-qcow2: Still creating... [1m50s elapsed]
- libvirt_cloudinit_disk.commoninit: Still creating... [1m50s elapsed]
- libvirt_volume.ubuntu-qcow2: Still creating... [2m0s elapsed]
- libvirt_cloudinit_disk.commoninit: Still creating... [2m0s elapsed]
- libvirt_volume.ubuntu-qcow2: Still creating... [2m10s elapsed]
- libvirt_cloudinit_disk.commoninit: Still creating... [2m10s elapsed]
- libvirt_volume.ubuntu-qcow2: Still creating... [2m20s elapsed]
- libvirt_cloudinit_disk.commoninit: Still creating... [2m20s elapsed]
- libvirt_volume.ubuntu-qcow2: Still creating... [2m30s elapsed]
- libvirt_cloudinit_disk.commoninit: Still creating... [2m30s elapsed]
- libvirt_volume.ubuntu-qcow2: Still creating... [2m40s elapsed]
- libvirt_cloudinit_disk.commoninit: Still creating... [2m40s elapsed]
- libvirt_volume.ubuntu-qcow2: Still creating... [2m50s elapsed]
- libvirt_cloudinit_disk.commoninit: Still creating... [2m50s elapsed]
- libvirt_volume.ubuntu-qcow2: Still creating... [3m0s elapsed]
- libvirt_cloudinit_disk.commoninit: Still creating... [3m0s elapsed]
- libvirt_volume.ubuntu-qcow2: Creation complete after 3m8s [id=/u01/guest_images/ubuntu-qcow2]
- libvirt_cloudinit_disk.commoninit: Creation complete after 3m8s [id=/u01/guest_images/commoninit.iso;5eb8a180-82bc-2de5-f359-c48cba940164]
- libvirt_domain.domain-ubuntu: Creating...
- libvirt_domain.domain-ubuntu: Creation complete after 1s [id=cf3355ed-ff43-40de-9a5f-318d54b2f5c8]
- Apply complete! Resources: 4 added, 0 changed, 0 destroyed.
- [root@localhost terraform]# kcli list vm
- +---------------+--------+----------------+----------------------------------+----------------------+------------+--------+
- | Name | Status | Ips | Source | Plan | Profile | Report |
- +---------------+--------+----------------+----------------------------------+----------------------+------------+--------+
- | db2 | up | 192.168.122.63 | bionic-server-cloudimg-amd64.img | kvirt | ubuntu1804 | |
- | terraform-db2 | down | | | | | |
- | vm2 | down | | | condescending-jmayer | kvirt | |
- +---------------+--------+----------------+----------------------------------+----------------------+------------+--------+
- [root@localhost terraform]# kcli list image
- +--------------------------------------------------------------------------+
- | Images |
- +--------------------------------------------------------------------------+
- | /u01/guest_images/bionic-server-cloudimg-amd64.img |
- | /u01/guest_images/CentOS-8-GenericCloud-8.1.1911-20200113.3.x86_64.qcow2 |
- | /u01/guest_images/ubuntu-qcow2 |
- +--------------------------------------------------------------------------+
Add Comment
Please, Sign In to add comment