|
1 |
| -Deploy Red Hat KVM Image using cloud-init |
2 |
| -========= |
| 1 | +deploy-kvm-vm |
| 2 | +============= |
| 3 | +This role deploys a Libvirt KVM instance from a qcow image |
3 | 4 |
|
4 |
| -The following role will deploy a Red Hat Enterprise Linux 7.x KVM. |
| 5 | +Tested deployments: |
| 6 | + - Red Hat Enterprise Linux 7/8 |
| 7 | + - Fedora 32 |
5 | 8 |
|
6 | 9 | Requirements
|
7 | 10 | ------------
|
8 | 11 | * kvm packages are installed
|
9 | 12 |
|
10 | 13 | Role Variables
|
11 | 14 | --------------
|
12 |
| - |
13 |
| -|Variables |Required |Default |Description | |
14 |
| -|-------------------------------------------------------|------------------|---------------------|-------------------------------------------------------------------------------------------------------| |
15 |
| -|admin_user |x |admin |User cloud-init creates | |
16 |
| -|admin_user_password |:heavy_check_mark:|see defaults/main.yml|Password for the cloud-init user | |
17 |
| -|cidata_iso_name |x |cidata.iso |name of the iso created for cloud-init | |
18 |
| -|cloud_init_iso_image |x |see defaults/main.yml|full path where the cloud-init iso is stored | |
19 |
| -|cloud_init_meta_data |x |see defaults/main.yml|full path to cloud-init meta data file | |
20 |
| -|cloud_init_user_data |x |see defaults/main.yml|full path to cloud-init user data file | |
21 |
| -|cloud_init_vm_image | | |name of the qcow OS iso | |
22 |
| -|disk_opt |x |see defaults/main.yml|options to pass to qemu-img | |
23 |
| -|disk_sequence | |see defaults/main.yml|template to generate disk device names, e.g. vdc | |
24 |
| -|dns_servers | | |dns servers for /etc/resolv manged by cloud-init | |
25 |
| -|extra_disk_name | | |generated prefix for extra disk name | |
26 |
| -|extra_storage | | |dictionary of extra disk, see defaults/main.yml | |
27 |
| -|kvm_install_host | |localhost |kvm host to run these tasks on, for future use. | |
28 |
| -|kvm_vm_pool_dir |:heavy_check_mark:| |the libvirt pool where VM images are stored | |
29 |
| -|kvm_vm_root_pwd | |see defaults/main.yml|sets root's password when cloud-init is executed | |
30 |
| -|vm_virtinstall_net_opts | | |Libvirt network with opitions that VMs will sit on | |
31 |
| -|manage_dns | |yes |Enable cloud-init to setup /etc/resolv.conf | |
32 |
| -|os_disk |x |see defaults/main.yml|Full path to the OS primary qcow2 disk | |
33 |
| -|os_qcow_template |x |see defaults/main.yml|Full path to the OS qcow template | |
34 |
| -|os_variant |:heavy_check_mark:|see defaults/main.yml|Which Linux distro | |
35 |
| -|rhsm_activationkey rhsm_org rhsm_password rhsm_username|:heavy_check_mark:|none |Register system to Red Hat. Use either rhsm_activationkey & rhsm_org or rhsm_password and rhsm_username| |
36 |
| -|search_domains |x |see defaults/main.yml|sets /etc/resolv.conf search domains | |
37 |
| -|vm_cpu |:heavy_check_mark:|see defaults/main.yml|The number of vpcu's for the VM | |
38 |
| -|vm_data_dir |:heavy_check_mark:|see defaults/main.yml|files related to VM's are stored | |
39 |
| -|vm_domain |:heavy_check_mark:|see defaults/main.yml|domain for the VM | |
40 |
| -|vm_hostname |x |see defaults/main.yml| | |
41 |
| -|vm_local_hostname |x |see defaults/main.yml| | |
42 |
| -|vm_memory |:heavy_check_mark:|see defaults/main.yml|amount of memory for VM | |
43 |
| -|vm_name |:heavy_check_mark:|none |Short name of the vm | |
44 |
| -|vm_network_br |:heavy_check_mark:|see defaults/main.yml|Libvirt network bridge | |
45 |
| -|vm_provision_vars |:heavy_check_mark:|see defaults/main.yml|location for vars file created during play | |
46 |
| -|vm_public_key |x |see defaults/main.yml|user public key | |
47 |
| -|vm_recreate |x |false |recreates VM | |
48 |
| -|vm_teardown |x |false |delete VM and associated files VM | |
49 |
| -|vm_root_disk_size |:heavy_check_mark:|see defaults/main.yml|size of the OS root disk | |
50 |
| -|vm_virtinstall_script |:heavy_check_mark:| |full path to virt-install script generated | |
51 |
| -|update_inventory |x |false |updates the static inventory file | |
52 |
| -|inventory_file |x |none |path to local inventory file | |
53 |
| - |
| 15 | +Please see defaults/main.yml |
54 | 16 |
|
55 | 17 | Dependencies
|
56 | 18 | ------------
|
| 19 | +N/A |
57 | 20 |
|
58 |
| -A list of other roles hosted on Galaxy should go here, plus any details in regards to parameters that may need to be set for other roles, or variables that are used from other roles. |
| 21 | +Example Playbooks |
| 22 | +----------------- |
59 | 23 |
|
60 |
| -Example Playbook |
61 |
| ----------------- |
| 24 | +**Deploy Fedora** |
62 | 25 | ```
|
63 |
| -- hosts: localhost |
64 |
| - tags: provision |
| 26 | +- name: Fedora VM |
| 27 | + hosts: localhost |
| 28 | + become: yes |
| 29 | +
|
65 | 30 | vars:
|
66 |
| - update_inventory: true |
67 |
| - inventory_file: /inventory/instances/localhost |
68 |
| - kvm_vm_pool_dir: "/var/lib/libvirt/images" |
69 |
| - kvm_install_host: localhost |
70 |
| - vm_recreate: false |
71 |
| - vm_teardown: false |
72 |
| - cloud_init_vm_image: "rhel-server-7.6-x86_64-kvm.qcow2" |
73 |
| - vm_name: test0073 |
74 |
| - vm_public_key: "{{ lookup('file', '~/.ssh/id_rsa.pub') }}" |
| 31 | + vm_name: "fedora32" |
75 | 32 | vm_cpu: 2
|
76 | 33 | vm_memory: 2048
|
77 |
| - vm_root_disk_size: 20G |
78 |
| - vm_libvirt_net: default |
79 |
| - rhsm_org: "7828949" |
80 |
| - rhsm_activationkey: "act-os-rhel-7Server" |
81 |
| - admin_user_password: mypassword |
82 |
| - extra_storage: |
83 |
| - - size: 80G |
84 |
| - enable: true |
85 |
| - - size: 50G |
86 |
| - enable: true |
| 34 | + vm_root_disk_size: 20 |
| 35 | + vm_teardown: no |
| 36 | + vm_qcow_image: Fedora-Cloud-Base-32-1.6.x86_64.qcow2 |
| 37 | + admin_user: changeme |
| 38 | + admin_user_password: changeme |
| 39 | + kvm_vm_root_pwd: changeme |
| 40 | + os_release: fedora31 |
| 41 | + |
| 42 | +
|
| 43 | + tasks: |
| 44 | + - name: deploy a kvm node |
| 45 | + include_role: |
| 46 | + name: deploy-kvm-vm |
| 47 | +``` |
| 48 | + |
| 49 | +**Deploy RHEL 8** |
| 50 | +``` |
| 51 | +- name: Deploy RHEL 8.3 Beta VM |
| 52 | + hosts: localhost |
| 53 | + become: yes |
| 54 | +
|
| 55 | + vars: |
| 56 | + vm_name: "rhel83-beta" |
| 57 | + vm_cpu: 2 |
| 58 | + vm_memory: 2048 |
| 59 | + vm_root_disk_size: 20 |
| 60 | + vm_teardown: no |
| 61 | + vm_qcow_image: rhel-8.3-beta-1-x86_64-kvm.qcow2 |
| 62 | + admin_user: changeme |
| 63 | + admin_user_password: changeme |
| 64 | + kvm_vm_root_pwd: changeme |
| 65 | + os_release: rhel8.2 |
| 66 | + rhsm_activationkey: rhel-server |
| 67 | + rhsm_org: 1234565 |
| 68 | +
|
| 69 | +
|
87 | 70 | tasks:
|
88 |
| - - name: Create KVM VM |
| 71 | + - name: deploy a kvm node |
89 | 72 | include_role:
|
90 |
| - name: ansible-role-rhel7-kvm-cloud-init |
| 73 | + name: deploy-kvm-vm |
91 | 74 | ```
|
92 | 75 |
|
93 | 76 | License
|
|
0 commit comments