aboutsummaryrefslogtreecommitdiff
path: root/docs/README.md
blob: c3929cdab2a3f70fb3f03c10d932198dc9234c73 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
# Documentation

## Variable Explanation

Below is a table describing each variable, and which Ansible role the variable is used in.

| Variable                   | zfs | libvirt | guest-configure | Default             | Required | Description |
| :------:                   | :-: | :-----: |:--------------: | :----------------:  | :------: | -----------
| "host"                     |  X  |    X    |       X         |                     |     X    | Hostname for the VM to be created, name for the child dataset to be created, and used to connect and configure the guest |
| ```os```                   |     |    X    |                 | ```rhel8-unknown``` |          | Libvirt needs this to determine what hardware to use, list of all options can be found with ```#virt-install --osinfo list``` on your hypervisor |
| ```kickstart```            |     |    X    |                 |                     |          | Kickstart file for the new VM, files are located in roles/libvirt/templates/kickstart, not defining this will result in a manual install |
| ```iso_path```             |     |    X    |                 |                     |     X    | Path on hypervisor to ISO for virt-installer to use |
| ```cpus```                 |     |    X    |                 | ```1```             |          | Amount of CPU's for the new VM |
| ```memory_mb```            |     |    X    |                 | ```1024```          |          | Amount of RAM (in MB) for the new VM |
| ```disk_gb```              |     |    X    |                 | ```20```            |          | Amount of disk (in GB) for the new VM |
| ```disk_format```          |     |    X    |                 | ```qcow2```         |          | Image format for disk on new VM, recommended to use ```raw``` on ZFS (with compression) or ```qcow2``` otherwise |
| ```network```              |     |    X    |                 | ```default```       |          | Name of the network device (usually a bridge) on the hypervisor to attach to new VM, not defining this will use the ```default``` device |
| ```parent_dataset```       |  X  |    X    |                 |                     |     X    | Parent ZFS dataset, child dataset for the VM will be created here - virt-install will also use this path for the new VM's installation |
| ```parent_dataset_mount``` |     |    X    |                 |                     |          | Mountpoint for the parent ZFS dataset - this is used only for virt-install |
| ```timezone```             |     |    X    |                 | ```Etc/GMT```       |          | Sets the timezone in Kickstart, does nothing for non-Kickstart installs |
| ```hypervisor_host```      |  X  |    X    |                 |                     |     X    | This is the host, either FQDN - IP - or "localhost", where ZFS and libvirt is running |
| ```pre_packages```         |     |         |       X         |                     |          | **List** of packages to be installed **first**, before the rest of the packages, on the new VM |
| ```packages```             |     |         |       X         |                     |          | **List** of packages to be installed on the new VM |
| ```user```                 |     |         |       X         |                     |          | User to be created on the new VM |
| ```root_password```        |     |    X    |       X         | Kickstart - Random  |          | Sets root password in Kickstart (uses random if not specified), can be used to communicate with new VM if no SSH key is defined |
| ```ssh_keys```              |     |    X    |                 |                     |          | List of keys to be put into the Kickstart template for the root user and the regular user (if defined) - if not defined, PermitRootLogin is used in Kickstart |
| ```shell```                |     |         |       X         |                     |          | Set new user's shell to this shell, does not change the root user shell - does nothing if no regular user defined |
| ```services```             |     |         |       X         |                     |          | Services to enable on the new VM
| ```redhat_user```          |     |         |       X         |                     |          | Username to register/unregister new VM with Red Hat Subscription Manager |
| ```redhat_password```      |     |         |       X         |                     |          | Password to register/unregister new VM with Red Hat Subscription Manager |
| `redhat_activation_key`    |     |         |       X         |                     |          | Activation key for RHSM |
| `redhat_org_id`            |     |         |       X         |                     |          | Org ID for RHSM |
| ```libvirt_vm_location_arguments``` | | X | | | | This is a temporary workaround for Fedora ISOs, the path to the Kernel is missing from the ISO and can be defined here if necessary |
| `fips`                     |     |    X    |                 | `false`             |          | This passes fips=1 to `libvirt` while creating the VM, only works with kickstart |

## Inventory
Ansible provides a flexible way to define your environment: [How to build your inventory](https://docs.ansible.com/ansible/latest/inventory_guide/intro_inventory.html).
Every variable listed above can be mixed and matched to make a dynamic inventory. Host-specific variables win against shared variables, they are not merged. This is standard Ansible behavior.

Here are a few examples:

```yaml
# Single VM
all:
  hosts:
    first-vm: #This is the hostname
      iso_path:        "/path/to/iso/install.iso"
      parent_dataset:  "zfs-parent-dataset/zfs-child-dataset"
      hypervisor_host: "hypervisor-hostname.fqdn"
```

```yaml
# Two VMs, sharing variables
all:
  hosts:
    first-vm:
    second-vm:
  vars:
    iso_path:        "/path/to/iso/install.iso"
    parent_dataset:  "zfs-parent-dataset/zfs-child-dataset"
    hypervisor_host: "hypervisor-hostname.fqdn"
```

```yaml
# Three VMs, shared and host-specific variables
all:
  hosts:
    first-vm:
      iso_path: "/path/to/iso/install-1.iso"
    second-vm:
      iso_path: "/path/to/iso/install-2.iso"
    third-vm:
      iso_path: "/path/to/iso/install-3.iso"
  vars:
    parent_dataset:  "zfs-parent-dataset/zfs-child-dataset"
    hypervisor_host: "hypervisor-hostname.fqdn"
```

```yaml
# Single CentOS stream-9 VM, use SSH key for root,
# install EPEL, create user, use SSH key for user, install and use fish shell for user
all:
  hosts:
    test-stream9:
      os: "rhel9-unknown"
      kickstart: "el9.ks"
      iso_path: "/path/to/strem9.iso"
  vars:
    hypervisor_host: "hypervisor-hostname.fqdn"
    parent_dataset: "zfs-parent-dataset/zfs-child-dataset"
    user: "myuser"
    shell: "/usr/bin/fish"
    ssh_keys:
      - ssh-rsa <key1>
      - ssh-rsa <key2>
    pre-packages:
      - epel-release
    packages:
      - fish
```

```yaml
# Two RHEL VMs, use SSH key for root, register VM with Red Hat,
# install EPEL, create user, use SSH key for user, install and use fish shell for user
# using a non-standard mountpoint for the ZFS parent dataset
all:
  hosts:
    test-rhel8:
      os: "rhel8-unknown"
      kickstart: "el8.ks"
      iso_path: "/path/to/el8.iso"
      pre_packages:
        - https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
    test-rhel9:
      os: "rhel9-unknown"
      kickstart: "el9.ks"
      iso_path: "/path/to/el9.iso"
      pre_packages:
        - https://dl.fedoraproject.org/pub/epel/epel-release-latest-9.noarch.rpm
  vars:
    hypervisor_host: "hypervisor-hostname.fqdn"
    parent_dataset: "zfs-parent-dataset/zfs-child-dataset"
    parent_dataset_mount: "/mnt/zfs-parent-dataset/zfs-child-dataset"
    user: "myuser"
    shell: "/usr/bin/fish"
    ssh_keys:
      - ssh-rsa <key1>
      - ssh-rsa <key2>
    packages:
      - fish
    redhat_user: "myrhsmuser"
    redhat_password: "myrhsmpassword"
```


For examples of more variable usage, check the ```sample-environment.yml```.